Remove StorageException from throws clauses
Change-Id: I48a0169293ddf766fbbd924cb310f9b8dacc58cf
This commit is contained in:
@@ -53,7 +53,6 @@ import com.google.gerrit.common.data.Permission;
|
|||||||
import com.google.gerrit.common.data.PermissionRange;
|
import com.google.gerrit.common.data.PermissionRange;
|
||||||
import com.google.gerrit.common.data.PermissionRule;
|
import com.google.gerrit.common.data.PermissionRule;
|
||||||
import com.google.gerrit.common.data.PermissionRule.Action;
|
import com.google.gerrit.common.data.PermissionRule.Action;
|
||||||
import com.google.gerrit.exceptions.StorageException;
|
|
||||||
import com.google.gerrit.extensions.api.GerritApi;
|
import com.google.gerrit.extensions.api.GerritApi;
|
||||||
import com.google.gerrit.extensions.api.changes.ReviewInput;
|
import com.google.gerrit.extensions.api.changes.ReviewInput;
|
||||||
import com.google.gerrit.extensions.api.changes.RevisionApi;
|
import com.google.gerrit.extensions.api.changes.RevisionApi;
|
||||||
@@ -1087,7 +1086,7 @@ public abstract class AbstractDaemonTest {
|
|||||||
.inOrder();
|
.inOrder();
|
||||||
}
|
}
|
||||||
|
|
||||||
protected PatchSet getPatchSet(PatchSet.Id psId) throws StorageException {
|
protected PatchSet getPatchSet(PatchSet.Id psId) {
|
||||||
return changeDataFactory.create(project, psId.getParentKey()).patchSet(psId);
|
return changeDataFactory.create(project, psId.getParentKey()).patchSet(psId);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1416,7 +1415,7 @@ public abstract class AbstractDaemonTest {
|
|||||||
}
|
}
|
||||||
|
|
||||||
protected void watch(PushOneCommit.Result r, ProjectWatchInfoConfiguration config)
|
protected void watch(PushOneCommit.Result r, ProjectWatchInfoConfiguration config)
|
||||||
throws StorageException, RestApiException {
|
throws RestApiException {
|
||||||
watch(r.getChange().project().get(), config);
|
watch(r.getChange().project().get(), config);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -21,7 +21,6 @@ import com.google.common.collect.ImmutableSet;
|
|||||||
import com.google.common.collect.Sets;
|
import com.google.common.collect.Sets;
|
||||||
import com.google.gerrit.common.Nullable;
|
import com.google.gerrit.common.Nullable;
|
||||||
import com.google.gerrit.exceptions.NoSuchGroupException;
|
import com.google.gerrit.exceptions.NoSuchGroupException;
|
||||||
import com.google.gerrit.exceptions.StorageException;
|
|
||||||
import com.google.gerrit.reviewdb.client.Account;
|
import com.google.gerrit.reviewdb.client.Account;
|
||||||
import com.google.gerrit.reviewdb.client.AccountGroup;
|
import com.google.gerrit.reviewdb.client.AccountGroup;
|
||||||
import com.google.gerrit.server.ServerInitiated;
|
import com.google.gerrit.server.ServerInitiated;
|
||||||
@@ -157,7 +156,7 @@ public class AccountCreator {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private void addGroupMember(AccountGroup.UUID groupUuid, Account.Id accountId)
|
private void addGroupMember(AccountGroup.UUID groupUuid, Account.Id accountId)
|
||||||
throws StorageException, IOException, NoSuchGroupException, ConfigInvalidException {
|
throws IOException, NoSuchGroupException, ConfigInvalidException {
|
||||||
InternalGroupUpdate groupUpdate =
|
InternalGroupUpdate groupUpdate =
|
||||||
InternalGroupUpdate.builder()
|
InternalGroupUpdate.builder()
|
||||||
.setMemberModification(memberIds -> Sets.union(memberIds, ImmutableSet.of(accountId)))
|
.setMemberModification(memberIds -> Sets.union(memberIds, ImmutableSet.of(accountId)))
|
||||||
|
@@ -24,7 +24,6 @@ import com.google.common.collect.ImmutableMap;
|
|||||||
import com.google.common.collect.Iterables;
|
import com.google.common.collect.Iterables;
|
||||||
import com.google.common.collect.Sets;
|
import com.google.common.collect.Sets;
|
||||||
import com.google.gerrit.common.Nullable;
|
import com.google.gerrit.common.Nullable;
|
||||||
import com.google.gerrit.exceptions.StorageException;
|
|
||||||
import com.google.gerrit.reviewdb.client.Account;
|
import com.google.gerrit.reviewdb.client.Account;
|
||||||
import com.google.gerrit.reviewdb.client.Change;
|
import com.google.gerrit.reviewdb.client.Change;
|
||||||
import com.google.gerrit.reviewdb.client.PatchSet;
|
import com.google.gerrit.reviewdb.client.PatchSet;
|
||||||
@@ -334,15 +333,15 @@ public class PushOneCommit {
|
|||||||
this.resSubj = subject;
|
this.resSubj = subject;
|
||||||
}
|
}
|
||||||
|
|
||||||
public ChangeData getChange() throws StorageException {
|
public ChangeData getChange() {
|
||||||
return Iterables.getOnlyElement(queryProvider.get().byKeyPrefix(changeId));
|
return Iterables.getOnlyElement(queryProvider.get().byKeyPrefix(changeId));
|
||||||
}
|
}
|
||||||
|
|
||||||
public PatchSet getPatchSet() throws StorageException {
|
public PatchSet getPatchSet() {
|
||||||
return getChange().currentPatchSet();
|
return getChange().currentPatchSet();
|
||||||
}
|
}
|
||||||
|
|
||||||
public PatchSet.Id getPatchSetId() throws StorageException {
|
public PatchSet.Id getPatchSetId() {
|
||||||
return getChange().change().currentPatchSetId();
|
return getChange().change().currentPatchSetId();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -359,8 +358,7 @@ public class PushOneCommit {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void assertChange(
|
public void assertChange(
|
||||||
Change.Status expectedStatus, String expectedTopic, TestAccount... expectedReviewers)
|
Change.Status expectedStatus, String expectedTopic, TestAccount... expectedReviewers) {
|
||||||
throws StorageException {
|
|
||||||
assertChange(
|
assertChange(
|
||||||
expectedStatus, expectedTopic, Arrays.asList(expectedReviewers), ImmutableList.of());
|
expectedStatus, expectedTopic, Arrays.asList(expectedReviewers), ImmutableList.of());
|
||||||
}
|
}
|
||||||
@@ -369,8 +367,7 @@ public class PushOneCommit {
|
|||||||
Change.Status expectedStatus,
|
Change.Status expectedStatus,
|
||||||
String expectedTopic,
|
String expectedTopic,
|
||||||
List<TestAccount> expectedReviewers,
|
List<TestAccount> expectedReviewers,
|
||||||
List<TestAccount> expectedCcs)
|
List<TestAccount> expectedCcs) {
|
||||||
throws StorageException {
|
|
||||||
Change c = getChange().change();
|
Change c = getChange().change();
|
||||||
assertThat(c.getSubject()).isEqualTo(resSubj);
|
assertThat(c.getSubject()).isEqualTo(resSubj);
|
||||||
assertThat(c.getStatus()).isEqualTo(expectedStatus);
|
assertThat(c.getStatus()).isEqualTo(expectedStatus);
|
||||||
@@ -380,8 +377,7 @@ public class PushOneCommit {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private void assertReviewers(
|
private void assertReviewers(
|
||||||
Change c, ReviewerStateInternal state, List<TestAccount> expectedReviewers)
|
Change c, ReviewerStateInternal state, List<TestAccount> expectedReviewers) {
|
||||||
throws StorageException {
|
|
||||||
Iterable<Account.Id> actualIds =
|
Iterable<Account.Id> actualIds =
|
||||||
approvalsUtil.getReviewers(notesFactory.createChecked(c)).byState(state);
|
approvalsUtil.getReviewers(notesFactory.createChecked(c)).byState(state);
|
||||||
assertThat(actualIds)
|
assertThat(actualIds)
|
||||||
|
@@ -16,7 +16,6 @@ package com.google.gerrit.acceptance.testsuite.account;
|
|||||||
|
|
||||||
import static com.google.common.base.Preconditions.checkState;
|
import static com.google.common.base.Preconditions.checkState;
|
||||||
|
|
||||||
import com.google.gerrit.exceptions.StorageException;
|
|
||||||
import com.google.gerrit.reviewdb.client.Account;
|
import com.google.gerrit.reviewdb.client.Account;
|
||||||
import com.google.gerrit.server.ServerInitiated;
|
import com.google.gerrit.server.ServerInitiated;
|
||||||
import com.google.gerrit.server.account.AccountState;
|
import com.google.gerrit.server.account.AccountState;
|
||||||
@@ -68,7 +67,7 @@ public class AccountOperationsImpl implements AccountOperations {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private AccountState createAccount(AccountsUpdate.AccountUpdater accountUpdater)
|
private AccountState createAccount(AccountsUpdate.AccountUpdater accountUpdater)
|
||||||
throws StorageException, IOException, ConfigInvalidException {
|
throws IOException, ConfigInvalidException {
|
||||||
Account.Id accountId = new Account.Id(seq.nextAccountId());
|
Account.Id accountId = new Account.Id(seq.nextAccountId());
|
||||||
return accountsUpdate.insert("Create Test Account", accountId, accountUpdater);
|
return accountsUpdate.insert("Create Test Account", accountId, accountUpdater);
|
||||||
}
|
}
|
||||||
@@ -146,7 +145,7 @@ public class AccountOperationsImpl implements AccountOperations {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private void updateAccount(TestAccountUpdate accountUpdate)
|
private void updateAccount(TestAccountUpdate accountUpdate)
|
||||||
throws StorageException, IOException, ConfigInvalidException {
|
throws IOException, ConfigInvalidException {
|
||||||
AccountsUpdate.AccountUpdater accountUpdater =
|
AccountsUpdate.AccountUpdater accountUpdater =
|
||||||
(account, updateBuilder) -> fillBuilder(updateBuilder, accountUpdate, accountId);
|
(account, updateBuilder) -> fillBuilder(updateBuilder, accountUpdate, accountId);
|
||||||
Optional<AccountState> updatedAccount = updateAccount(accountUpdater);
|
Optional<AccountState> updatedAccount = updateAccount(accountUpdater);
|
||||||
@@ -154,7 +153,7 @@ public class AccountOperationsImpl implements AccountOperations {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private Optional<AccountState> updateAccount(AccountsUpdate.AccountUpdater accountUpdater)
|
private Optional<AccountState> updateAccount(AccountsUpdate.AccountUpdater accountUpdater)
|
||||||
throws StorageException, IOException, ConfigInvalidException {
|
throws IOException, ConfigInvalidException {
|
||||||
return accountsUpdate.update("Update Test Account", accountId, accountUpdater);
|
return accountsUpdate.update("Update Test Account", accountId, accountUpdater);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -18,7 +18,6 @@ import static com.google.common.base.Preconditions.checkState;
|
|||||||
|
|
||||||
import com.google.gerrit.exceptions.DuplicateKeyException;
|
import com.google.gerrit.exceptions.DuplicateKeyException;
|
||||||
import com.google.gerrit.exceptions.NoSuchGroupException;
|
import com.google.gerrit.exceptions.NoSuchGroupException;
|
||||||
import com.google.gerrit.exceptions.StorageException;
|
|
||||||
import com.google.gerrit.reviewdb.client.AccountGroup;
|
import com.google.gerrit.reviewdb.client.AccountGroup;
|
||||||
import com.google.gerrit.server.GerritPersonIdent;
|
import com.google.gerrit.server.GerritPersonIdent;
|
||||||
import com.google.gerrit.server.ServerInitiated;
|
import com.google.gerrit.server.ServerInitiated;
|
||||||
@@ -70,7 +69,7 @@ public class GroupOperationsImpl implements GroupOperations {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private AccountGroup.UUID createNewGroup(TestGroupCreation groupCreation)
|
private AccountGroup.UUID createNewGroup(TestGroupCreation groupCreation)
|
||||||
throws ConfigInvalidException, IOException, StorageException {
|
throws ConfigInvalidException, IOException {
|
||||||
InternalGroupCreation internalGroupCreation = toInternalGroupCreation(groupCreation);
|
InternalGroupCreation internalGroupCreation = toInternalGroupCreation(groupCreation);
|
||||||
InternalGroupUpdate internalGroupUpdate = toInternalGroupUpdate(groupCreation);
|
InternalGroupUpdate internalGroupUpdate = toInternalGroupUpdate(groupCreation);
|
||||||
InternalGroup internalGroup =
|
InternalGroup internalGroup =
|
||||||
@@ -78,8 +77,7 @@ public class GroupOperationsImpl implements GroupOperations {
|
|||||||
return internalGroup.getGroupUUID();
|
return internalGroup.getGroupUUID();
|
||||||
}
|
}
|
||||||
|
|
||||||
private InternalGroupCreation toInternalGroupCreation(TestGroupCreation groupCreation)
|
private InternalGroupCreation toInternalGroupCreation(TestGroupCreation groupCreation) {
|
||||||
throws StorageException {
|
|
||||||
AccountGroup.Id groupId = new AccountGroup.Id(seq.nextGroupId());
|
AccountGroup.Id groupId = new AccountGroup.Id(seq.nextGroupId());
|
||||||
String groupName = groupCreation.name().orElse("group-with-id-" + groupId.get());
|
String groupName = groupCreation.name().orElse("group-with-id-" + groupId.get());
|
||||||
AccountGroup.UUID groupUuid = GroupUUID.make(groupName, serverIdent);
|
AccountGroup.UUID groupUuid = GroupUUID.make(groupName, serverIdent);
|
||||||
|
@@ -377,16 +377,16 @@ abstract class AbstractElasticIndex<K, V> implements Index<K, V> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public ResultSet<V> read() throws StorageException {
|
public ResultSet<V> read() {
|
||||||
return readImpl((doc) -> AbstractElasticIndex.this.fromDocument(doc, opts.fields()));
|
return readImpl((doc) -> AbstractElasticIndex.this.fromDocument(doc, opts.fields()));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public ResultSet<FieldBundle> readRaw() throws StorageException {
|
public ResultSet<FieldBundle> readRaw() {
|
||||||
return readImpl(AbstractElasticIndex.this::toFieldBundle);
|
return readImpl(AbstractElasticIndex.this::toFieldBundle);
|
||||||
}
|
}
|
||||||
|
|
||||||
private <T> ResultSet<T> readImpl(Function<JsonObject, T> mapper) throws StorageException {
|
private <T> ResultSet<T> readImpl(Function<JsonObject, T> mapper) {
|
||||||
try {
|
try {
|
||||||
String uri = getURI(index, SEARCH);
|
String uri = getURI(index, SEARCH);
|
||||||
Response response =
|
Response response =
|
||||||
|
@@ -156,8 +156,7 @@ public class GerritPublicKeyChecker extends PublicKeyChecker {
|
|||||||
return CheckResult.bad(missingUserIds(allowedUserIds));
|
return CheckResult.bad(missingUserIds(allowedUserIds));
|
||||||
}
|
}
|
||||||
|
|
||||||
private CheckResult checkIdsForArbitraryUser(PGPPublicKey key)
|
private CheckResult checkIdsForArbitraryUser(PGPPublicKey key) throws PGPException {
|
||||||
throws PGPException, StorageException {
|
|
||||||
List<AccountState> accountStates = accountQueryProvider.get().byExternalId(toExtIdKey(key));
|
List<AccountState> accountStates = accountQueryProvider.get().byExternalId(toExtIdKey(key));
|
||||||
if (accountStates.isEmpty()) {
|
if (accountStates.isEmpty()) {
|
||||||
return CheckResult.bad("Key is not associated with any users");
|
return CheckResult.bad("Key is not associated with any users");
|
||||||
|
@@ -18,7 +18,6 @@ import static com.google.gerrit.gpg.PublicKeyStore.keyIdToString;
|
|||||||
import static com.google.gerrit.server.account.externalids.ExternalId.SCHEME_GPGKEY;
|
import static com.google.gerrit.server.account.externalids.ExternalId.SCHEME_GPGKEY;
|
||||||
|
|
||||||
import com.google.common.io.BaseEncoding;
|
import com.google.common.io.BaseEncoding;
|
||||||
import com.google.gerrit.exceptions.StorageException;
|
|
||||||
import com.google.gerrit.extensions.common.Input;
|
import com.google.gerrit.extensions.common.Input;
|
||||||
import com.google.gerrit.extensions.restapi.ResourceConflictException;
|
import com.google.gerrit.extensions.restapi.ResourceConflictException;
|
||||||
import com.google.gerrit.extensions.restapi.ResourceNotFoundException;
|
import com.google.gerrit.extensions.restapi.ResourceNotFoundException;
|
||||||
@@ -63,7 +62,7 @@ public class DeleteGpgKey implements RestModifyView<GpgKey, Input> {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Response<?> apply(GpgKey rsrc, Input input)
|
public Response<?> apply(GpgKey rsrc, Input input)
|
||||||
throws RestApiException, PGPException, StorageException, IOException, ConfigInvalidException {
|
throws RestApiException, PGPException, IOException, ConfigInvalidException {
|
||||||
PGPPublicKey key = rsrc.getKeyRing().getPublicKey();
|
PGPPublicKey key = rsrc.getKeyRing().getPublicKey();
|
||||||
String fingerprint = BaseEncoding.base16().encode(key.getFingerprint());
|
String fingerprint = BaseEncoding.base16().encode(key.getFingerprint());
|
||||||
Optional<ExternalId> extId = externalIds.get(ExternalId.Key.create(SCHEME_GPGKEY, fingerprint));
|
Optional<ExternalId> extId = externalIds.get(ExternalId.Key.create(SCHEME_GPGKEY, fingerprint));
|
||||||
|
@@ -21,7 +21,6 @@ import com.google.common.base.CharMatcher;
|
|||||||
import com.google.common.collect.ImmutableList;
|
import com.google.common.collect.ImmutableList;
|
||||||
import com.google.common.flogger.FluentLogger;
|
import com.google.common.flogger.FluentLogger;
|
||||||
import com.google.common.io.BaseEncoding;
|
import com.google.common.io.BaseEncoding;
|
||||||
import com.google.gerrit.exceptions.StorageException;
|
|
||||||
import com.google.gerrit.extensions.common.GpgKeyInfo;
|
import com.google.gerrit.extensions.common.GpgKeyInfo;
|
||||||
import com.google.gerrit.extensions.registration.DynamicMap;
|
import com.google.gerrit.extensions.registration.DynamicMap;
|
||||||
import com.google.gerrit.extensions.restapi.AuthException;
|
import com.google.gerrit.extensions.restapi.AuthException;
|
||||||
@@ -86,7 +85,7 @@ public class GpgKeys implements ChildCollection<AccountResource, GpgKey> {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public GpgKey parse(AccountResource parent, IdString id)
|
public GpgKey parse(AccountResource parent, IdString id)
|
||||||
throws ResourceNotFoundException, PGPException, StorageException, IOException {
|
throws ResourceNotFoundException, PGPException, IOException {
|
||||||
checkVisible(self, parent);
|
checkVisible(self, parent);
|
||||||
|
|
||||||
ExternalId gpgKeyExtId = findGpgKey(id.get(), getGpgExtIds(parent));
|
ExternalId gpgKeyExtId = findGpgKey(id.get(), getGpgExtIds(parent));
|
||||||
@@ -142,7 +141,7 @@ public class GpgKeys implements ChildCollection<AccountResource, GpgKey> {
|
|||||||
public class ListGpgKeys implements RestReadView<AccountResource> {
|
public class ListGpgKeys implements RestReadView<AccountResource> {
|
||||||
@Override
|
@Override
|
||||||
public Map<String, GpgKeyInfo> apply(AccountResource rsrc)
|
public Map<String, GpgKeyInfo> apply(AccountResource rsrc)
|
||||||
throws StorageException, PGPException, IOException, ResourceNotFoundException {
|
throws PGPException, IOException, ResourceNotFoundException {
|
||||||
checkVisible(self, rsrc);
|
checkVisible(self, rsrc);
|
||||||
Map<String, GpgKeyInfo> keys = new HashMap<>();
|
Map<String, GpgKeyInfo> keys = new HashMap<>();
|
||||||
try (PublicKeyStore store = storeProvider.get()) {
|
try (PublicKeyStore store = storeProvider.get()) {
|
||||||
|
@@ -27,7 +27,6 @@ import com.google.common.collect.Maps;
|
|||||||
import com.google.common.flogger.FluentLogger;
|
import com.google.common.flogger.FluentLogger;
|
||||||
import com.google.common.io.BaseEncoding;
|
import com.google.common.io.BaseEncoding;
|
||||||
import com.google.gerrit.exceptions.EmailException;
|
import com.google.gerrit.exceptions.EmailException;
|
||||||
import com.google.gerrit.exceptions.StorageException;
|
|
||||||
import com.google.gerrit.extensions.api.accounts.GpgKeysInput;
|
import com.google.gerrit.extensions.api.accounts.GpgKeysInput;
|
||||||
import com.google.gerrit.extensions.common.GpgKeyInfo;
|
import com.google.gerrit.extensions.common.GpgKeyInfo;
|
||||||
import com.google.gerrit.extensions.restapi.BadRequestException;
|
import com.google.gerrit.extensions.restapi.BadRequestException;
|
||||||
@@ -108,7 +107,7 @@ public class PostGpgKeys implements RestModifyView<AccountResource, GpgKeysInput
|
|||||||
@Override
|
@Override
|
||||||
public Map<String, GpgKeyInfo> apply(AccountResource rsrc, GpgKeysInput input)
|
public Map<String, GpgKeyInfo> apply(AccountResource rsrc, GpgKeysInput input)
|
||||||
throws ResourceNotFoundException, BadRequestException, ResourceConflictException,
|
throws ResourceNotFoundException, BadRequestException, ResourceConflictException,
|
||||||
PGPException, StorageException, IOException, ConfigInvalidException {
|
PGPException, IOException, ConfigInvalidException {
|
||||||
GpgKeys.checkVisible(self, rsrc);
|
GpgKeys.checkVisible(self, rsrc);
|
||||||
|
|
||||||
Collection<ExternalId> existingExtIds =
|
Collection<ExternalId> existingExtIds =
|
||||||
@@ -249,7 +248,7 @@ public class PostGpgKeys implements RestModifyView<AccountResource, GpgKeysInput
|
|||||||
return ExternalId.Key.create(SCHEME_GPGKEY, BaseEncoding.base16().encode(fp));
|
return ExternalId.Key.create(SCHEME_GPGKEY, BaseEncoding.base16().encode(fp));
|
||||||
}
|
}
|
||||||
|
|
||||||
private Account getAccountByExternalId(ExternalId.Key extIdKey) throws StorageException {
|
private Account getAccountByExternalId(ExternalId.Key extIdKey) {
|
||||||
List<AccountState> accountStates = accountQueryProvider.get().byExternalId(extIdKey);
|
List<AccountState> accountStates = accountQueryProvider.get().byExternalId(extIdKey);
|
||||||
|
|
||||||
if (accountStates.isEmpty()) {
|
if (accountStates.isEmpty()) {
|
||||||
|
@@ -152,7 +152,7 @@ class HttpLoginServlet extends HttpServlet {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private void updateRemoteExternalId(AuthResult arsp, String remoteAuthToken)
|
private void updateRemoteExternalId(AuthResult arsp, String remoteAuthToken)
|
||||||
throws AccountException, StorageException, IOException, ConfigInvalidException {
|
throws AccountException, IOException, ConfigInvalidException {
|
||||||
accountManager.updateLink(
|
accountManager.updateLink(
|
||||||
arsp.getAccountId(),
|
arsp.getAccountId(),
|
||||||
new AuthRequest(ExternalId.Key.create(SCHEME_EXTERNAL, remoteAuthToken)));
|
new AuthRequest(ExternalId.Key.create(SCHEME_EXTERNAL, remoteAuthToken)));
|
||||||
|
@@ -62,7 +62,7 @@ public final class FieldDef<I, T> {
|
|||||||
@FunctionalInterface
|
@FunctionalInterface
|
||||||
public interface Getter<I, T> {
|
public interface Getter<I, T> {
|
||||||
@Nullable
|
@Nullable
|
||||||
T get(I input) throws StorageException, IOException;
|
T get(I input) throws IOException;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static class Builder<T> {
|
public static class Builder<T> {
|
||||||
@@ -133,10 +133,9 @@ public final class FieldDef<I, T> {
|
|||||||
*
|
*
|
||||||
* @param input input object.
|
* @param input input object.
|
||||||
* @return the field value(s) to index.
|
* @return the field value(s) to index.
|
||||||
* @throws StorageException
|
|
||||||
*/
|
*/
|
||||||
@Nullable
|
@Nullable
|
||||||
public T get(I input) throws StorageException {
|
public T get(I input) {
|
||||||
try {
|
try {
|
||||||
return getter.get(input);
|
return getter.get(input);
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
|
@@ -16,7 +16,6 @@ package com.google.gerrit.index.query;
|
|||||||
|
|
||||||
import static com.google.common.base.Preconditions.checkState;
|
import static com.google.common.base.Preconditions.checkState;
|
||||||
|
|
||||||
import com.google.gerrit.exceptions.StorageException;
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
import java.util.Collection;
|
import java.util.Collection;
|
||||||
@@ -82,7 +81,7 @@ public class AndPredicate<T> extends Predicate<T> implements Matchable<T> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean match(T object) throws StorageException {
|
public boolean match(T object) {
|
||||||
for (Predicate<T> c : children) {
|
for (Predicate<T> c : children) {
|
||||||
checkState(
|
checkState(
|
||||||
c.isMatchable(),
|
c.isMatchable(),
|
||||||
|
@@ -74,7 +74,7 @@ public class AndSource<T> extends AndPredicate<T>
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public ResultSet<T> read() throws StorageException {
|
public ResultSet<T> read() {
|
||||||
if (source == null) {
|
if (source == null) {
|
||||||
throw new StorageException("No DataSource: " + this);
|
throw new StorageException("No DataSource: " + this);
|
||||||
}
|
}
|
||||||
@@ -123,7 +123,7 @@ public class AndSource<T> extends AndPredicate<T>
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public ResultSet<FieldBundle> readRaw() throws StorageException {
|
public ResultSet<FieldBundle> readRaw() {
|
||||||
// TOOD(hiesel): Implement
|
// TOOD(hiesel): Implement
|
||||||
throw new UnsupportedOperationException("not implemented");
|
throw new UnsupportedOperationException("not implemented");
|
||||||
}
|
}
|
||||||
@@ -134,7 +134,7 @@ public class AndSource<T> extends AndPredicate<T>
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean match(T object) throws StorageException {
|
public boolean match(T object) {
|
||||||
if (isVisibleToPredicate != null && !isVisibleToPredicate.match(object)) {
|
if (isVisibleToPredicate != null && !isVisibleToPredicate.match(object)) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
@@ -14,15 +14,13 @@
|
|||||||
|
|
||||||
package com.google.gerrit.index.query;
|
package com.google.gerrit.index.query;
|
||||||
|
|
||||||
import com.google.gerrit.exceptions.StorageException;
|
|
||||||
|
|
||||||
public interface DataSource<T> {
|
public interface DataSource<T> {
|
||||||
/** @return an estimate of the number of results from {@link #read()}. */
|
/** @return an estimate of the number of results from {@link #read()}. */
|
||||||
int getCardinality();
|
int getCardinality();
|
||||||
|
|
||||||
/** @return read from the database and return the results. */
|
/** @return read from the database and return the results. */
|
||||||
ResultSet<T> read() throws StorageException;
|
ResultSet<T> read();
|
||||||
|
|
||||||
/** @return read from the database and return the raw results. */
|
/** @return read from the database and return the raw results. */
|
||||||
ResultSet<FieldBundle> readRaw() throws StorageException;
|
ResultSet<FieldBundle> readRaw();
|
||||||
}
|
}
|
||||||
|
@@ -77,17 +77,17 @@ public class IndexedQuery<I, T> extends Predicate<T> implements DataSource<T>, P
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public ResultSet<T> read() throws StorageException {
|
public ResultSet<T> read() {
|
||||||
return source.read();
|
return source.read();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public ResultSet<FieldBundle> readRaw() throws StorageException {
|
public ResultSet<FieldBundle> readRaw() {
|
||||||
return source.readRaw();
|
return source.readRaw();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public ResultSet<T> restart(int start) throws StorageException {
|
public ResultSet<T> restart(int start) {
|
||||||
opts = opts.withStart(start);
|
opts = opts.withStart(start);
|
||||||
try {
|
try {
|
||||||
source = index.getSource(pred, opts);
|
source = index.getSource(pred, opts);
|
||||||
|
@@ -14,7 +14,6 @@
|
|||||||
|
|
||||||
package com.google.gerrit.index.query;
|
package com.google.gerrit.index.query;
|
||||||
|
|
||||||
import com.google.gerrit.exceptions.StorageException;
|
|
||||||
import com.google.gerrit.index.FieldDef;
|
import com.google.gerrit.index.FieldDef;
|
||||||
import com.google.gerrit.index.query.RangeUtil.Range;
|
import com.google.gerrit.index.query.RangeUtil.Range;
|
||||||
|
|
||||||
@@ -30,9 +29,9 @@ public abstract class IntegerRangePredicate<T> extends IndexPredicate<T> {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
protected abstract Integer getValueInt(T object) throws StorageException;
|
protected abstract Integer getValueInt(T object);
|
||||||
|
|
||||||
public boolean match(T object) throws StorageException {
|
public boolean match(T object) {
|
||||||
Integer valueInt = getValueInt(object);
|
Integer valueInt = getValueInt(object);
|
||||||
if (valueInt == null) {
|
if (valueInt == null) {
|
||||||
return false;
|
return false;
|
||||||
|
@@ -88,11 +88,11 @@ public class InternalQuery<T, Q extends InternalQuery<T, Q>> {
|
|||||||
return self();
|
return self();
|
||||||
}
|
}
|
||||||
|
|
||||||
public final List<T> query(Predicate<T> p) throws StorageException {
|
public final List<T> query(Predicate<T> p) {
|
||||||
return queryResults(p).entities();
|
return queryResults(p).entities();
|
||||||
}
|
}
|
||||||
|
|
||||||
final QueryResult<T> queryResults(Predicate<T> p) throws StorageException {
|
final QueryResult<T> queryResults(Predicate<T> p) {
|
||||||
try {
|
try {
|
||||||
return queryProcessor.query(p);
|
return queryProcessor.query(p);
|
||||||
} catch (QueryParseException e) {
|
} catch (QueryParseException e) {
|
||||||
@@ -110,7 +110,7 @@ public class InternalQuery<T, Q extends InternalQuery<T, Q>> {
|
|||||||
* @return results of the queries, one list of results per input query, in the same order as the
|
* @return results of the queries, one list of results per input query, in the same order as the
|
||||||
* input.
|
* input.
|
||||||
*/
|
*/
|
||||||
public final List<List<T>> query(List<Predicate<T>> queries) throws StorageException {
|
public final List<List<T>> query(List<Predicate<T>> queries) {
|
||||||
try {
|
try {
|
||||||
return Lists.transform(queryProcessor.query(queries), QueryResult::entities);
|
return Lists.transform(queryProcessor.query(queries), QueryResult::entities);
|
||||||
} catch (QueryParseException e) {
|
} catch (QueryParseException e) {
|
||||||
@@ -144,11 +144,9 @@ public class InternalQuery<T, Q extends InternalQuery<T, Q>> {
|
|||||||
* @param predicate predicate to search for.
|
* @param predicate predicate to search for.
|
||||||
* @param <T> result type.
|
* @param <T> result type.
|
||||||
* @return exhaustive list of results, subject to the race condition described above.
|
* @return exhaustive list of results, subject to the race condition described above.
|
||||||
* @throws StorageException if an error occurred.
|
|
||||||
*/
|
*/
|
||||||
protected static <T> ImmutableList<T> queryExhaustively(
|
protected static <T> ImmutableList<T> queryExhaustively(
|
||||||
Supplier<? extends InternalQuery<T, ?>> querySupplier, Predicate<T> predicate)
|
Supplier<? extends InternalQuery<T, ?>> querySupplier, Predicate<T> predicate) {
|
||||||
throws StorageException {
|
|
||||||
ImmutableList.Builder<T> b = null;
|
ImmutableList.Builder<T> b = null;
|
||||||
int start = 0;
|
int start = 0;
|
||||||
while (true) {
|
while (true) {
|
||||||
|
@@ -14,15 +14,9 @@
|
|||||||
|
|
||||||
package com.google.gerrit.index.query;
|
package com.google.gerrit.index.query;
|
||||||
|
|
||||||
import com.google.gerrit.exceptions.StorageException;
|
|
||||||
|
|
||||||
public interface Matchable<T> {
|
public interface Matchable<T> {
|
||||||
/**
|
/** Does this predicate match this object? */
|
||||||
* Does this predicate match this object?
|
boolean match(T object);
|
||||||
*
|
|
||||||
* @throws StorageException
|
|
||||||
*/
|
|
||||||
boolean match(T object) throws StorageException;
|
|
||||||
|
|
||||||
/** @return a cost estimate to run this predicate, higher figures cost more. */
|
/** @return a cost estimate to run this predicate, higher figures cost more. */
|
||||||
int getCost();
|
int getCost();
|
||||||
|
@@ -16,7 +16,6 @@ package com.google.gerrit.index.query;
|
|||||||
|
|
||||||
import static com.google.common.base.Preconditions.checkState;
|
import static com.google.common.base.Preconditions.checkState;
|
||||||
|
|
||||||
import com.google.gerrit.exceptions.StorageException;
|
|
||||||
import java.util.Collection;
|
import java.util.Collection;
|
||||||
import java.util.Collections;
|
import java.util.Collections;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
@@ -64,7 +63,7 @@ public class NotPredicate<T> extends Predicate<T> implements Matchable<T> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean match(T object) throws StorageException {
|
public boolean match(T object) {
|
||||||
checkState(
|
checkState(
|
||||||
that.isMatchable(),
|
that.isMatchable(),
|
||||||
"match invoked, but child predicate %s doesn't implement %s",
|
"match invoked, but child predicate %s doesn't implement %s",
|
||||||
|
@@ -16,7 +16,6 @@ package com.google.gerrit.index.query;
|
|||||||
|
|
||||||
import static com.google.common.base.Preconditions.checkState;
|
import static com.google.common.base.Preconditions.checkState;
|
||||||
|
|
||||||
import com.google.gerrit.exceptions.StorageException;
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
import java.util.Collection;
|
import java.util.Collection;
|
||||||
@@ -82,7 +81,7 @@ public class OrPredicate<T> extends Predicate<T> implements Matchable<T> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean match(T object) throws StorageException {
|
public boolean match(T object) {
|
||||||
for (Predicate<T> c : children) {
|
for (Predicate<T> c : children) {
|
||||||
checkState(
|
checkState(
|
||||||
c.isMatchable(),
|
c.isMatchable(),
|
||||||
|
@@ -14,11 +14,10 @@
|
|||||||
|
|
||||||
package com.google.gerrit.index.query;
|
package com.google.gerrit.index.query;
|
||||||
|
|
||||||
import com.google.gerrit.exceptions.StorageException;
|
|
||||||
import com.google.gerrit.index.QueryOptions;
|
import com.google.gerrit.index.QueryOptions;
|
||||||
|
|
||||||
public interface Paginated<T> {
|
public interface Paginated<T> {
|
||||||
QueryOptions getOptions();
|
QueryOptions getOptions();
|
||||||
|
|
||||||
ResultSet<T> restart(int start) throws StorageException;
|
ResultSet<T> restart(int start);
|
||||||
}
|
}
|
||||||
|
@@ -172,7 +172,7 @@ public abstract class QueryProcessor<T> {
|
|||||||
* @param query the query.
|
* @param query the query.
|
||||||
* @return results of the query.
|
* @return results of the query.
|
||||||
*/
|
*/
|
||||||
public QueryResult<T> query(Predicate<T> query) throws StorageException, QueryParseException {
|
public QueryResult<T> query(Predicate<T> query) throws QueryParseException {
|
||||||
return query(ImmutableList.of(query)).get(0);
|
return query(ImmutableList.of(query)).get(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -187,8 +187,7 @@ public abstract class QueryProcessor<T> {
|
|||||||
* @return results of the queries, one QueryResult per input query, in the same order as the
|
* @return results of the queries, one QueryResult per input query, in the same order as the
|
||||||
* input.
|
* input.
|
||||||
*/
|
*/
|
||||||
public List<QueryResult<T>> query(List<Predicate<T>> queries)
|
public List<QueryResult<T>> query(List<Predicate<T>> queries) throws QueryParseException {
|
||||||
throws StorageException, QueryParseException {
|
|
||||||
try {
|
try {
|
||||||
return query(null, queries);
|
return query(null, queries);
|
||||||
} catch (StorageException e) {
|
} catch (StorageException e) {
|
||||||
@@ -200,8 +199,7 @@ public abstract class QueryProcessor<T> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private List<QueryResult<T>> query(
|
private List<QueryResult<T>> query(
|
||||||
@Nullable List<String> queryStrings, List<Predicate<T>> queries)
|
@Nullable List<String> queryStrings, List<Predicate<T>> queries) throws QueryParseException {
|
||||||
throws StorageException, QueryParseException {
|
|
||||||
long startNanos = System.nanoTime();
|
long startNanos = System.nanoTime();
|
||||||
checkState(!used.getAndSet(true), "%s has already been used", getClass().getSimpleName());
|
checkState(!used.getAndSet(true), "%s has already been used", getClass().getSimpleName());
|
||||||
int cnt = queries.size();
|
int cnt = queries.size();
|
||||||
|
@@ -486,16 +486,16 @@ public abstract class AbstractLuceneIndex<K, V> implements Index<K, V> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public ResultSet<V> read() throws StorageException {
|
public ResultSet<V> read() {
|
||||||
return readImpl(AbstractLuceneIndex.this::fromDocument);
|
return readImpl(AbstractLuceneIndex.this::fromDocument);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public ResultSet<FieldBundle> readRaw() throws StorageException {
|
public ResultSet<FieldBundle> readRaw() {
|
||||||
return readImpl(AbstractLuceneIndex.this::toFieldBundle);
|
return readImpl(AbstractLuceneIndex.this::toFieldBundle);
|
||||||
}
|
}
|
||||||
|
|
||||||
private <T> ResultSet<T> readImpl(Function<Document, T> mapper) throws StorageException {
|
private <T> ResultSet<T> readImpl(Function<Document, T> mapper) {
|
||||||
IndexSearcher searcher = null;
|
IndexSearcher searcher = null;
|
||||||
try {
|
try {
|
||||||
searcher = acquire();
|
searcher = acquire();
|
||||||
|
@@ -302,7 +302,7 @@ public class LuceneChangeIndex implements ChangeIndex {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public ResultSet<ChangeData> read() throws StorageException {
|
public ResultSet<ChangeData> read() {
|
||||||
if (Thread.interrupted()) {
|
if (Thread.interrupted()) {
|
||||||
Thread.currentThread().interrupt();
|
Thread.currentThread().interrupt();
|
||||||
throw new StorageException("interrupted");
|
throw new StorageException("interrupted");
|
||||||
@@ -326,7 +326,7 @@ public class LuceneChangeIndex implements ChangeIndex {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public ResultSet<FieldBundle> readRaw() throws StorageException {
|
public ResultSet<FieldBundle> readRaw() {
|
||||||
List<Document> documents;
|
List<Document> documents;
|
||||||
try {
|
try {
|
||||||
documents = doRead(IndexUtils.changeFields(opts));
|
documents = doRead(IndexUtils.changeFields(opts));
|
||||||
|
@@ -22,7 +22,6 @@ import com.google.common.base.Strings;
|
|||||||
import com.google.common.flogger.FluentLogger;
|
import com.google.common.flogger.FluentLogger;
|
||||||
import com.google.gerrit.common.Die;
|
import com.google.gerrit.common.Die;
|
||||||
import com.google.gerrit.common.IoUtil;
|
import com.google.gerrit.common.IoUtil;
|
||||||
import com.google.gerrit.exceptions.StorageException;
|
|
||||||
import com.google.gerrit.metrics.DisabledMetricMaker;
|
import com.google.gerrit.metrics.DisabledMetricMaker;
|
||||||
import com.google.gerrit.metrics.MetricMaker;
|
import com.google.gerrit.metrics.MetricMaker;
|
||||||
import com.google.gerrit.pgm.init.api.ConsoleUI;
|
import com.google.gerrit.pgm.init.api.ConsoleUI;
|
||||||
@@ -350,7 +349,7 @@ public class BaseInit extends SiteProgram {
|
|||||||
this.repositoryManager = repositoryManager;
|
this.repositoryManager = repositoryManager;
|
||||||
}
|
}
|
||||||
|
|
||||||
void upgradeSchema() throws StorageException {
|
void upgradeSchema() {
|
||||||
noteDbSchemaUpdater.update(new UpdateUIImpl(ui));
|
noteDbSchemaUpdater.update(new UpdateUIImpl(ui));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -14,7 +14,6 @@
|
|||||||
|
|
||||||
package com.google.gerrit.pgm.init;
|
package com.google.gerrit.pgm.init;
|
||||||
|
|
||||||
import com.google.gerrit.exceptions.StorageException;
|
|
||||||
import com.google.gerrit.pgm.init.api.AllUsersNameOnInitProvider;
|
import com.google.gerrit.pgm.init.api.AllUsersNameOnInitProvider;
|
||||||
import com.google.gerrit.pgm.init.api.InitFlags;
|
import com.google.gerrit.pgm.init.api.InitFlags;
|
||||||
import com.google.gerrit.server.GerritPersonIdentProvider;
|
import com.google.gerrit.server.GerritPersonIdentProvider;
|
||||||
@@ -49,7 +48,7 @@ public class ExternalIdsOnInit {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public synchronized void insert(String commitMessage, Collection<ExternalId> extIds)
|
public synchronized void insert(String commitMessage, Collection<ExternalId> extIds)
|
||||||
throws StorageException, IOException, ConfigInvalidException {
|
throws IOException, ConfigInvalidException {
|
||||||
File path = getPath();
|
File path = getPath();
|
||||||
if (path != null) {
|
if (path != null) {
|
||||||
try (Repository allUsersRepo = new FileRepository(path)) {
|
try (Repository allUsersRepo = new FileRepository(path)) {
|
||||||
|
@@ -14,7 +14,6 @@
|
|||||||
|
|
||||||
package com.google.gerrit.pgm.init.api;
|
package com.google.gerrit.pgm.init.api;
|
||||||
|
|
||||||
import com.google.gerrit.exceptions.StorageException;
|
|
||||||
import com.google.gerrit.reviewdb.client.Project;
|
import com.google.gerrit.reviewdb.client.Project;
|
||||||
import com.google.gerrit.server.extensions.events.GitReferenceUpdated;
|
import com.google.gerrit.server.extensions.events.GitReferenceUpdated;
|
||||||
import com.google.gerrit.server.git.GitRepositoryManager;
|
import com.google.gerrit.server.git.GitRepositoryManager;
|
||||||
@@ -34,7 +33,7 @@ public class SequencesOnInit {
|
|||||||
this.allUsersName = allUsersName;
|
this.allUsersName = allUsersName;
|
||||||
}
|
}
|
||||||
|
|
||||||
public int nextAccountId() throws StorageException {
|
public int nextAccountId() {
|
||||||
RepoSequence accountSeq =
|
RepoSequence accountSeq =
|
||||||
new RepoSequence(
|
new RepoSequence(
|
||||||
repoManager,
|
repoManager,
|
||||||
|
@@ -73,8 +73,7 @@ public class ApprovalCopier {
|
|||||||
}
|
}
|
||||||
|
|
||||||
Iterable<PatchSetApproval> getForPatchSet(
|
Iterable<PatchSetApproval> getForPatchSet(
|
||||||
ChangeNotes notes, PatchSet.Id psId, @Nullable RevWalk rw, @Nullable Config repoConfig)
|
ChangeNotes notes, PatchSet.Id psId, @Nullable RevWalk rw, @Nullable Config repoConfig) {
|
||||||
throws StorageException {
|
|
||||||
return getForPatchSet(notes, psId, rw, repoConfig, Collections.emptyList());
|
return getForPatchSet(notes, psId, rw, repoConfig, Collections.emptyList());
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -83,8 +82,7 @@ public class ApprovalCopier {
|
|||||||
PatchSet.Id psId,
|
PatchSet.Id psId,
|
||||||
@Nullable RevWalk rw,
|
@Nullable RevWalk rw,
|
||||||
@Nullable Config repoConfig,
|
@Nullable Config repoConfig,
|
||||||
Iterable<PatchSetApproval> dontCopy)
|
Iterable<PatchSetApproval> dontCopy) {
|
||||||
throws StorageException {
|
|
||||||
PatchSet ps = psUtil.get(notes, psId);
|
PatchSet ps = psUtil.get(notes, psId);
|
||||||
if (ps == null) {
|
if (ps == null) {
|
||||||
return Collections.emptyList();
|
return Collections.emptyList();
|
||||||
@@ -97,8 +95,7 @@ public class ApprovalCopier {
|
|||||||
PatchSet ps,
|
PatchSet ps,
|
||||||
@Nullable RevWalk rw,
|
@Nullable RevWalk rw,
|
||||||
@Nullable Config repoConfig,
|
@Nullable Config repoConfig,
|
||||||
Iterable<PatchSetApproval> dontCopy)
|
Iterable<PatchSetApproval> dontCopy) {
|
||||||
throws StorageException {
|
|
||||||
requireNonNull(ps, "ps should not be null");
|
requireNonNull(ps, "ps should not be null");
|
||||||
ChangeData cd = changeDataFactory.create(notes);
|
ChangeData cd = changeDataFactory.create(notes);
|
||||||
try {
|
try {
|
||||||
@@ -157,7 +154,7 @@ public class ApprovalCopier {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private static TreeMap<Integer, PatchSet> getPatchSets(ChangeData cd) throws StorageException {
|
private static TreeMap<Integer, PatchSet> getPatchSets(ChangeData cd) {
|
||||||
Collection<PatchSet> patchSets = cd.patchSets();
|
Collection<PatchSet> patchSets = cd.patchSets();
|
||||||
TreeMap<Integer, PatchSet> result = new TreeMap<>();
|
TreeMap<Integer, PatchSet> result = new TreeMap<>();
|
||||||
for (PatchSet ps : patchSets) {
|
for (PatchSet ps : patchSets) {
|
||||||
|
@@ -112,9 +112,8 @@ public class ApprovalsUtil {
|
|||||||
*
|
*
|
||||||
* @param notes change notes.
|
* @param notes change notes.
|
||||||
* @return reviewers for the change.
|
* @return reviewers for the change.
|
||||||
* @throws StorageException if reviewers for the change could not be read.
|
|
||||||
*/
|
*/
|
||||||
public ReviewerSet getReviewers(ChangeNotes notes) throws StorageException {
|
public ReviewerSet getReviewers(ChangeNotes notes) {
|
||||||
return notes.load().getReviewers();
|
return notes.load().getReviewers();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -123,10 +122,8 @@ public class ApprovalsUtil {
|
|||||||
*
|
*
|
||||||
* @param allApprovals all approvals to consider; must all belong to the same change.
|
* @param allApprovals all approvals to consider; must all belong to the same change.
|
||||||
* @return reviewers for the change.
|
* @return reviewers for the change.
|
||||||
* @throws StorageException if reviewers for the change could not be read.
|
|
||||||
*/
|
*/
|
||||||
public ReviewerSet getReviewers(ChangeNotes notes, Iterable<PatchSetApproval> allApprovals)
|
public ReviewerSet getReviewers(ChangeNotes notes, Iterable<PatchSetApproval> allApprovals) {
|
||||||
throws StorageException {
|
|
||||||
return notes.load().getReviewers();
|
return notes.load().getReviewers();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -135,9 +132,8 @@ public class ApprovalsUtil {
|
|||||||
*
|
*
|
||||||
* @param notes change notes.
|
* @param notes change notes.
|
||||||
* @return reviewer updates for the change.
|
* @return reviewer updates for the change.
|
||||||
* @throws StorageException if reviewer updates for the change could not be read.
|
|
||||||
*/
|
*/
|
||||||
public List<ReviewerStatusUpdate> getReviewerUpdates(ChangeNotes notes) throws StorageException {
|
public List<ReviewerStatusUpdate> getReviewerUpdates(ChangeNotes notes) {
|
||||||
return notes.load().getReviewerUpdates();
|
return notes.load().getReviewerUpdates();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -165,8 +161,7 @@ public class ApprovalsUtil {
|
|||||||
ChangeUpdate update,
|
ChangeUpdate update,
|
||||||
LabelTypes labelTypes,
|
LabelTypes labelTypes,
|
||||||
Change change,
|
Change change,
|
||||||
Iterable<Account.Id> wantReviewers)
|
Iterable<Account.Id> wantReviewers) {
|
||||||
throws StorageException {
|
|
||||||
PatchSet.Id psId = change.currentPatchSetId();
|
PatchSet.Id psId = change.currentPatchSetId();
|
||||||
Collection<Account.Id> existingReviewers;
|
Collection<Account.Id> existingReviewers;
|
||||||
existingReviewers = notes.load().getReviewers().byState(REVIEWER);
|
existingReviewers = notes.load().getReviewers().byState(REVIEWER);
|
||||||
@@ -245,11 +240,9 @@ public class ApprovalsUtil {
|
|||||||
* @param update change update.
|
* @param update change update.
|
||||||
* @param wantCCs accounts to CC.
|
* @param wantCCs accounts to CC.
|
||||||
* @return whether a change was made.
|
* @return whether a change was made.
|
||||||
* @throws StorageException
|
|
||||||
*/
|
*/
|
||||||
public Collection<Account.Id> addCcs(
|
public Collection<Account.Id> addCcs(
|
||||||
ChangeNotes notes, ChangeUpdate update, Collection<Account.Id> wantCCs)
|
ChangeNotes notes, ChangeUpdate update, Collection<Account.Id> wantCCs) {
|
||||||
throws StorageException {
|
|
||||||
return addCcs(update, wantCCs, notes.load().getReviewers());
|
return addCcs(update, wantCCs, notes.load().getReviewers());
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -273,7 +266,6 @@ public class ApprovalsUtil {
|
|||||||
* @param user user adding approvals.
|
* @param user user adding approvals.
|
||||||
* @param approvals approvals to add.
|
* @param approvals approvals to add.
|
||||||
* @throws RestApiException
|
* @throws RestApiException
|
||||||
* @throws StorageException
|
|
||||||
*/
|
*/
|
||||||
public Iterable<PatchSetApproval> addApprovalsForNewPatchSet(
|
public Iterable<PatchSetApproval> addApprovalsForNewPatchSet(
|
||||||
ChangeUpdate update,
|
ChangeUpdate update,
|
||||||
@@ -281,7 +273,7 @@ public class ApprovalsUtil {
|
|||||||
PatchSet ps,
|
PatchSet ps,
|
||||||
CurrentUser user,
|
CurrentUser user,
|
||||||
Map<String, Short> approvals)
|
Map<String, Short> approvals)
|
||||||
throws RestApiException, StorageException, PermissionBackendException {
|
throws RestApiException, PermissionBackendException {
|
||||||
Account.Id accountId = user.getAccountId();
|
Account.Id accountId = user.getAccountId();
|
||||||
checkArgument(
|
checkArgument(
|
||||||
accountId.equals(ps.getUploader()),
|
accountId.equals(ps.getUploader()),
|
||||||
@@ -331,14 +323,12 @@ public class ApprovalsUtil {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public ListMultimap<PatchSet.Id, PatchSetApproval> byChange(ChangeNotes notes)
|
public ListMultimap<PatchSet.Id, PatchSetApproval> byChange(ChangeNotes notes) {
|
||||||
throws StorageException {
|
|
||||||
return notes.load().getApprovals();
|
return notes.load().getApprovals();
|
||||||
}
|
}
|
||||||
|
|
||||||
public Iterable<PatchSetApproval> byPatchSet(
|
public Iterable<PatchSetApproval> byPatchSet(
|
||||||
ChangeNotes notes, PatchSet.Id psId, @Nullable RevWalk rw, @Nullable Config repoConfig)
|
ChangeNotes notes, PatchSet.Id psId, @Nullable RevWalk rw, @Nullable Config repoConfig) {
|
||||||
throws StorageException {
|
|
||||||
return copier.getForPatchSet(notes, psId, rw, repoConfig);
|
return copier.getForPatchSet(notes, psId, rw, repoConfig);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -347,8 +337,7 @@ public class ApprovalsUtil {
|
|||||||
PatchSet.Id psId,
|
PatchSet.Id psId,
|
||||||
Account.Id accountId,
|
Account.Id accountId,
|
||||||
@Nullable RevWalk rw,
|
@Nullable RevWalk rw,
|
||||||
@Nullable Config repoConfig)
|
@Nullable Config repoConfig) {
|
||||||
throws StorageException {
|
|
||||||
return filterApprovals(byPatchSet(notes, psId, rw, repoConfig), accountId);
|
return filterApprovals(byPatchSet(notes, psId, rw, repoConfig), accountId);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -18,7 +18,6 @@ import static com.google.common.base.Preconditions.checkState;
|
|||||||
import static java.util.Objects.requireNonNull;
|
import static java.util.Objects.requireNonNull;
|
||||||
|
|
||||||
import com.google.gerrit.common.Nullable;
|
import com.google.gerrit.common.Nullable;
|
||||||
import com.google.gerrit.exceptions.StorageException;
|
|
||||||
import com.google.gerrit.extensions.common.ChangeMessageInfo;
|
import com.google.gerrit.extensions.common.ChangeMessageInfo;
|
||||||
import com.google.gerrit.reviewdb.client.Account;
|
import com.google.gerrit.reviewdb.client.Account;
|
||||||
import com.google.gerrit.reviewdb.client.ChangeMessage;
|
import com.google.gerrit.reviewdb.client.ChangeMessage;
|
||||||
@@ -87,7 +86,7 @@ public class ChangeMessagesUtil {
|
|||||||
return workInProgress ? TAG_UPLOADED_WIP_PATCH_SET : TAG_UPLOADED_PATCH_SET;
|
return workInProgress ? TAG_UPLOADED_WIP_PATCH_SET : TAG_UPLOADED_PATCH_SET;
|
||||||
}
|
}
|
||||||
|
|
||||||
public List<ChangeMessage> byChange(ChangeNotes notes) throws StorageException {
|
public List<ChangeMessage> byChange(ChangeNotes notes) {
|
||||||
return notes.load().getChangeMessages();
|
return notes.load().getChangeMessages();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -124,7 +124,7 @@ public class CommentsUtil {
|
|||||||
String message,
|
String message,
|
||||||
@Nullable Boolean unresolved,
|
@Nullable Boolean unresolved,
|
||||||
@Nullable String parentUuid)
|
@Nullable String parentUuid)
|
||||||
throws StorageException, UnprocessableEntityException {
|
throws UnprocessableEntityException {
|
||||||
if (unresolved == null) {
|
if (unresolved == null) {
|
||||||
if (parentUuid == null) {
|
if (parentUuid == null) {
|
||||||
// Default to false if comment is not descended from another.
|
// Default to false if comment is not descended from another.
|
||||||
@@ -175,29 +175,27 @@ public class CommentsUtil {
|
|||||||
return c;
|
return c;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Optional<Comment> getPublished(ChangeNotes notes, Comment.Key key)
|
public Optional<Comment> getPublished(ChangeNotes notes, Comment.Key key) {
|
||||||
throws StorageException {
|
|
||||||
return publishedByChange(notes).stream().filter(c -> key.equals(c.key)).findFirst();
|
return publishedByChange(notes).stream().filter(c -> key.equals(c.key)).findFirst();
|
||||||
}
|
}
|
||||||
|
|
||||||
public Optional<Comment> getDraft(ChangeNotes notes, IdentifiedUser user, Comment.Key key)
|
public Optional<Comment> getDraft(ChangeNotes notes, IdentifiedUser user, Comment.Key key) {
|
||||||
throws StorageException {
|
|
||||||
return draftByChangeAuthor(notes, user.getAccountId()).stream()
|
return draftByChangeAuthor(notes, user.getAccountId()).stream()
|
||||||
.filter(c -> key.equals(c.key))
|
.filter(c -> key.equals(c.key))
|
||||||
.findFirst();
|
.findFirst();
|
||||||
}
|
}
|
||||||
|
|
||||||
public List<Comment> publishedByChange(ChangeNotes notes) throws StorageException {
|
public List<Comment> publishedByChange(ChangeNotes notes) {
|
||||||
notes.load();
|
notes.load();
|
||||||
return sort(Lists.newArrayList(notes.getComments().values()));
|
return sort(Lists.newArrayList(notes.getComments().values()));
|
||||||
}
|
}
|
||||||
|
|
||||||
public List<RobotComment> robotCommentsByChange(ChangeNotes notes) throws StorageException {
|
public List<RobotComment> robotCommentsByChange(ChangeNotes notes) {
|
||||||
notes.load();
|
notes.load();
|
||||||
return sort(Lists.newArrayList(notes.getRobotComments().values()));
|
return sort(Lists.newArrayList(notes.getRobotComments().values()));
|
||||||
}
|
}
|
||||||
|
|
||||||
public List<Comment> draftByChange(ChangeNotes notes) throws StorageException {
|
public List<Comment> draftByChange(ChangeNotes notes) {
|
||||||
List<Comment> comments = new ArrayList<>();
|
List<Comment> comments = new ArrayList<>();
|
||||||
for (Ref ref : getDraftRefs(notes.getChangeId())) {
|
for (Ref ref : getDraftRefs(notes.getChangeId())) {
|
||||||
Account.Id account = Account.Id.fromRefSuffix(ref.getName());
|
Account.Id account = Account.Id.fromRefSuffix(ref.getName());
|
||||||
@@ -208,7 +206,7 @@ public class CommentsUtil {
|
|||||||
return sort(comments);
|
return sort(comments);
|
||||||
}
|
}
|
||||||
|
|
||||||
public List<Comment> byPatchSet(ChangeNotes notes, PatchSet.Id psId) throws StorageException {
|
public List<Comment> byPatchSet(ChangeNotes notes, PatchSet.Id psId) {
|
||||||
List<Comment> comments = new ArrayList<>();
|
List<Comment> comments = new ArrayList<>();
|
||||||
comments.addAll(publishedByPatchSet(notes, psId));
|
comments.addAll(publishedByPatchSet(notes, psId));
|
||||||
|
|
||||||
@@ -221,19 +219,16 @@ public class CommentsUtil {
|
|||||||
return sort(comments);
|
return sort(comments);
|
||||||
}
|
}
|
||||||
|
|
||||||
public List<Comment> publishedByChangeFile(ChangeNotes notes, String file)
|
public List<Comment> publishedByChangeFile(ChangeNotes notes, String file) {
|
||||||
throws StorageException {
|
|
||||||
return commentsOnFile(notes.load().getComments().values(), file);
|
return commentsOnFile(notes.load().getComments().values(), file);
|
||||||
}
|
}
|
||||||
|
|
||||||
public List<Comment> publishedByPatchSet(ChangeNotes notes, PatchSet.Id psId)
|
public List<Comment> publishedByPatchSet(ChangeNotes notes, PatchSet.Id psId) {
|
||||||
throws StorageException {
|
|
||||||
return removeCommentsOnAncestorOfCommitMessage(
|
return removeCommentsOnAncestorOfCommitMessage(
|
||||||
commentsOnPatchSet(notes.load().getComments().values(), psId));
|
commentsOnPatchSet(notes.load().getComments().values(), psId));
|
||||||
}
|
}
|
||||||
|
|
||||||
public List<RobotComment> robotCommentsByPatchSet(ChangeNotes notes, PatchSet.Id psId)
|
public List<RobotComment> robotCommentsByPatchSet(ChangeNotes notes, PatchSet.Id psId) {
|
||||||
throws StorageException {
|
|
||||||
return commentsOnPatchSet(notes.load().getRobotComments().values(), psId);
|
return commentsOnPatchSet(notes.load().getRobotComments().values(), psId);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -250,18 +245,16 @@ public class CommentsUtil {
|
|||||||
.collect(toList());
|
.collect(toList());
|
||||||
}
|
}
|
||||||
|
|
||||||
public List<Comment> draftByPatchSetAuthor(PatchSet.Id psId, Account.Id author, ChangeNotes notes)
|
public List<Comment> draftByPatchSetAuthor(
|
||||||
throws StorageException {
|
PatchSet.Id psId, Account.Id author, ChangeNotes notes) {
|
||||||
return commentsOnPatchSet(notes.load().getDraftComments(author).values(), psId);
|
return commentsOnPatchSet(notes.load().getDraftComments(author).values(), psId);
|
||||||
}
|
}
|
||||||
|
|
||||||
public List<Comment> draftByChangeFileAuthor(ChangeNotes notes, String file, Account.Id author)
|
public List<Comment> draftByChangeFileAuthor(ChangeNotes notes, String file, Account.Id author) {
|
||||||
throws StorageException {
|
|
||||||
return commentsOnFile(notes.load().getDraftComments(author).values(), file);
|
return commentsOnFile(notes.load().getDraftComments(author).values(), file);
|
||||||
}
|
}
|
||||||
|
|
||||||
public List<Comment> draftByChangeAuthor(ChangeNotes notes, Account.Id author)
|
public List<Comment> draftByChangeAuthor(ChangeNotes notes, Account.Id author) {
|
||||||
throws StorageException {
|
|
||||||
List<Comment> comments = new ArrayList<>();
|
List<Comment> comments = new ArrayList<>();
|
||||||
comments.addAll(notes.getDraftComments(author).values());
|
comments.addAll(notes.getDraftComments(author).values());
|
||||||
return sort(comments);
|
return sort(comments);
|
||||||
@@ -345,7 +338,7 @@ public class CommentsUtil {
|
|||||||
* @param changeId change ID.
|
* @param changeId change ID.
|
||||||
* @return raw refs from All-Users repo.
|
* @return raw refs from All-Users repo.
|
||||||
*/
|
*/
|
||||||
public Collection<Ref> getDraftRefs(Change.Id changeId) throws StorageException {
|
public Collection<Ref> getDraftRefs(Change.Id changeId) {
|
||||||
try (Repository repo = repoManager.openRepository(allUsers)) {
|
try (Repository repo = repoManager.openRepository(allUsers)) {
|
||||||
return getDraftRefs(repo, changeId);
|
return getDraftRefs(repo, changeId);
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
|
@@ -22,7 +22,6 @@ import com.google.common.collect.ImmutableMap;
|
|||||||
import com.google.common.collect.Maps;
|
import com.google.common.collect.Maps;
|
||||||
import com.google.gerrit.common.data.LabelFunction;
|
import com.google.gerrit.common.data.LabelFunction;
|
||||||
import com.google.gerrit.common.data.LabelType;
|
import com.google.gerrit.common.data.LabelType;
|
||||||
import com.google.gerrit.exceptions.StorageException;
|
|
||||||
import com.google.gerrit.extensions.restapi.ResourceConflictException;
|
import com.google.gerrit.extensions.restapi.ResourceConflictException;
|
||||||
import com.google.gerrit.reviewdb.client.Change;
|
import com.google.gerrit.reviewdb.client.Change;
|
||||||
import com.google.gerrit.reviewdb.client.PatchSet;
|
import com.google.gerrit.reviewdb.client.PatchSet;
|
||||||
@@ -63,25 +62,24 @@ public class PatchSetUtil {
|
|||||||
this.repoManager = repoManager;
|
this.repoManager = repoManager;
|
||||||
}
|
}
|
||||||
|
|
||||||
public PatchSet current(ChangeNotes notes) throws StorageException {
|
public PatchSet current(ChangeNotes notes) {
|
||||||
return get(notes, notes.getChange().currentPatchSetId());
|
return get(notes, notes.getChange().currentPatchSetId());
|
||||||
}
|
}
|
||||||
|
|
||||||
public PatchSet get(ChangeNotes notes, PatchSet.Id psId) throws StorageException {
|
public PatchSet get(ChangeNotes notes, PatchSet.Id psId) {
|
||||||
return notes.load().getPatchSets().get(psId);
|
return notes.load().getPatchSets().get(psId);
|
||||||
}
|
}
|
||||||
|
|
||||||
public ImmutableCollection<PatchSet> byChange(ChangeNotes notes) throws StorageException {
|
public ImmutableCollection<PatchSet> byChange(ChangeNotes notes) {
|
||||||
return notes.load().getPatchSets().values();
|
return notes.load().getPatchSets().values();
|
||||||
}
|
}
|
||||||
|
|
||||||
public ImmutableMap<PatchSet.Id, PatchSet> byChangeAsMap(ChangeNotes notes)
|
public ImmutableMap<PatchSet.Id, PatchSet> byChangeAsMap(ChangeNotes notes) {
|
||||||
throws StorageException {
|
|
||||||
return notes.load().getPatchSets();
|
return notes.load().getPatchSets();
|
||||||
}
|
}
|
||||||
|
|
||||||
public ImmutableMap<PatchSet.Id, PatchSet> getAsMap(
|
public ImmutableMap<PatchSet.Id, PatchSet> getAsMap(
|
||||||
ChangeNotes notes, Set<PatchSet.Id> patchSetIds) throws StorageException {
|
ChangeNotes notes, Set<PatchSet.Id> patchSetIds) {
|
||||||
return ImmutableMap.copyOf(Maps.filterKeys(notes.load().getPatchSets(), patchSetIds::contains));
|
return ImmutableMap.copyOf(Maps.filterKeys(notes.load().getPatchSets(), patchSetIds::contains));
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -136,7 +134,7 @@ public class PatchSetUtil {
|
|||||||
|
|
||||||
/** Check if the current patch set of the change is locked. */
|
/** Check if the current patch set of the change is locked. */
|
||||||
public void checkPatchSetNotLocked(ChangeNotes notes)
|
public void checkPatchSetNotLocked(ChangeNotes notes)
|
||||||
throws StorageException, IOException, ResourceConflictException {
|
throws IOException, ResourceConflictException {
|
||||||
if (isPatchSetLocked(notes)) {
|
if (isPatchSetLocked(notes)) {
|
||||||
throw new ResourceConflictException(
|
throw new ResourceConflictException(
|
||||||
String.format("The current patch set of change %s is locked", notes.getChangeId()));
|
String.format("The current patch set of change %s is locked", notes.getChangeId()));
|
||||||
@@ -144,7 +142,7 @@ public class PatchSetUtil {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/** Is the current patch set locked against state changes? */
|
/** Is the current patch set locked against state changes? */
|
||||||
public boolean isPatchSetLocked(ChangeNotes notes) throws StorageException, IOException {
|
public boolean isPatchSetLocked(ChangeNotes notes) throws IOException {
|
||||||
Change change = notes.getChange();
|
Change change = notes.getChange();
|
||||||
if (change.isMerged()) {
|
if (change.isMerged()) {
|
||||||
return false;
|
return false;
|
||||||
|
@@ -46,8 +46,7 @@ public class PublishCommentUtil {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void publish(
|
public void publish(
|
||||||
ChangeContext ctx, PatchSet.Id psId, Collection<Comment> drafts, @Nullable String tag)
|
ChangeContext ctx, PatchSet.Id psId, Collection<Comment> drafts, @Nullable String tag) {
|
||||||
throws StorageException {
|
|
||||||
ChangeNotes notes = ctx.getNotes();
|
ChangeNotes notes = ctx.getNotes();
|
||||||
checkArgument(notes != null);
|
checkArgument(notes != null);
|
||||||
if (drafts.isEmpty()) {
|
if (drafts.isEmpty()) {
|
||||||
|
@@ -186,8 +186,7 @@ public class StarredChangesUtil {
|
|||||||
this.queryProvider = queryProvider;
|
this.queryProvider = queryProvider;
|
||||||
}
|
}
|
||||||
|
|
||||||
public ImmutableSortedSet<String> getLabels(Account.Id accountId, Change.Id changeId)
|
public ImmutableSortedSet<String> getLabels(Account.Id accountId, Change.Id changeId) {
|
||||||
throws StorageException {
|
|
||||||
try (Repository repo = repoManager.openRepository(allUsers)) {
|
try (Repository repo = repoManager.openRepository(allUsers)) {
|
||||||
return readLabels(repo, RefNames.refsStarredChanges(changeId, accountId)).labels();
|
return readLabels(repo, RefNames.refsStarredChanges(changeId, accountId)).labels();
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
@@ -205,7 +204,7 @@ public class StarredChangesUtil {
|
|||||||
Change.Id changeId,
|
Change.Id changeId,
|
||||||
Set<String> labelsToAdd,
|
Set<String> labelsToAdd,
|
||||||
Set<String> labelsToRemove)
|
Set<String> labelsToRemove)
|
||||||
throws StorageException, IllegalLabelException {
|
throws IllegalLabelException {
|
||||||
try (Repository repo = repoManager.openRepository(allUsers)) {
|
try (Repository repo = repoManager.openRepository(allUsers)) {
|
||||||
String refName = RefNames.refsStarredChanges(changeId, accountId);
|
String refName = RefNames.refsStarredChanges(changeId, accountId);
|
||||||
StarRef old = readLabels(repo, refName);
|
StarRef old = readLabels(repo, refName);
|
||||||
@@ -234,7 +233,7 @@ public class StarredChangesUtil {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void unstarAll(Project.NameKey project, Change.Id changeId) throws StorageException {
|
public void unstarAll(Project.NameKey project, Change.Id changeId) {
|
||||||
try (Repository repo = repoManager.openRepository(allUsers);
|
try (Repository repo = repoManager.openRepository(allUsers);
|
||||||
RevWalk rw = new RevWalk(repo)) {
|
RevWalk rw = new RevWalk(repo)) {
|
||||||
BatchRefUpdate batchUpdate = repo.getRefDatabase().newBatchUpdate();
|
BatchRefUpdate batchUpdate = repo.getRefDatabase().newBatchUpdate();
|
||||||
@@ -261,7 +260,7 @@ public class StarredChangesUtil {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public ImmutableMap<Account.Id, StarRef> byChange(Change.Id changeId) throws StorageException {
|
public ImmutableMap<Account.Id, StarRef> byChange(Change.Id changeId) {
|
||||||
try (Repository repo = repoManager.openRepository(allUsers)) {
|
try (Repository repo = repoManager.openRepository(allUsers)) {
|
||||||
ImmutableMap.Builder<Account.Id, StarRef> builder = ImmutableMap.builder();
|
ImmutableMap.Builder<Account.Id, StarRef> builder = ImmutableMap.builder();
|
||||||
for (String refPart : getRefNames(repo, RefNames.refsStarredChangesPrefix(changeId))) {
|
for (String refPart : getRefNames(repo, RefNames.refsStarredChangesPrefix(changeId))) {
|
||||||
@@ -279,8 +278,7 @@ public class StarredChangesUtil {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public ImmutableListMultimap<Account.Id, String> byChangeFromIndex(Change.Id changeId)
|
public ImmutableListMultimap<Account.Id, String> byChangeFromIndex(Change.Id changeId) {
|
||||||
throws StorageException {
|
|
||||||
List<ChangeData> changeData =
|
List<ChangeData> changeData =
|
||||||
queryProvider
|
queryProvider
|
||||||
.get()
|
.get()
|
||||||
@@ -311,7 +309,7 @@ public class StarredChangesUtil {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void ignore(ChangeResource rsrc) throws StorageException, IllegalLabelException {
|
public void ignore(ChangeResource rsrc) throws IllegalLabelException {
|
||||||
star(
|
star(
|
||||||
rsrc.getUser().asIdentifiedUser().getAccountId(),
|
rsrc.getUser().asIdentifiedUser().getAccountId(),
|
||||||
rsrc.getProject(),
|
rsrc.getProject(),
|
||||||
@@ -320,7 +318,7 @@ public class StarredChangesUtil {
|
|||||||
ImmutableSet.of());
|
ImmutableSet.of());
|
||||||
}
|
}
|
||||||
|
|
||||||
public void unignore(ChangeResource rsrc) throws StorageException, IllegalLabelException {
|
public void unignore(ChangeResource rsrc) throws IllegalLabelException {
|
||||||
star(
|
star(
|
||||||
rsrc.getUser().asIdentifiedUser().getAccountId(),
|
rsrc.getUser().asIdentifiedUser().getAccountId(),
|
||||||
rsrc.getProject(),
|
rsrc.getProject(),
|
||||||
@@ -329,11 +327,11 @@ public class StarredChangesUtil {
|
|||||||
ImmutableSet.of(IGNORE_LABEL));
|
ImmutableSet.of(IGNORE_LABEL));
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean isIgnoredBy(Change.Id changeId, Account.Id accountId) throws StorageException {
|
public boolean isIgnoredBy(Change.Id changeId, Account.Id accountId) {
|
||||||
return getLabels(accountId, changeId).contains(IGNORE_LABEL);
|
return getLabels(accountId, changeId).contains(IGNORE_LABEL);
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean isIgnored(ChangeResource rsrc) throws StorageException {
|
public boolean isIgnored(ChangeResource rsrc) {
|
||||||
return isIgnoredBy(rsrc.getChange().getId(), rsrc.getUser().asIdentifiedUser().getAccountId());
|
return isIgnoredBy(rsrc.getChange().getId(), rsrc.getUser().asIdentifiedUser().getAccountId());
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -353,7 +351,7 @@ public class StarredChangesUtil {
|
|||||||
return UNREVIEWED_LABEL + "/" + ps;
|
return UNREVIEWED_LABEL + "/" + ps;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void markAsReviewed(ChangeResource rsrc) throws StorageException, IllegalLabelException {
|
public void markAsReviewed(ChangeResource rsrc) throws IllegalLabelException {
|
||||||
star(
|
star(
|
||||||
rsrc.getUser().asIdentifiedUser().getAccountId(),
|
rsrc.getUser().asIdentifiedUser().getAccountId(),
|
||||||
rsrc.getProject(),
|
rsrc.getProject(),
|
||||||
@@ -362,7 +360,7 @@ public class StarredChangesUtil {
|
|||||||
ImmutableSet.of(getUnreviewedLabel(rsrc.getChange())));
|
ImmutableSet.of(getUnreviewedLabel(rsrc.getChange())));
|
||||||
}
|
}
|
||||||
|
|
||||||
public void markAsUnreviewed(ChangeResource rsrc) throws StorageException, IllegalLabelException {
|
public void markAsUnreviewed(ChangeResource rsrc) throws IllegalLabelException {
|
||||||
star(
|
star(
|
||||||
rsrc.getUser().asIdentifiedUser().getAccountId(),
|
rsrc.getUser().asIdentifiedUser().getAccountId(),
|
||||||
rsrc.getProject(),
|
rsrc.getProject(),
|
||||||
@@ -444,7 +442,7 @@ public class StarredChangesUtil {
|
|||||||
|
|
||||||
private void updateLabels(
|
private void updateLabels(
|
||||||
Repository repo, String refName, ObjectId oldObjectId, Collection<String> labels)
|
Repository repo, String refName, ObjectId oldObjectId, Collection<String> labels)
|
||||||
throws IOException, StorageException, InvalidLabelsException {
|
throws IOException, InvalidLabelsException {
|
||||||
try (TraceTimer traceTimer =
|
try (TraceTimer traceTimer =
|
||||||
TraceContext.newTimer("Update star labels in %s (labels=%s)", refName, labels);
|
TraceContext.newTimer("Update star labels in %s (labels=%s)", refName, labels);
|
||||||
RevWalk rw = new RevWalk(repo)) {
|
RevWalk rw = new RevWalk(repo)) {
|
||||||
@@ -477,8 +475,7 @@ public class StarredChangesUtil {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void deleteRef(Repository repo, String refName, ObjectId oldObjectId)
|
private void deleteRef(Repository repo, String refName, ObjectId oldObjectId) throws IOException {
|
||||||
throws IOException, StorageException {
|
|
||||||
if (ObjectId.zeroId().equals(oldObjectId)) {
|
if (ObjectId.zeroId().equals(oldObjectId)) {
|
||||||
// ref doesn't exist
|
// ref doesn't exist
|
||||||
return;
|
return;
|
||||||
|
@@ -214,7 +214,7 @@ public class AccountManager {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private void update(AuthRequest who, ExternalId extId)
|
private void update(AuthRequest who, ExternalId extId)
|
||||||
throws StorageException, IOException, ConfigInvalidException, AccountException {
|
throws IOException, ConfigInvalidException, AccountException {
|
||||||
IdentifiedUser user = userFactory.create(extId.accountId());
|
IdentifiedUser user = userFactory.create(extId.accountId());
|
||||||
List<Consumer<InternalAccountUpdate.Builder>> accountUpdates = new ArrayList<>();
|
List<Consumer<InternalAccountUpdate.Builder>> accountUpdates = new ArrayList<>();
|
||||||
|
|
||||||
@@ -271,7 +271,7 @@ public class AccountManager {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private AuthResult create(AuthRequest who)
|
private AuthResult create(AuthRequest who)
|
||||||
throws StorageException, AccountException, IOException, ConfigInvalidException {
|
throws AccountException, IOException, ConfigInvalidException {
|
||||||
Account.Id newId = new Account.Id(sequences.nextAccountId());
|
Account.Id newId = new Account.Id(sequences.nextAccountId());
|
||||||
logger.atFine().log("Assigning new Id %s to account", newId);
|
logger.atFine().log("Assigning new Id %s to account", newId);
|
||||||
|
|
||||||
@@ -375,7 +375,7 @@ public class AccountManager {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private void addGroupMember(AccountGroup.UUID groupUuid, IdentifiedUser user)
|
private void addGroupMember(AccountGroup.UUID groupUuid, IdentifiedUser user)
|
||||||
throws StorageException, IOException, ConfigInvalidException, AccountException {
|
throws IOException, ConfigInvalidException, AccountException {
|
||||||
// The user initiated this request by logging in. -> Attribute all modifications to that user.
|
// The user initiated this request by logging in. -> Attribute all modifications to that user.
|
||||||
GroupsUpdate groupsUpdate = groupsUpdateFactory.create(user);
|
GroupsUpdate groupsUpdate = groupsUpdateFactory.create(user);
|
||||||
InternalGroupUpdate groupUpdate =
|
InternalGroupUpdate groupUpdate =
|
||||||
@@ -400,7 +400,7 @@ public class AccountManager {
|
|||||||
* this time.
|
* this time.
|
||||||
*/
|
*/
|
||||||
public AuthResult link(Account.Id to, AuthRequest who)
|
public AuthResult link(Account.Id to, AuthRequest who)
|
||||||
throws AccountException, StorageException, IOException, ConfigInvalidException {
|
throws AccountException, IOException, ConfigInvalidException {
|
||||||
Optional<ExternalId> optionalExtId = externalIds.get(who.getExternalIdKey());
|
Optional<ExternalId> optionalExtId = externalIds.get(who.getExternalIdKey());
|
||||||
if (optionalExtId.isPresent()) {
|
if (optionalExtId.isPresent()) {
|
||||||
ExternalId extId = optionalExtId.get();
|
ExternalId extId = optionalExtId.get();
|
||||||
@@ -437,12 +437,11 @@ public class AccountManager {
|
|||||||
* @param to account to link the identity onto.
|
* @param to account to link the identity onto.
|
||||||
* @param who the additional identity.
|
* @param who the additional identity.
|
||||||
* @return the result of linking the identity to the user.
|
* @return the result of linking the identity to the user.
|
||||||
* @throws StorageException
|
|
||||||
* @throws AccountException the identity belongs to a different account, or it cannot be linked at
|
* @throws AccountException the identity belongs to a different account, or it cannot be linked at
|
||||||
* this time.
|
* this time.
|
||||||
*/
|
*/
|
||||||
public AuthResult updateLink(Account.Id to, AuthRequest who)
|
public AuthResult updateLink(Account.Id to, AuthRequest who)
|
||||||
throws StorageException, AccountException, IOException, ConfigInvalidException {
|
throws AccountException, IOException, ConfigInvalidException {
|
||||||
accountsUpdateProvider
|
accountsUpdateProvider
|
||||||
.get()
|
.get()
|
||||||
.update(
|
.update(
|
||||||
@@ -474,7 +473,7 @@ public class AccountManager {
|
|||||||
* found
|
* found
|
||||||
*/
|
*/
|
||||||
public void unlink(Account.Id from, ExternalId.Key extIdKey)
|
public void unlink(Account.Id from, ExternalId.Key extIdKey)
|
||||||
throws AccountException, StorageException, IOException, ConfigInvalidException {
|
throws AccountException, IOException, ConfigInvalidException {
|
||||||
unlink(from, ImmutableList.of(extIdKey));
|
unlink(from, ImmutableList.of(extIdKey));
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -487,7 +486,7 @@ public class AccountManager {
|
|||||||
* identity was not found
|
* identity was not found
|
||||||
*/
|
*/
|
||||||
public void unlink(Account.Id from, Collection<ExternalId.Key> extIdKeys)
|
public void unlink(Account.Id from, Collection<ExternalId.Key> extIdKeys)
|
||||||
throws AccountException, StorageException, IOException, ConfigInvalidException {
|
throws AccountException, IOException, ConfigInvalidException {
|
||||||
if (extIdKeys.isEmpty()) {
|
if (extIdKeys.isEmpty()) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@@ -26,7 +26,6 @@ import com.google.common.base.Suppliers;
|
|||||||
import com.google.common.collect.ImmutableList;
|
import com.google.common.collect.ImmutableList;
|
||||||
import com.google.common.collect.ImmutableSet;
|
import com.google.common.collect.ImmutableSet;
|
||||||
import com.google.common.collect.Streams;
|
import com.google.common.collect.Streams;
|
||||||
import com.google.gerrit.exceptions.StorageException;
|
|
||||||
import com.google.gerrit.extensions.restapi.UnprocessableEntityException;
|
import com.google.gerrit.extensions.restapi.UnprocessableEntityException;
|
||||||
import com.google.gerrit.index.Schema;
|
import com.google.gerrit.index.Schema;
|
||||||
import com.google.gerrit.reviewdb.client.Account;
|
import com.google.gerrit.reviewdb.client.Account;
|
||||||
@@ -216,15 +215,14 @@ public class AccountResolver {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
Optional<I> tryParse(String input) throws IOException, StorageException;
|
Optional<I> tryParse(String input) throws IOException;
|
||||||
|
|
||||||
Stream<AccountState> search(I input)
|
Stream<AccountState> search(I input) throws IOException, ConfigInvalidException;
|
||||||
throws StorageException, IOException, ConfigInvalidException;
|
|
||||||
|
|
||||||
boolean shortCircuitIfNoResults();
|
boolean shortCircuitIfNoResults();
|
||||||
|
|
||||||
default Optional<Stream<AccountState>> trySearch(String input)
|
default Optional<Stream<AccountState>> trySearch(String input)
|
||||||
throws StorageException, IOException, ConfigInvalidException {
|
throws IOException, ConfigInvalidException {
|
||||||
Optional<I> parsed = tryParse(input);
|
Optional<I> parsed = tryParse(input);
|
||||||
return parsed.isPresent() ? Optional.of(search(parsed.get())) : Optional.empty();
|
return parsed.isPresent() ? Optional.of(search(parsed.get())) : Optional.empty();
|
||||||
}
|
}
|
||||||
@@ -336,7 +334,7 @@ public class AccountResolver {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Stream<AccountState> search(String nameOrEmail) throws StorageException, IOException {
|
public Stream<AccountState> search(String nameOrEmail) throws IOException {
|
||||||
// TODO(dborowitz): This would probably work as a Searcher<Address>
|
// TODO(dborowitz): This would probably work as a Searcher<Address>
|
||||||
int lt = nameOrEmail.indexOf('<');
|
int lt = nameOrEmail.indexOf('<');
|
||||||
int gt = nameOrEmail.indexOf('>');
|
int gt = nameOrEmail.indexOf('>');
|
||||||
@@ -369,7 +367,7 @@ public class AccountResolver {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Stream<AccountState> search(String input) throws StorageException, IOException {
|
public Stream<AccountState> search(String input) throws IOException {
|
||||||
return toAccountStates(emails.getAccountFor(input));
|
return toAccountStates(emails.getAccountFor(input));
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -398,7 +396,7 @@ public class AccountResolver {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Optional<AccountState> tryParse(String input) throws StorageException {
|
public Optional<AccountState> tryParse(String input) {
|
||||||
List<AccountState> results =
|
List<AccountState> results =
|
||||||
accountQueryProvider.get().enforceVisibility(true).byFullName(input);
|
accountQueryProvider.get().enforceVisibility(true).byFullName(input);
|
||||||
return results.size() == 1 ? Optional.of(results.get(0)) : Optional.empty();
|
return results.size() == 1 ? Optional.of(results.get(0)) : Optional.empty();
|
||||||
@@ -427,7 +425,7 @@ public class AccountResolver {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Stream<AccountState> search(String input) throws StorageException {
|
public Stream<AccountState> search(String input) {
|
||||||
// At this point we have no clue. Just perform a whole bunch of suggestions and pray we come
|
// At this point we have no clue. Just perform a whole bunch of suggestions and pray we come
|
||||||
// up with a reasonable result list.
|
// up with a reasonable result list.
|
||||||
// TODO(dborowitz): This doesn't match the documentation; consider whether it's possible to be
|
// TODO(dborowitz): This doesn't match the documentation; consider whether it's possible to be
|
||||||
@@ -514,11 +512,10 @@ public class AccountResolver {
|
|||||||
*
|
*
|
||||||
* @param input input string.
|
* @param input input string.
|
||||||
* @return a result describing matching accounts. Never null even if the result set is empty.
|
* @return a result describing matching accounts. Never null even if the result set is empty.
|
||||||
* @throws StorageException if an error occurs.
|
|
||||||
* @throws ConfigInvalidException if an error occurs.
|
* @throws ConfigInvalidException if an error occurs.
|
||||||
* @throws IOException if an error occurs.
|
* @throws IOException if an error occurs.
|
||||||
*/
|
*/
|
||||||
public Result resolve(String input) throws StorageException, ConfigInvalidException, IOException {
|
public Result resolve(String input) throws ConfigInvalidException, IOException {
|
||||||
return searchImpl(input, searchers, visibilitySupplier());
|
return searchImpl(input, searchers, visibilitySupplier());
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -540,15 +537,13 @@ public class AccountResolver {
|
|||||||
*
|
*
|
||||||
* @param input input string.
|
* @param input input string.
|
||||||
* @return a result describing matching accounts. Never null even if the result set is empty.
|
* @return a result describing matching accounts. Never null even if the result set is empty.
|
||||||
* @throws StorageException if an error occurs.
|
|
||||||
* @throws ConfigInvalidException if an error occurs.
|
* @throws ConfigInvalidException if an error occurs.
|
||||||
* @throws IOException if an error occurs.
|
* @throws IOException if an error occurs.
|
||||||
* @deprecated for use only by MailUtil for parsing commit footers; that class needs to be
|
* @deprecated for use only by MailUtil for parsing commit footers; that class needs to be
|
||||||
* reevaluated.
|
* reevaluated.
|
||||||
*/
|
*/
|
||||||
@Deprecated
|
@Deprecated
|
||||||
public Result resolveByNameOrEmail(String input)
|
public Result resolveByNameOrEmail(String input) throws ConfigInvalidException, IOException {
|
||||||
throws StorageException, ConfigInvalidException, IOException {
|
|
||||||
return searchImpl(input, nameOrEmailSearchers, visibilitySupplier());
|
return searchImpl(input, nameOrEmailSearchers, visibilitySupplier());
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -561,7 +556,7 @@ public class AccountResolver {
|
|||||||
String input,
|
String input,
|
||||||
ImmutableList<Searcher<?>> searchers,
|
ImmutableList<Searcher<?>> searchers,
|
||||||
Supplier<Predicate<AccountState>> visibilitySupplier)
|
Supplier<Predicate<AccountState>> visibilitySupplier)
|
||||||
throws StorageException, ConfigInvalidException, IOException {
|
throws ConfigInvalidException, IOException {
|
||||||
visibilitySupplier = Suppliers.memoize(visibilitySupplier::get);
|
visibilitySupplier = Suppliers.memoize(visibilitySupplier::get);
|
||||||
List<AccountState> inactive = new ArrayList<>();
|
List<AccountState> inactive = new ArrayList<>();
|
||||||
|
|
||||||
|
@@ -295,12 +295,11 @@ public class AccountsUpdate {
|
|||||||
* @return the newly created account
|
* @return the newly created account
|
||||||
* @throws DuplicateKeyException if the account already exists
|
* @throws DuplicateKeyException if the account already exists
|
||||||
* @throws IOException if creating the user branch fails due to an IO error
|
* @throws IOException if creating the user branch fails due to an IO error
|
||||||
* @throws StorageException if creating the user branch fails
|
|
||||||
* @throws ConfigInvalidException if any of the account fields has an invalid value
|
* @throws ConfigInvalidException if any of the account fields has an invalid value
|
||||||
*/
|
*/
|
||||||
public AccountState insert(
|
public AccountState insert(
|
||||||
String message, Account.Id accountId, Consumer<InternalAccountUpdate.Builder> init)
|
String message, Account.Id accountId, Consumer<InternalAccountUpdate.Builder> init)
|
||||||
throws StorageException, IOException, ConfigInvalidException {
|
throws IOException, ConfigInvalidException {
|
||||||
return insert(message, accountId, AccountUpdater.fromConsumer(init));
|
return insert(message, accountId, AccountUpdater.fromConsumer(init));
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -313,11 +312,10 @@ public class AccountsUpdate {
|
|||||||
* @return the newly created account
|
* @return the newly created account
|
||||||
* @throws DuplicateKeyException if the account already exists
|
* @throws DuplicateKeyException if the account already exists
|
||||||
* @throws IOException if creating the user branch fails due to an IO error
|
* @throws IOException if creating the user branch fails due to an IO error
|
||||||
* @throws StorageException if creating the user branch fails
|
|
||||||
* @throws ConfigInvalidException if any of the account fields has an invalid value
|
* @throws ConfigInvalidException if any of the account fields has an invalid value
|
||||||
*/
|
*/
|
||||||
public AccountState insert(String message, Account.Id accountId, AccountUpdater updater)
|
public AccountState insert(String message, Account.Id accountId, AccountUpdater updater)
|
||||||
throws StorageException, IOException, ConfigInvalidException {
|
throws IOException, ConfigInvalidException {
|
||||||
return updateAccount(
|
return updateAccount(
|
||||||
r -> {
|
r -> {
|
||||||
AccountConfig accountConfig = read(r, accountId);
|
AccountConfig accountConfig = read(r, accountId);
|
||||||
@@ -351,12 +349,11 @@ public class AccountsUpdate {
|
|||||||
* @throws IOException if updating the user branch fails due to an IO error
|
* @throws IOException if updating the user branch fails due to an IO error
|
||||||
* @throws LockFailureException if updating the user branch still fails due to concurrent updates
|
* @throws LockFailureException if updating the user branch still fails due to concurrent updates
|
||||||
* after the retry timeout exceeded
|
* after the retry timeout exceeded
|
||||||
* @throws StorageException if updating the user branch fails
|
|
||||||
* @throws ConfigInvalidException if any of the account fields has an invalid value
|
* @throws ConfigInvalidException if any of the account fields has an invalid value
|
||||||
*/
|
*/
|
||||||
public Optional<AccountState> update(
|
public Optional<AccountState> update(
|
||||||
String message, Account.Id accountId, Consumer<InternalAccountUpdate.Builder> update)
|
String message, Account.Id accountId, Consumer<InternalAccountUpdate.Builder> update)
|
||||||
throws StorageException, LockFailureException, IOException, ConfigInvalidException {
|
throws LockFailureException, IOException, ConfigInvalidException {
|
||||||
return update(message, accountId, AccountUpdater.fromConsumer(update));
|
return update(message, accountId, AccountUpdater.fromConsumer(update));
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -372,11 +369,10 @@ public class AccountsUpdate {
|
|||||||
* @throws IOException if updating the user branch fails due to an IO error
|
* @throws IOException if updating the user branch fails due to an IO error
|
||||||
* @throws LockFailureException if updating the user branch still fails due to concurrent updates
|
* @throws LockFailureException if updating the user branch still fails due to concurrent updates
|
||||||
* after the retry timeout exceeded
|
* after the retry timeout exceeded
|
||||||
* @throws StorageException if updating the user branch fails
|
|
||||||
* @throws ConfigInvalidException if any of the account fields has an invalid value
|
* @throws ConfigInvalidException if any of the account fields has an invalid value
|
||||||
*/
|
*/
|
||||||
public Optional<AccountState> update(String message, Account.Id accountId, AccountUpdater updater)
|
public Optional<AccountState> update(String message, Account.Id accountId, AccountUpdater updater)
|
||||||
throws StorageException, LockFailureException, IOException, ConfigInvalidException {
|
throws LockFailureException, IOException, ConfigInvalidException {
|
||||||
return updateAccount(
|
return updateAccount(
|
||||||
r -> {
|
r -> {
|
||||||
AccountConfig accountConfig = read(r, accountId);
|
AccountConfig accountConfig = read(r, accountId);
|
||||||
@@ -407,7 +403,7 @@ public class AccountsUpdate {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private Optional<AccountState> updateAccount(AccountUpdate accountUpdate)
|
private Optional<AccountState> updateAccount(AccountUpdate accountUpdate)
|
||||||
throws IOException, ConfigInvalidException, StorageException {
|
throws IOException, ConfigInvalidException {
|
||||||
return executeAccountUpdate(
|
return executeAccountUpdate(
|
||||||
() -> {
|
() -> {
|
||||||
try (Repository allUsersRepo = repoManager.openRepository(allUsersName)) {
|
try (Repository allUsersRepo = repoManager.openRepository(allUsersName)) {
|
||||||
@@ -423,7 +419,7 @@ public class AccountsUpdate {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private Optional<AccountState> executeAccountUpdate(Action<Optional<AccountState>> action)
|
private Optional<AccountState> executeAccountUpdate(Action<Optional<AccountState>> action)
|
||||||
throws IOException, ConfigInvalidException, StorageException {
|
throws IOException, ConfigInvalidException {
|
||||||
try {
|
try {
|
||||||
return retryHelper.execute(
|
return retryHelper.execute(
|
||||||
ActionType.ACCOUNT_UPDATE, action, LockFailureException.class::isInstance);
|
ActionType.ACCOUNT_UPDATE, action, LockFailureException.class::isInstance);
|
||||||
@@ -562,8 +558,7 @@ public class AccountsUpdate {
|
|||||||
|
|
||||||
@FunctionalInterface
|
@FunctionalInterface
|
||||||
private static interface AccountUpdate {
|
private static interface AccountUpdate {
|
||||||
UpdatedAccount update(Repository allUsersRepo)
|
UpdatedAccount update(Repository allUsersRepo) throws IOException, ConfigInvalidException;
|
||||||
throws IOException, ConfigInvalidException, StorageException;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private static class UpdatedAccount {
|
private static class UpdatedAccount {
|
||||||
|
@@ -69,7 +69,7 @@ public class Emails {
|
|||||||
*
|
*
|
||||||
* @see #getAccountsFor(String...)
|
* @see #getAccountsFor(String...)
|
||||||
*/
|
*/
|
||||||
public ImmutableSet<Account.Id> getAccountFor(String email) throws IOException, StorageException {
|
public ImmutableSet<Account.Id> getAccountFor(String email) throws IOException {
|
||||||
return Streams.concat(
|
return Streams.concat(
|
||||||
externalIds.byEmail(email).stream().map(ExternalId::accountId),
|
externalIds.byEmail(email).stream().map(ExternalId::accountId),
|
||||||
executeIndexQuery(() -> queryProvider.get().byPreferredEmail(email).stream())
|
executeIndexQuery(() -> queryProvider.get().byPreferredEmail(email).stream())
|
||||||
@@ -83,7 +83,7 @@ public class Emails {
|
|||||||
* @see #getAccountFor(String)
|
* @see #getAccountFor(String)
|
||||||
*/
|
*/
|
||||||
public ImmutableSetMultimap<String, Account.Id> getAccountsFor(String... emails)
|
public ImmutableSetMultimap<String, Account.Id> getAccountsFor(String... emails)
|
||||||
throws IOException, StorageException {
|
throws IOException {
|
||||||
ImmutableSetMultimap.Builder<String, Account.Id> builder = ImmutableSetMultimap.builder();
|
ImmutableSetMultimap.Builder<String, Account.Id> builder = ImmutableSetMultimap.builder();
|
||||||
externalIds.byEmails(emails).entries().stream()
|
externalIds.byEmails(emails).entries().stream()
|
||||||
.forEach(e -> builder.put(e.getKey(), e.getValue().accountId()));
|
.forEach(e -> builder.put(e.getKey(), e.getValue().accountId()));
|
||||||
@@ -102,7 +102,7 @@ public class Emails {
|
|||||||
return externalIds.byEmail(email).stream().map(ExternalId::accountId).collect(toImmutableSet());
|
return externalIds.byEmail(email).stream().map(ExternalId::accountId).collect(toImmutableSet());
|
||||||
}
|
}
|
||||||
|
|
||||||
private <T> T executeIndexQuery(Action<T> action) throws StorageException {
|
private <T> T executeIndexQuery(Action<T> action) {
|
||||||
try {
|
try {
|
||||||
return retryHelper.execute(
|
return retryHelper.execute(
|
||||||
ActionType.INDEX_QUERY, action, StorageException.class::isInstance);
|
ActionType.INDEX_QUERY, action, StorageException.class::isInstance);
|
||||||
|
@@ -22,7 +22,6 @@ import com.google.common.cache.LoadingCache;
|
|||||||
import com.google.common.collect.ImmutableList;
|
import com.google.common.collect.ImmutableList;
|
||||||
import com.google.common.collect.ImmutableSet;
|
import com.google.common.collect.ImmutableSet;
|
||||||
import com.google.common.flogger.FluentLogger;
|
import com.google.common.flogger.FluentLogger;
|
||||||
import com.google.gerrit.exceptions.StorageException;
|
|
||||||
import com.google.gerrit.reviewdb.client.Account;
|
import com.google.gerrit.reviewdb.client.Account;
|
||||||
import com.google.gerrit.reviewdb.client.AccountGroup;
|
import com.google.gerrit.reviewdb.client.AccountGroup;
|
||||||
import com.google.gerrit.server.cache.CacheModule;
|
import com.google.gerrit.server.cache.CacheModule;
|
||||||
@@ -152,7 +151,7 @@ public class GroupIncludeCacheImpl implements GroupIncludeCache {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public ImmutableSet<AccountGroup.UUID> load(Account.Id memberId) throws StorageException {
|
public ImmutableSet<AccountGroup.UUID> load(Account.Id memberId) {
|
||||||
try (TraceTimer timer = TraceContext.newTimer("Loading groups with member %s", memberId)) {
|
try (TraceTimer timer = TraceContext.newTimer("Loading groups with member %s", memberId)) {
|
||||||
return groupQueryProvider.get().byMember(memberId).stream()
|
return groupQueryProvider.get().byMember(memberId).stream()
|
||||||
.map(InternalGroup::getGroupUUID)
|
.map(InternalGroup::getGroupUUID)
|
||||||
@@ -171,7 +170,7 @@ public class GroupIncludeCacheImpl implements GroupIncludeCache {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public ImmutableList<AccountGroup.UUID> load(AccountGroup.UUID key) throws StorageException {
|
public ImmutableList<AccountGroup.UUID> load(AccountGroup.UUID key) {
|
||||||
try (TraceTimer timer = TraceContext.newTimer("Loading parent groups of %s", key)) {
|
try (TraceTimer timer = TraceContext.newTimer("Loading parent groups of %s", key)) {
|
||||||
return groupQueryProvider.get().bySubgroup(key).stream()
|
return groupQueryProvider.get().bySubgroup(key).stream()
|
||||||
.map(InternalGroup::getGroupUUID)
|
.map(InternalGroup::getGroupUUID)
|
||||||
|
@@ -14,7 +14,6 @@
|
|||||||
|
|
||||||
package com.google.gerrit.server.account;
|
package com.google.gerrit.server.account;
|
||||||
|
|
||||||
import com.google.gerrit.exceptions.StorageException;
|
|
||||||
import com.google.gerrit.extensions.restapi.ResourceConflictException;
|
import com.google.gerrit.extensions.restapi.ResourceConflictException;
|
||||||
import com.google.gerrit.extensions.restapi.ResourceNotFoundException;
|
import com.google.gerrit.extensions.restapi.ResourceNotFoundException;
|
||||||
import com.google.gerrit.extensions.restapi.Response;
|
import com.google.gerrit.extensions.restapi.Response;
|
||||||
@@ -48,7 +47,7 @@ public class SetInactiveFlag {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public Response<?> deactivate(Account.Id accountId)
|
public Response<?> deactivate(Account.Id accountId)
|
||||||
throws RestApiException, IOException, ConfigInvalidException, StorageException {
|
throws RestApiException, IOException, ConfigInvalidException {
|
||||||
AtomicBoolean alreadyInactive = new AtomicBoolean(false);
|
AtomicBoolean alreadyInactive = new AtomicBoolean(false);
|
||||||
AtomicReference<Optional<RestApiException>> exception = new AtomicReference<>(Optional.empty());
|
AtomicReference<Optional<RestApiException>> exception = new AtomicReference<>(Optional.empty());
|
||||||
accountsUpdateProvider
|
accountsUpdateProvider
|
||||||
@@ -81,7 +80,7 @@ public class SetInactiveFlag {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public Response<String> activate(Account.Id accountId)
|
public Response<String> activate(Account.Id accountId)
|
||||||
throws RestApiException, IOException, ConfigInvalidException, StorageException {
|
throws RestApiException, IOException, ConfigInvalidException {
|
||||||
AtomicBoolean alreadyActive = new AtomicBoolean(false);
|
AtomicBoolean alreadyActive = new AtomicBoolean(false);
|
||||||
AtomicReference<Optional<RestApiException>> exception = new AtomicReference<>(Optional.empty());
|
AtomicReference<Optional<RestApiException>> exception = new AtomicReference<>(Optional.empty());
|
||||||
accountsUpdateProvider
|
accountsUpdateProvider
|
||||||
|
@@ -16,7 +16,6 @@ package com.google.gerrit.server.api.changes;
|
|||||||
|
|
||||||
import static com.google.gerrit.server.api.ApiUtil.asRestApiException;
|
import static com.google.gerrit.server.api.ApiUtil.asRestApiException;
|
||||||
|
|
||||||
import com.google.gerrit.exceptions.StorageException;
|
|
||||||
import com.google.gerrit.extensions.api.changes.ChangeEditApi;
|
import com.google.gerrit.extensions.api.changes.ChangeEditApi;
|
||||||
import com.google.gerrit.extensions.api.changes.PublishChangeEditInput;
|
import com.google.gerrit.extensions.api.changes.PublishChangeEditInput;
|
||||||
import com.google.gerrit.extensions.client.ChangeEditDetailOption;
|
import com.google.gerrit.extensions.client.ChangeEditDetailOption;
|
||||||
@@ -242,7 +241,7 @@ public class ChangeEditApiImpl implements ChangeEditApi {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private ChangeEditResource getChangeEditResource(String filePath)
|
private ChangeEditResource getChangeEditResource(String filePath)
|
||||||
throws ResourceNotFoundException, AuthException, IOException, StorageException {
|
throws ResourceNotFoundException, AuthException, IOException {
|
||||||
return changeEdits.parse(changeResource, IdString.fromDecoded(filePath));
|
return changeEdits.parse(changeResource, IdString.fromDecoded(filePath));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -17,7 +17,6 @@ package com.google.gerrit.server.change;
|
|||||||
import com.google.common.base.Strings;
|
import com.google.common.base.Strings;
|
||||||
import com.google.common.flogger.FluentLogger;
|
import com.google.common.flogger.FluentLogger;
|
||||||
import com.google.gerrit.common.Nullable;
|
import com.google.gerrit.common.Nullable;
|
||||||
import com.google.gerrit.exceptions.StorageException;
|
|
||||||
import com.google.gerrit.extensions.restapi.ResourceConflictException;
|
import com.google.gerrit.extensions.restapi.ResourceConflictException;
|
||||||
import com.google.gerrit.reviewdb.client.Change;
|
import com.google.gerrit.reviewdb.client.Change;
|
||||||
import com.google.gerrit.reviewdb.client.ChangeMessage;
|
import com.google.gerrit.reviewdb.client.ChangeMessage;
|
||||||
@@ -79,8 +78,7 @@ public class AbandonOp implements BatchUpdateOp {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean updateChange(ChangeContext ctx)
|
public boolean updateChange(ChangeContext ctx) throws ResourceConflictException {
|
||||||
throws StorageException, ResourceConflictException {
|
|
||||||
change = ctx.getChange();
|
change = ctx.getChange();
|
||||||
PatchSet.Id psId = change.currentPatchSetId();
|
PatchSet.Id psId = change.currentPatchSetId();
|
||||||
ChangeUpdate update = ctx.getUpdate(psId);
|
ChangeUpdate update = ctx.getUpdate(psId);
|
||||||
@@ -109,7 +107,7 @@ public class AbandonOp implements BatchUpdateOp {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void postUpdate(Context ctx) throws StorageException {
|
public void postUpdate(Context ctx) {
|
||||||
NotifyResolver.Result notify = ctx.getNotify(change.getId());
|
NotifyResolver.Result notify = ctx.getNotify(change.getId());
|
||||||
try {
|
try {
|
||||||
ReplyToChangeSender cm = abandonedSenderFactory.create(ctx.getProject(), change.getId());
|
ReplyToChangeSender cm = abandonedSenderFactory.create(ctx.getProject(), change.getId());
|
||||||
|
@@ -103,7 +103,7 @@ public class AbandonUtil {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private Collection<ChangeData> getValidChanges(Collection<ChangeData> changes, String query)
|
private Collection<ChangeData> getValidChanges(Collection<ChangeData> changes, String query)
|
||||||
throws StorageException, QueryParseException {
|
throws QueryParseException {
|
||||||
Collection<ChangeData> validChanges = new ArrayList<>();
|
Collection<ChangeData> validChanges = new ArrayList<>();
|
||||||
for (ChangeData cd : changes) {
|
for (ChangeData cd : changes) {
|
||||||
String newQuery = query + " change:" + cd.getId();
|
String newQuery = query + " change:" + cd.getId();
|
||||||
|
@@ -16,7 +16,6 @@ package com.google.gerrit.server.change;
|
|||||||
|
|
||||||
import com.google.auto.value.AutoValue;
|
import com.google.auto.value.AutoValue;
|
||||||
import com.google.common.collect.ImmutableSet;
|
import com.google.common.collect.ImmutableSet;
|
||||||
import com.google.gerrit.exceptions.StorageException;
|
|
||||||
import com.google.gerrit.reviewdb.client.Account;
|
import com.google.gerrit.reviewdb.client.Account;
|
||||||
import com.google.gerrit.reviewdb.client.PatchSet;
|
import com.google.gerrit.reviewdb.client.PatchSet;
|
||||||
import java.util.Collection;
|
import java.util.Collection;
|
||||||
@@ -54,9 +53,8 @@ public interface AccountPatchReviewStore {
|
|||||||
* @param path file path
|
* @param path file path
|
||||||
* @return {@code true} if the reviewed flag was updated, {@code false} if the reviewed flag was
|
* @return {@code true} if the reviewed flag was updated, {@code false} if the reviewed flag was
|
||||||
* already set
|
* already set
|
||||||
* @throws StorageException thrown if updating the reviewed flag failed
|
|
||||||
*/
|
*/
|
||||||
boolean markReviewed(PatchSet.Id psId, Account.Id accountId, String path) throws StorageException;
|
boolean markReviewed(PatchSet.Id psId, Account.Id accountId, String path);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Marks the given files in the given patch set as reviewed by the given user.
|
* Marks the given files in the given patch set as reviewed by the given user.
|
||||||
@@ -64,10 +62,8 @@ public interface AccountPatchReviewStore {
|
|||||||
* @param psId patch set ID
|
* @param psId patch set ID
|
||||||
* @param accountId account ID of the user
|
* @param accountId account ID of the user
|
||||||
* @param paths file paths
|
* @param paths file paths
|
||||||
* @throws StorageException thrown if updating the reviewed flag failed
|
|
||||||
*/
|
*/
|
||||||
void markReviewed(PatchSet.Id psId, Account.Id accountId, Collection<String> paths)
|
void markReviewed(PatchSet.Id psId, Account.Id accountId, Collection<String> paths);
|
||||||
throws StorageException;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Clears the reviewed flag for the given file in the given patch set for the given user.
|
* Clears the reviewed flag for the given file in the given patch set for the given user.
|
||||||
@@ -75,17 +71,15 @@ public interface AccountPatchReviewStore {
|
|||||||
* @param psId patch set ID
|
* @param psId patch set ID
|
||||||
* @param accountId account ID of the user
|
* @param accountId account ID of the user
|
||||||
* @param path file path
|
* @param path file path
|
||||||
* @throws StorageException thrown if clearing the reviewed flag failed
|
|
||||||
*/
|
*/
|
||||||
void clearReviewed(PatchSet.Id psId, Account.Id accountId, String path) throws StorageException;
|
void clearReviewed(PatchSet.Id psId, Account.Id accountId, String path);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Clears the reviewed flags for all files in the given patch set for all users.
|
* Clears the reviewed flags for all files in the given patch set for all users.
|
||||||
*
|
*
|
||||||
* @param psId patch set ID
|
* @param psId patch set ID
|
||||||
* @throws StorageException thrown if clearing the reviewed flags failed
|
|
||||||
*/
|
*/
|
||||||
void clearReviewed(PatchSet.Id psId) throws StorageException;
|
void clearReviewed(PatchSet.Id psId);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Find the latest patch set, that is smaller or equals to the given patch set, where at least,
|
* Find the latest patch set, that is smaller or equals to the given patch set, where at least,
|
||||||
@@ -95,8 +89,6 @@ public interface AccountPatchReviewStore {
|
|||||||
* @param accountId account ID of the user
|
* @param accountId account ID of the user
|
||||||
* @return optionally, all files the have been reviewed by the given user that belong to the patch
|
* @return optionally, all files the have been reviewed by the given user that belong to the patch
|
||||||
* set that is smaller or equals to the given patch set
|
* set that is smaller or equals to the given patch set
|
||||||
* @throws StorageException thrown if accessing the reviewed flags failed
|
|
||||||
*/
|
*/
|
||||||
Optional<PatchSetWithReviewedFiles> findReviewed(PatchSet.Id psId, Account.Id accountId)
|
Optional<PatchSetWithReviewedFiles> findReviewed(PatchSet.Id psId, Account.Id accountId);
|
||||||
throws StorageException;
|
|
||||||
}
|
}
|
||||||
|
@@ -20,7 +20,6 @@ import com.google.common.collect.ImmutableMap;
|
|||||||
import com.google.common.collect.Iterables;
|
import com.google.common.collect.Iterables;
|
||||||
import com.google.common.collect.Lists;
|
import com.google.common.collect.Lists;
|
||||||
import com.google.gerrit.common.Nullable;
|
import com.google.gerrit.common.Nullable;
|
||||||
import com.google.gerrit.exceptions.StorageException;
|
|
||||||
import com.google.gerrit.extensions.api.changes.ActionVisitor;
|
import com.google.gerrit.extensions.api.changes.ActionVisitor;
|
||||||
import com.google.gerrit.extensions.common.ActionInfo;
|
import com.google.gerrit.extensions.common.ActionInfo;
|
||||||
import com.google.gerrit.extensions.common.ChangeInfo;
|
import com.google.gerrit.extensions.common.ChangeInfo;
|
||||||
@@ -70,7 +69,7 @@ public class ActionJson {
|
|||||||
this.userProvider = userProvider;
|
this.userProvider = userProvider;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Map<String, ActionInfo> format(RevisionResource rsrc) throws StorageException {
|
public Map<String, ActionInfo> format(RevisionResource rsrc) {
|
||||||
ChangeInfo changeInfo = null;
|
ChangeInfo changeInfo = null;
|
||||||
RevisionInfo revisionInfo = null;
|
RevisionInfo revisionInfo = null;
|
||||||
List<ActionVisitor> visitors = visitors();
|
List<ActionVisitor> visitors = visitors();
|
||||||
@@ -97,8 +96,7 @@ public class ActionJson {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public RevisionInfo addRevisionActions(
|
public RevisionInfo addRevisionActions(
|
||||||
@Nullable ChangeInfo changeInfo, RevisionInfo to, RevisionResource rsrc)
|
@Nullable ChangeInfo changeInfo, RevisionInfo to, RevisionResource rsrc) {
|
||||||
throws StorageException {
|
|
||||||
List<ActionVisitor> visitors = visitors();
|
List<ActionVisitor> visitors = visitors();
|
||||||
if (!visitors.isEmpty()) {
|
if (!visitors.isEmpty()) {
|
||||||
if (changeInfo != null) {
|
if (changeInfo != null) {
|
||||||
|
@@ -27,7 +27,6 @@ import com.google.common.collect.ImmutableList;
|
|||||||
import com.google.common.collect.ImmutableSet;
|
import com.google.common.collect.ImmutableSet;
|
||||||
import com.google.common.collect.Lists;
|
import com.google.common.collect.Lists;
|
||||||
import com.google.common.collect.Streams;
|
import com.google.common.collect.Streams;
|
||||||
import com.google.gerrit.exceptions.StorageException;
|
|
||||||
import com.google.gerrit.extensions.client.ReviewerState;
|
import com.google.gerrit.extensions.client.ReviewerState;
|
||||||
import com.google.gerrit.extensions.restapi.RestApiException;
|
import com.google.gerrit.extensions.restapi.RestApiException;
|
||||||
import com.google.gerrit.mail.Address;
|
import com.google.gerrit.mail.Address;
|
||||||
@@ -157,8 +156,7 @@ public class AddReviewersOp implements BatchUpdateOp {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean updateChange(ChangeContext ctx)
|
public boolean updateChange(ChangeContext ctx) throws RestApiException, IOException {
|
||||||
throws RestApiException, StorageException, IOException {
|
|
||||||
change = ctx.getChange();
|
change = ctx.getChange();
|
||||||
if (!accountIds.isEmpty()) {
|
if (!accountIds.isEmpty()) {
|
||||||
if (state == CC) {
|
if (state == CC) {
|
||||||
|
@@ -106,7 +106,7 @@ public class ChangeFinder {
|
|||||||
this.allowedIdTypes = ImmutableSet.copyOf(configuredChangeIdTypes);
|
this.allowedIdTypes = ImmutableSet.copyOf(configuredChangeIdTypes);
|
||||||
}
|
}
|
||||||
|
|
||||||
public ChangeNotes findOne(String id) throws StorageException {
|
public ChangeNotes findOne(String id) {
|
||||||
List<ChangeNotes> ctls = find(id);
|
List<ChangeNotes> ctls = find(id);
|
||||||
if (ctls.size() != 1) {
|
if (ctls.size() != 1) {
|
||||||
return null;
|
return null;
|
||||||
@@ -119,9 +119,8 @@ public class ChangeFinder {
|
|||||||
*
|
*
|
||||||
* @param id change identifier.
|
* @param id change identifier.
|
||||||
* @return possibly-empty list of notes for all matching changes; may or may not be visible.
|
* @return possibly-empty list of notes for all matching changes; may or may not be visible.
|
||||||
* @throws StorageException if an error occurred querying the database.
|
|
||||||
*/
|
*/
|
||||||
public List<ChangeNotes> find(String id) throws StorageException {
|
public List<ChangeNotes> find(String id) {
|
||||||
try {
|
try {
|
||||||
return find(id, false);
|
return find(id, false);
|
||||||
} catch (DeprecatedIdentifierException e) {
|
} catch (DeprecatedIdentifierException e) {
|
||||||
@@ -137,11 +136,10 @@ public class ChangeFinder {
|
|||||||
* @param enforceDeprecation boolean to see if we should throw {@link
|
* @param enforceDeprecation boolean to see if we should throw {@link
|
||||||
* DeprecatedIdentifierException} in case the identifier is deprecated
|
* DeprecatedIdentifierException} in case the identifier is deprecated
|
||||||
* @return possibly-empty list of notes for all matching changes; may or may not be visible.
|
* @return possibly-empty list of notes for all matching changes; may or may not be visible.
|
||||||
* @throws StorageException if an error occurred querying the database
|
|
||||||
* @throws DeprecatedIdentifierException if the identifier is deprecated.
|
* @throws DeprecatedIdentifierException if the identifier is deprecated.
|
||||||
*/
|
*/
|
||||||
public List<ChangeNotes> find(String id, boolean enforceDeprecation)
|
public List<ChangeNotes> find(String id, boolean enforceDeprecation)
|
||||||
throws StorageException, DeprecatedIdentifierException {
|
throws DeprecatedIdentifierException {
|
||||||
if (id.isEmpty()) {
|
if (id.isEmpty()) {
|
||||||
return Collections.emptyList();
|
return Collections.emptyList();
|
||||||
}
|
}
|
||||||
@@ -194,8 +192,7 @@ public class ChangeFinder {
|
|||||||
return notes;
|
return notes;
|
||||||
}
|
}
|
||||||
|
|
||||||
private List<ChangeNotes> fromProjectNumber(String project, int changeNumber)
|
private List<ChangeNotes> fromProjectNumber(String project, int changeNumber) {
|
||||||
throws StorageException {
|
|
||||||
Change.Id cId = new Change.Id(changeNumber);
|
Change.Id cId = new Change.Id(changeNumber);
|
||||||
try {
|
try {
|
||||||
return ImmutableList.of(
|
return ImmutableList.of(
|
||||||
@@ -212,7 +209,7 @@ public class ChangeFinder {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public ChangeNotes findOne(Change.Id id) throws StorageException {
|
public ChangeNotes findOne(Change.Id id) {
|
||||||
List<ChangeNotes> notes = find(id);
|
List<ChangeNotes> notes = find(id);
|
||||||
if (notes.size() != 1) {
|
if (notes.size() != 1) {
|
||||||
throw new NoSuchChangeException(id);
|
throw new NoSuchChangeException(id);
|
||||||
@@ -220,7 +217,7 @@ public class ChangeFinder {
|
|||||||
return notes.get(0);
|
return notes.get(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
public List<ChangeNotes> find(Change.Id id) throws StorageException {
|
public List<ChangeNotes> find(Change.Id id) {
|
||||||
String project = changeIdProjectCache.getIfPresent(id);
|
String project = changeIdProjectCache.getIfPresent(id);
|
||||||
if (project != null) {
|
if (project != null) {
|
||||||
return fromProjectNumber(project, id.get());
|
return fromProjectNumber(project, id.get());
|
||||||
@@ -236,7 +233,7 @@ public class ChangeFinder {
|
|||||||
return asChangeNotes(r);
|
return asChangeNotes(r);
|
||||||
}
|
}
|
||||||
|
|
||||||
private List<ChangeNotes> asChangeNotes(List<ChangeData> cds) throws StorageException {
|
private List<ChangeNotes> asChangeNotes(List<ChangeData> cds) {
|
||||||
List<ChangeNotes> notes = new ArrayList<>(cds.size());
|
List<ChangeNotes> notes = new ArrayList<>(cds.size());
|
||||||
if (!indexConfig.separateChangeSubIndexes()) {
|
if (!indexConfig.separateChangeSubIndexes()) {
|
||||||
for (ChangeData cd : cds) {
|
for (ChangeData cd : cds) {
|
||||||
|
@@ -30,7 +30,6 @@ import com.google.common.flogger.FluentLogger;
|
|||||||
import com.google.gerrit.common.FooterConstants;
|
import com.google.gerrit.common.FooterConstants;
|
||||||
import com.google.gerrit.common.data.LabelType;
|
import com.google.gerrit.common.data.LabelType;
|
||||||
import com.google.gerrit.common.data.LabelTypes;
|
import com.google.gerrit.common.data.LabelTypes;
|
||||||
import com.google.gerrit.exceptions.StorageException;
|
|
||||||
import com.google.gerrit.extensions.api.changes.NotifyHandling;
|
import com.google.gerrit.extensions.api.changes.NotifyHandling;
|
||||||
import com.google.gerrit.extensions.client.ReviewerState;
|
import com.google.gerrit.extensions.client.ReviewerState;
|
||||||
import com.google.gerrit.extensions.restapi.ResourceConflictException;
|
import com.google.gerrit.extensions.restapi.ResourceConflictException;
|
||||||
@@ -369,8 +368,7 @@ public class ChangeInserter implements InsertChangeOp {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean updateChange(ChangeContext ctx)
|
public boolean updateChange(ChangeContext ctx)
|
||||||
throws RestApiException, StorageException, IOException, PermissionBackendException,
|
throws RestApiException, IOException, PermissionBackendException, ConfigInvalidException {
|
||||||
ConfigInvalidException {
|
|
||||||
change = ctx.getChange(); // Use defensive copy created by ChangeControl.
|
change = ctx.getChange(); // Use defensive copy created by ChangeControl.
|
||||||
patchSetInfo =
|
patchSetInfo =
|
||||||
patchSetInfoFactory.get(ctx.getRevWalk(), ctx.getRevWalk().parseCommit(commitId), psId);
|
patchSetInfoFactory.get(ctx.getRevWalk(), ctx.getRevWalk().parseCommit(commitId), psId);
|
||||||
|
@@ -268,23 +268,23 @@ public class ChangeJson {
|
|||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
public ChangeInfo format(ChangeResource rsrc) throws StorageException {
|
public ChangeInfo format(ChangeResource rsrc) {
|
||||||
return format(changeDataFactory.create(rsrc.getNotes()));
|
return format(changeDataFactory.create(rsrc.getNotes()));
|
||||||
}
|
}
|
||||||
|
|
||||||
public ChangeInfo format(Change change) throws StorageException {
|
public ChangeInfo format(Change change) {
|
||||||
return format(changeDataFactory.create(change));
|
return format(changeDataFactory.create(change));
|
||||||
}
|
}
|
||||||
|
|
||||||
public ChangeInfo format(Project.NameKey project, Change.Id id) throws StorageException {
|
public ChangeInfo format(Project.NameKey project, Change.Id id) {
|
||||||
return format(project, id, ChangeInfo::new);
|
return format(project, id, ChangeInfo::new);
|
||||||
}
|
}
|
||||||
|
|
||||||
public ChangeInfo format(ChangeData cd) throws StorageException {
|
public ChangeInfo format(ChangeData cd) {
|
||||||
return format(cd, Optional.empty(), true, ChangeInfo::new);
|
return format(cd, Optional.empty(), true, ChangeInfo::new);
|
||||||
}
|
}
|
||||||
|
|
||||||
public ChangeInfo format(RevisionResource rsrc) throws StorageException {
|
public ChangeInfo format(RevisionResource rsrc) {
|
||||||
ChangeData cd = changeDataFactory.create(rsrc.getNotes());
|
ChangeData cd = changeDataFactory.create(rsrc.getNotes());
|
||||||
return format(cd, Optional.of(rsrc.getPatchSet().getId()), true, ChangeInfo::new);
|
return format(cd, Optional.of(rsrc.getPatchSet().getId()), true, ChangeInfo::new);
|
||||||
}
|
}
|
||||||
@@ -308,8 +308,7 @@ public class ChangeJson {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public List<ChangeInfo> format(Collection<ChangeData> in)
|
public List<ChangeInfo> format(Collection<ChangeData> in) throws PermissionBackendException {
|
||||||
throws StorageException, PermissionBackendException {
|
|
||||||
accountLoader = accountLoaderFactory.create(has(DETAILED_ACCOUNTS));
|
accountLoader = accountLoaderFactory.create(has(DETAILED_ACCOUNTS));
|
||||||
ensureLoaded(in);
|
ensureLoaded(in);
|
||||||
List<ChangeInfo> out = new ArrayList<>(in.size());
|
List<ChangeInfo> out = new ArrayList<>(in.size());
|
||||||
@@ -321,8 +320,7 @@ public class ChangeJson {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public <I extends ChangeInfo> I format(
|
public <I extends ChangeInfo> I format(
|
||||||
Project.NameKey project, Change.Id id, Supplier<I> changeInfoSupplier)
|
Project.NameKey project, Change.Id id, Supplier<I> changeInfoSupplier) {
|
||||||
throws StorageException {
|
|
||||||
ChangeNotes notes;
|
ChangeNotes notes;
|
||||||
try {
|
try {
|
||||||
notes = notesFactory.createChecked(project, id);
|
notes = notesFactory.createChecked(project, id);
|
||||||
@@ -367,8 +365,7 @@ public class ChangeJson {
|
|||||||
ChangeData cd,
|
ChangeData cd,
|
||||||
Optional<PatchSet.Id> limitToPsId,
|
Optional<PatchSet.Id> limitToPsId,
|
||||||
boolean fillAccountLoader,
|
boolean fillAccountLoader,
|
||||||
Supplier<I> changeInfoSupplier)
|
Supplier<I> changeInfoSupplier) {
|
||||||
throws StorageException {
|
|
||||||
try {
|
try {
|
||||||
if (fillAccountLoader) {
|
if (fillAccountLoader) {
|
||||||
accountLoader = accountLoaderFactory.create(has(DETAILED_ACCOUNTS));
|
accountLoader = accountLoaderFactory.create(has(DETAILED_ACCOUNTS));
|
||||||
@@ -390,7 +387,7 @@ public class ChangeJson {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void ensureLoaded(Iterable<ChangeData> all) throws StorageException {
|
private void ensureLoaded(Iterable<ChangeData> all) {
|
||||||
if (lazyLoad) {
|
if (lazyLoad) {
|
||||||
ChangeData.ensureChangeLoaded(all);
|
ChangeData.ensureChangeLoaded(all);
|
||||||
if (has(ALL_REVISIONS)) {
|
if (has(ALL_REVISIONS)) {
|
||||||
@@ -477,8 +474,7 @@ public class ChangeJson {
|
|||||||
|
|
||||||
private <I extends ChangeInfo> I toChangeInfo(
|
private <I extends ChangeInfo> I toChangeInfo(
|
||||||
ChangeData cd, Optional<PatchSet.Id> limitToPsId, Supplier<I> changeInfoSupplier)
|
ChangeData cd, Optional<PatchSet.Id> limitToPsId, Supplier<I> changeInfoSupplier)
|
||||||
throws PatchListNotAvailableException, GpgException, StorageException,
|
throws PatchListNotAvailableException, GpgException, PermissionBackendException, IOException {
|
||||||
PermissionBackendException, IOException {
|
|
||||||
try (Timer0.Context ignored = metrics.toChangeInfoLatency.start()) {
|
try (Timer0.Context ignored = metrics.toChangeInfoLatency.start()) {
|
||||||
return toChangeInfoImpl(cd, limitToPsId, changeInfoSupplier);
|
return toChangeInfoImpl(cd, limitToPsId, changeInfoSupplier);
|
||||||
}
|
}
|
||||||
@@ -486,8 +482,7 @@ public class ChangeJson {
|
|||||||
|
|
||||||
private <I extends ChangeInfo> I toChangeInfoImpl(
|
private <I extends ChangeInfo> I toChangeInfoImpl(
|
||||||
ChangeData cd, Optional<PatchSet.Id> limitToPsId, Supplier<I> changeInfoSupplier)
|
ChangeData cd, Optional<PatchSet.Id> limitToPsId, Supplier<I> changeInfoSupplier)
|
||||||
throws PatchListNotAvailableException, GpgException, StorageException,
|
throws PatchListNotAvailableException, GpgException, PermissionBackendException, IOException {
|
||||||
PermissionBackendException, IOException {
|
|
||||||
I out = changeInfoSupplier.get();
|
I out = changeInfoSupplier.get();
|
||||||
CurrentUser user = userProvider.get();
|
CurrentUser user = userProvider.get();
|
||||||
|
|
||||||
@@ -638,7 +633,7 @@ public class ChangeJson {
|
|||||||
return reviewerMap;
|
return reviewerMap;
|
||||||
}
|
}
|
||||||
|
|
||||||
private Collection<ReviewerUpdateInfo> reviewerUpdates(ChangeData cd) throws StorageException {
|
private Collection<ReviewerUpdateInfo> reviewerUpdates(ChangeData cd) {
|
||||||
List<ReviewerStatusUpdate> reviewerUpdates = cd.reviewerUpdates();
|
List<ReviewerStatusUpdate> reviewerUpdates = cd.reviewerUpdates();
|
||||||
List<ReviewerUpdateInfo> result = new ArrayList<>(reviewerUpdates.size());
|
List<ReviewerUpdateInfo> result = new ArrayList<>(reviewerUpdates.size());
|
||||||
for (ReviewerStatusUpdate c : reviewerUpdates) {
|
for (ReviewerStatusUpdate c : reviewerUpdates) {
|
||||||
@@ -656,7 +651,7 @@ public class ChangeJson {
|
|||||||
return SubmitRecord.allRecordsOK(cd.submitRecords(SUBMIT_RULE_OPTIONS_STRICT));
|
return SubmitRecord.allRecordsOK(cd.submitRecords(SUBMIT_RULE_OPTIONS_STRICT));
|
||||||
}
|
}
|
||||||
|
|
||||||
private void setSubmitter(ChangeData cd, ChangeInfo out) throws StorageException {
|
private void setSubmitter(ChangeData cd, ChangeInfo out) {
|
||||||
Optional<PatchSetApproval> s = cd.getSubmitApproval();
|
Optional<PatchSetApproval> s = cd.getSubmitApproval();
|
||||||
if (!s.isPresent()) {
|
if (!s.isPresent()) {
|
||||||
return;
|
return;
|
||||||
@@ -665,7 +660,7 @@ public class ChangeJson {
|
|||||||
out.submitter = accountLoader.get(s.get().getAccountId());
|
out.submitter = accountLoader.get(s.get().getAccountId());
|
||||||
}
|
}
|
||||||
|
|
||||||
private Collection<ChangeMessageInfo> messages(ChangeData cd) throws StorageException {
|
private Collection<ChangeMessageInfo> messages(ChangeData cd) {
|
||||||
List<ChangeMessage> messages = cmUtil.byChange(cd.notes());
|
List<ChangeMessage> messages = cmUtil.byChange(cd.notes());
|
||||||
if (messages.isEmpty()) {
|
if (messages.isEmpty()) {
|
||||||
return Collections.emptyList();
|
return Collections.emptyList();
|
||||||
@@ -679,7 +674,7 @@ public class ChangeJson {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private Collection<AccountInfo> removableReviewers(ChangeData cd, ChangeInfo out)
|
private Collection<AccountInfo> removableReviewers(ChangeData cd, ChangeInfo out)
|
||||||
throws PermissionBackendException, StorageException {
|
throws PermissionBackendException {
|
||||||
// Although this is called removableReviewers, this method also determines
|
// Although this is called removableReviewers, this method also determines
|
||||||
// which CCs are removable.
|
// which CCs are removable.
|
||||||
//
|
//
|
||||||
@@ -767,8 +762,8 @@ public class ChangeJson {
|
|||||||
.collect(toList());
|
.collect(toList());
|
||||||
}
|
}
|
||||||
|
|
||||||
private Map<PatchSet.Id, PatchSet> loadPatchSets(ChangeData cd, Optional<PatchSet.Id> limitToPsId)
|
private Map<PatchSet.Id, PatchSet> loadPatchSets(
|
||||||
throws StorageException {
|
ChangeData cd, Optional<PatchSet.Id> limitToPsId) {
|
||||||
Collection<PatchSet> src;
|
Collection<PatchSet> src;
|
||||||
if (has(ALL_REVISIONS) || has(MESSAGES)) {
|
if (has(ALL_REVISIONS) || has(MESSAGES)) {
|
||||||
src = cd.patchSets();
|
src = cd.patchSets();
|
||||||
@@ -799,8 +794,7 @@ public class ChangeJson {
|
|||||||
* from either an index-backed or a database-backed {@link ChangeData} depending on {@code
|
* from either an index-backed or a database-backed {@link ChangeData} depending on {@code
|
||||||
* lazyload}.
|
* lazyload}.
|
||||||
*/
|
*/
|
||||||
private PermissionBackend.ForChange permissionBackendForChange(CurrentUser user, ChangeData cd)
|
private PermissionBackend.ForChange permissionBackendForChange(CurrentUser user, ChangeData cd) {
|
||||||
throws StorageException {
|
|
||||||
PermissionBackend.WithUser withUser = permissionBackend.user(user);
|
PermissionBackend.WithUser withUser = permissionBackend.user(user);
|
||||||
return lazyLoad
|
return lazyLoad
|
||||||
? withUser.change(cd)
|
? withUser.change(cd)
|
||||||
|
@@ -574,7 +574,7 @@ public class ConsistencyChecker {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean updateChange(ChangeContext ctx) throws StorageException {
|
public boolean updateChange(ChangeContext ctx) {
|
||||||
ctx.getChange().setStatus(Change.Status.MERGED);
|
ctx.getChange().setStatus(Change.Status.MERGED);
|
||||||
ctx.getUpdate(ctx.getChange().currentPatchSetId()).fixStatus(Change.Status.MERGED);
|
ctx.getUpdate(ctx.getChange().currentPatchSetId()).fixStatus(Change.Status.MERGED);
|
||||||
p.status = Status.FIXED;
|
p.status = Status.FIXED;
|
||||||
@@ -672,8 +672,7 @@ public class ConsistencyChecker {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean updateChange(ChangeContext ctx)
|
public boolean updateChange(ChangeContext ctx) throws PatchSetInfoNotAvailableException {
|
||||||
throws StorageException, PatchSetInfoNotAvailableException {
|
|
||||||
// Delete dangling key references.
|
// Delete dangling key references.
|
||||||
accountPatchReviewStore.run(s -> s.clearReviewed(psId), StorageException.class);
|
accountPatchReviewStore.run(s -> s.clearReviewed(psId), StorageException.class);
|
||||||
|
|
||||||
@@ -706,8 +705,7 @@ public class ConsistencyChecker {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean updateChange(ChangeContext ctx)
|
public boolean updateChange(ChangeContext ctx)
|
||||||
throws StorageException, PatchSetInfoNotAvailableException,
|
throws PatchSetInfoNotAvailableException, NoPatchSetsWouldRemainException {
|
||||||
NoPatchSetsWouldRemainException {
|
|
||||||
if (!toDelete.contains(ctx.getChange().currentPatchSetId())) {
|
if (!toDelete.contains(ctx.getChange().currentPatchSetId())) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
@@ -66,8 +66,7 @@ public class DeleteChangeOp implements BatchUpdateOp {
|
|||||||
// executed in a single atomic BatchRefUpdate. Actually deleting the change refs first would not
|
// executed in a single atomic BatchRefUpdate. Actually deleting the change refs first would not
|
||||||
// fail gracefully if the second delete fails, but fortunately that's not what happens.
|
// fail gracefully if the second delete fails, but fortunately that's not what happens.
|
||||||
@Override
|
@Override
|
||||||
public boolean updateChange(ChangeContext ctx)
|
public boolean updateChange(ChangeContext ctx) throws RestApiException, IOException {
|
||||||
throws RestApiException, StorageException, IOException {
|
|
||||||
Collection<PatchSet> patchSets = psUtil.byChange(ctx.getNotes());
|
Collection<PatchSet> patchSets = psUtil.byChange(ctx.getNotes());
|
||||||
|
|
||||||
ensureDeletable(ctx, id, patchSets);
|
ensureDeletable(ctx, id, patchSets);
|
||||||
@@ -107,7 +106,7 @@ public class DeleteChangeOp implements BatchUpdateOp {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private void cleanUpReferences(ChangeContext ctx, Change.Id id, Collection<PatchSet> patchSets)
|
private void cleanUpReferences(ChangeContext ctx, Change.Id id, Collection<PatchSet> patchSets)
|
||||||
throws StorageException, NoSuchChangeException {
|
throws NoSuchChangeException {
|
||||||
for (PatchSet ps : patchSets) {
|
for (PatchSet ps : patchSets) {
|
||||||
accountPatchReviewStore.run(s -> s.clearReviewed(ps.getId()), StorageException.class);
|
accountPatchReviewStore.run(s -> s.clearReviewed(ps.getId()), StorageException.class);
|
||||||
}
|
}
|
||||||
|
@@ -15,7 +15,6 @@
|
|||||||
package com.google.gerrit.server.change;
|
package com.google.gerrit.server.change;
|
||||||
|
|
||||||
import com.google.common.flogger.FluentLogger;
|
import com.google.common.flogger.FluentLogger;
|
||||||
import com.google.gerrit.exceptions.StorageException;
|
|
||||||
import com.google.gerrit.mail.Address;
|
import com.google.gerrit.mail.Address;
|
||||||
import com.google.gerrit.reviewdb.client.Change;
|
import com.google.gerrit.reviewdb.client.Change;
|
||||||
import com.google.gerrit.reviewdb.client.ChangeMessage;
|
import com.google.gerrit.reviewdb.client.ChangeMessage;
|
||||||
@@ -50,7 +49,7 @@ public class DeleteReviewerByEmailOp implements BatchUpdateOp {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean updateChange(ChangeContext ctx) throws StorageException {
|
public boolean updateChange(ChangeContext ctx) {
|
||||||
change = ctx.getChange();
|
change = ctx.getChange();
|
||||||
PatchSet.Id psId = ctx.getChange().currentPatchSetId();
|
PatchSet.Id psId = ctx.getChange().currentPatchSetId();
|
||||||
String msg = "Removed reviewer " + reviewer;
|
String msg = "Removed reviewer " + reviewer;
|
||||||
|
@@ -19,7 +19,6 @@ import com.google.common.flogger.FluentLogger;
|
|||||||
import com.google.gerrit.common.data.LabelType;
|
import com.google.gerrit.common.data.LabelType;
|
||||||
import com.google.gerrit.common.data.LabelTypes;
|
import com.google.gerrit.common.data.LabelTypes;
|
||||||
import com.google.gerrit.exceptions.EmailException;
|
import com.google.gerrit.exceptions.EmailException;
|
||||||
import com.google.gerrit.exceptions.StorageException;
|
|
||||||
import com.google.gerrit.extensions.api.changes.DeleteReviewerInput;
|
import com.google.gerrit.extensions.api.changes.DeleteReviewerInput;
|
||||||
import com.google.gerrit.extensions.api.changes.NotifyHandling;
|
import com.google.gerrit.extensions.api.changes.NotifyHandling;
|
||||||
import com.google.gerrit.extensions.restapi.AuthException;
|
import com.google.gerrit.extensions.restapi.AuthException;
|
||||||
@@ -108,8 +107,7 @@ public class DeleteReviewerOp implements BatchUpdateOp {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean updateChange(ChangeContext ctx)
|
public boolean updateChange(ChangeContext ctx)
|
||||||
throws AuthException, ResourceNotFoundException, StorageException, PermissionBackendException,
|
throws AuthException, ResourceNotFoundException, PermissionBackendException, IOException {
|
||||||
IOException {
|
|
||||||
Account.Id reviewerId = reviewer.getAccount().getId();
|
Account.Id reviewerId = reviewer.getAccount().getId();
|
||||||
// Check of removing this reviewer (even if there is no vote processed by the loop below) is OK
|
// Check of removing this reviewer (even if there is no vote processed by the loop below) is OK
|
||||||
removeReviewerControl.checkRemoveReviewer(ctx.getNotes(), ctx.getUser(), reviewerId);
|
removeReviewerControl.checkRemoveReviewer(ctx.getNotes(), ctx.getUser(), reviewerId);
|
||||||
@@ -194,8 +192,7 @@ public class DeleteReviewerOp implements BatchUpdateOp {
|
|||||||
ctx.getWhen());
|
ctx.getWhen());
|
||||||
}
|
}
|
||||||
|
|
||||||
private Iterable<PatchSetApproval> approvals(ChangeContext ctx, Account.Id accountId)
|
private Iterable<PatchSetApproval> approvals(ChangeContext ctx, Account.Id accountId) {
|
||||||
throws StorageException {
|
|
||||||
Iterable<PatchSetApproval> approvals;
|
Iterable<PatchSetApproval> approvals;
|
||||||
approvals = approvalsUtil.byChange(ctx.getNotes()).values();
|
approvals = approvalsUtil.byChange(ctx.getNotes()).values();
|
||||||
return Iterables.filter(approvals, psa -> accountId.equals(psa.getAccountId()));
|
return Iterables.filter(approvals, psa -> accountId.equals(psa.getAccountId()));
|
||||||
|
@@ -36,7 +36,6 @@ import com.google.gerrit.common.data.LabelType;
|
|||||||
import com.google.gerrit.common.data.LabelTypes;
|
import com.google.gerrit.common.data.LabelTypes;
|
||||||
import com.google.gerrit.common.data.LabelValue;
|
import com.google.gerrit.common.data.LabelValue;
|
||||||
import com.google.gerrit.common.data.SubmitRecord;
|
import com.google.gerrit.common.data.SubmitRecord;
|
||||||
import com.google.gerrit.exceptions.StorageException;
|
|
||||||
import com.google.gerrit.extensions.client.ListChangesOption;
|
import com.google.gerrit.extensions.client.ListChangesOption;
|
||||||
import com.google.gerrit.extensions.common.ApprovalInfo;
|
import com.google.gerrit.extensions.common.ApprovalInfo;
|
||||||
import com.google.gerrit.extensions.common.LabelInfo;
|
import com.google.gerrit.extensions.common.LabelInfo;
|
||||||
@@ -100,7 +99,7 @@ public class LabelsJson {
|
|||||||
*/
|
*/
|
||||||
Map<String, LabelInfo> labelsFor(
|
Map<String, LabelInfo> labelsFor(
|
||||||
AccountLoader accountLoader, ChangeData cd, boolean standard, boolean detailed)
|
AccountLoader accountLoader, ChangeData cd, boolean standard, boolean detailed)
|
||||||
throws StorageException, PermissionBackendException {
|
throws PermissionBackendException {
|
||||||
if (!standard && !detailed) {
|
if (!standard && !detailed) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
@@ -115,7 +114,7 @@ public class LabelsJson {
|
|||||||
|
|
||||||
/** Returns all labels that the provided user has permission to vote on. */
|
/** Returns all labels that the provided user has permission to vote on. */
|
||||||
Map<String, Collection<String>> permittedLabels(Account.Id filterApprovalsBy, ChangeData cd)
|
Map<String, Collection<String>> permittedLabels(Account.Id filterApprovalsBy, ChangeData cd)
|
||||||
throws StorageException, PermissionBackendException {
|
throws PermissionBackendException {
|
||||||
boolean isMerged = cd.change().isMerged();
|
boolean isMerged = cd.change().isMerged();
|
||||||
LabelTypes labelTypes = cd.getLabelTypes();
|
LabelTypes labelTypes = cd.getLabelTypes();
|
||||||
Map<String, LabelType> toCheck = new HashMap<>();
|
Map<String, LabelType> toCheck = new HashMap<>();
|
||||||
@@ -194,7 +193,7 @@ public class LabelsJson {
|
|||||||
LabelTypes labelTypes,
|
LabelTypes labelTypes,
|
||||||
boolean standard,
|
boolean standard,
|
||||||
boolean detailed)
|
boolean detailed)
|
||||||
throws StorageException, PermissionBackendException {
|
throws PermissionBackendException {
|
||||||
Map<String, LabelWithStatus> labels = initLabels(accountLoader, cd, labelTypes, standard);
|
Map<String, LabelWithStatus> labels = initLabels(accountLoader, cd, labelTypes, standard);
|
||||||
if (detailed) {
|
if (detailed) {
|
||||||
setAllApprovals(accountLoader, cd, labels);
|
setAllApprovals(accountLoader, cd, labels);
|
||||||
@@ -252,8 +251,7 @@ public class LabelsJson {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private Map<String, Short> currentLabels(Account.Id accountId, ChangeData cd)
|
private Map<String, Short> currentLabels(Account.Id accountId, ChangeData cd) {
|
||||||
throws StorageException {
|
|
||||||
Map<String, Short> result = new HashMap<>();
|
Map<String, Short> result = new HashMap<>();
|
||||||
for (PatchSetApproval psa :
|
for (PatchSetApproval psa :
|
||||||
approvalsUtil.byPatchSetUser(
|
approvalsUtil.byPatchSetUser(
|
||||||
@@ -273,7 +271,7 @@ public class LabelsJson {
|
|||||||
LabelTypes labelTypes,
|
LabelTypes labelTypes,
|
||||||
boolean standard,
|
boolean standard,
|
||||||
boolean detailed)
|
boolean detailed)
|
||||||
throws StorageException, PermissionBackendException {
|
throws PermissionBackendException {
|
||||||
Set<Account.Id> allUsers = new HashSet<>();
|
Set<Account.Id> allUsers = new HashSet<>();
|
||||||
if (detailed) {
|
if (detailed) {
|
||||||
// Users expect to see all reviewers on closed changes, even if they
|
// Users expect to see all reviewers on closed changes, even if they
|
||||||
@@ -431,7 +429,7 @@ public class LabelsJson {
|
|||||||
|
|
||||||
private void setAllApprovals(
|
private void setAllApprovals(
|
||||||
AccountLoader accountLoader, ChangeData cd, Map<String, LabelWithStatus> labels)
|
AccountLoader accountLoader, ChangeData cd, Map<String, LabelWithStatus> labels)
|
||||||
throws StorageException, PermissionBackendException {
|
throws PermissionBackendException {
|
||||||
checkState(
|
checkState(
|
||||||
!cd.change().isMerged(),
|
!cd.change().isMerged(),
|
||||||
"should not call setAllApprovals on %s change",
|
"should not call setAllApprovals on %s change",
|
||||||
@@ -499,8 +497,7 @@ public class LabelsJson {
|
|||||||
* from either an index-backed or a database-backed {@link ChangeData} depending on {@code
|
* from either an index-backed or a database-backed {@link ChangeData} depending on {@code
|
||||||
* lazyload}.
|
* lazyload}.
|
||||||
*/
|
*/
|
||||||
private PermissionBackend.ForChange permissionBackendForChange(Account.Id user, ChangeData cd)
|
private PermissionBackend.ForChange permissionBackendForChange(Account.Id user, ChangeData cd) {
|
||||||
throws StorageException {
|
|
||||||
PermissionBackend.WithUser withUser = permissionBackend.absentUser(user);
|
PermissionBackend.WithUser withUser = permissionBackend.absentUser(user);
|
||||||
return lazyLoad
|
return lazyLoad
|
||||||
? withUser.change(cd)
|
? withUser.change(cd)
|
||||||
|
@@ -21,7 +21,6 @@ import com.google.auto.value.AutoValue;
|
|||||||
import com.google.common.collect.ImmutableList;
|
import com.google.common.collect.ImmutableList;
|
||||||
import com.google.common.collect.ImmutableSetMultimap;
|
import com.google.common.collect.ImmutableSetMultimap;
|
||||||
import com.google.gerrit.common.Nullable;
|
import com.google.gerrit.common.Nullable;
|
||||||
import com.google.gerrit.exceptions.StorageException;
|
|
||||||
import com.google.gerrit.extensions.api.changes.NotifyHandling;
|
import com.google.gerrit.extensions.api.changes.NotifyHandling;
|
||||||
import com.google.gerrit.extensions.api.changes.NotifyInfo;
|
import com.google.gerrit.extensions.api.changes.NotifyInfo;
|
||||||
import com.google.gerrit.extensions.api.changes.RecipientType;
|
import com.google.gerrit.extensions.api.changes.RecipientType;
|
||||||
@@ -81,7 +80,7 @@ public class NotifyResolver {
|
|||||||
|
|
||||||
public Result resolve(
|
public Result resolve(
|
||||||
NotifyHandling handling, @Nullable Map<RecipientType, NotifyInfo> notifyDetails)
|
NotifyHandling handling, @Nullable Map<RecipientType, NotifyInfo> notifyDetails)
|
||||||
throws BadRequestException, StorageException, IOException, ConfigInvalidException {
|
throws BadRequestException, IOException, ConfigInvalidException {
|
||||||
requireNonNull(handling);
|
requireNonNull(handling);
|
||||||
ImmutableSetMultimap.Builder<RecipientType, Account.Id> b = ImmutableSetMultimap.builder();
|
ImmutableSetMultimap.Builder<RecipientType, Account.Id> b = ImmutableSetMultimap.builder();
|
||||||
if (notifyDetails != null) {
|
if (notifyDetails != null) {
|
||||||
@@ -93,7 +92,7 @@ public class NotifyResolver {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private ImmutableList<Account.Id> find(@Nullable List<String> inputs)
|
private ImmutableList<Account.Id> find(@Nullable List<String> inputs)
|
||||||
throws StorageException, BadRequestException, IOException, ConfigInvalidException {
|
throws BadRequestException, IOException, ConfigInvalidException {
|
||||||
if (inputs == null || inputs.isEmpty()) {
|
if (inputs == null || inputs.isEmpty()) {
|
||||||
return ImmutableList.of();
|
return ImmutableList.of();
|
||||||
}
|
}
|
||||||
|
@@ -20,7 +20,6 @@ import static com.google.gerrit.server.notedb.ReviewerStateInternal.REVIEWER;
|
|||||||
import static java.util.Objects.requireNonNull;
|
import static java.util.Objects.requireNonNull;
|
||||||
|
|
||||||
import com.google.common.flogger.FluentLogger;
|
import com.google.common.flogger.FluentLogger;
|
||||||
import com.google.gerrit.exceptions.StorageException;
|
|
||||||
import com.google.gerrit.extensions.api.changes.NotifyHandling;
|
import com.google.gerrit.extensions.api.changes.NotifyHandling;
|
||||||
import com.google.gerrit.extensions.restapi.AuthException;
|
import com.google.gerrit.extensions.restapi.AuthException;
|
||||||
import com.google.gerrit.extensions.restapi.ResourceConflictException;
|
import com.google.gerrit.extensions.restapi.ResourceConflictException;
|
||||||
@@ -187,15 +186,13 @@ public class PatchSetInserter implements BatchUpdateOp {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void updateRepo(RepoContext ctx)
|
public void updateRepo(RepoContext ctx)
|
||||||
throws AuthException, ResourceConflictException, IOException, StorageException,
|
throws AuthException, ResourceConflictException, IOException, PermissionBackendException {
|
||||||
PermissionBackendException {
|
|
||||||
validate(ctx);
|
validate(ctx);
|
||||||
ctx.addRefUpdate(ObjectId.zeroId(), commitId, getPatchSetId().toRefName());
|
ctx.addRefUpdate(ObjectId.zeroId(), commitId, getPatchSetId().toRefName());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean updateChange(ChangeContext ctx)
|
public boolean updateChange(ChangeContext ctx) throws ResourceConflictException, IOException {
|
||||||
throws ResourceConflictException, StorageException, IOException {
|
|
||||||
change = ctx.getChange();
|
change = ctx.getChange();
|
||||||
ChangeUpdate update = ctx.getUpdate(psId);
|
ChangeUpdate update = ctx.getUpdate(psId);
|
||||||
update.setSubjectForCommit("Create patch set " + psId.get());
|
update.setSubjectForCommit("Create patch set " + psId.get());
|
||||||
@@ -271,8 +268,7 @@ public class PatchSetInserter implements BatchUpdateOp {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private void validate(RepoContext ctx)
|
private void validate(RepoContext ctx)
|
||||||
throws AuthException, ResourceConflictException, IOException, PermissionBackendException,
|
throws AuthException, ResourceConflictException, IOException, PermissionBackendException {
|
||||||
StorageException {
|
|
||||||
// Not allowed to create a new patch set if the current patch set is locked.
|
// Not allowed to create a new patch set if the current patch set is locked.
|
||||||
psUtil.checkPatchSetNotLocked(origNotes);
|
psUtil.checkPatchSetNotLocked(origNotes);
|
||||||
|
|
||||||
|
@@ -14,7 +14,6 @@
|
|||||||
|
|
||||||
package com.google.gerrit.server.change;
|
package com.google.gerrit.server.change;
|
||||||
|
|
||||||
import com.google.gerrit.exceptions.StorageException;
|
|
||||||
import com.google.gerrit.extensions.restapi.BadRequestException;
|
import com.google.gerrit.extensions.restapi.BadRequestException;
|
||||||
import com.google.gerrit.extensions.restapi.ResourceConflictException;
|
import com.google.gerrit.extensions.restapi.ResourceConflictException;
|
||||||
import com.google.gerrit.reviewdb.client.PatchSet;
|
import com.google.gerrit.reviewdb.client.PatchSet;
|
||||||
@@ -38,7 +37,7 @@ public class PureRevert {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public boolean get(ChangeNotes notes, Optional<String> claimedOriginal)
|
public boolean get(ChangeNotes notes, Optional<String> claimedOriginal)
|
||||||
throws StorageException, IOException, BadRequestException, ResourceConflictException {
|
throws IOException, BadRequestException, ResourceConflictException {
|
||||||
PatchSet currentPatchSet = notes.getCurrentPatchSet();
|
PatchSet currentPatchSet = notes.getCurrentPatchSet();
|
||||||
if (currentPatchSet == null) {
|
if (currentPatchSet == null) {
|
||||||
throw new ResourceConflictException("current revision is missing");
|
throw new ResourceConflictException("current revision is missing");
|
||||||
|
@@ -16,7 +16,6 @@ package com.google.gerrit.server.change;
|
|||||||
|
|
||||||
import static com.google.common.base.Preconditions.checkState;
|
import static com.google.common.base.Preconditions.checkState;
|
||||||
|
|
||||||
import com.google.gerrit.exceptions.StorageException;
|
|
||||||
import com.google.gerrit.extensions.restapi.MergeConflictException;
|
import com.google.gerrit.extensions.restapi.MergeConflictException;
|
||||||
import com.google.gerrit.extensions.restapi.ResourceConflictException;
|
import com.google.gerrit.extensions.restapi.ResourceConflictException;
|
||||||
import com.google.gerrit.extensions.restapi.RestApiException;
|
import com.google.gerrit.extensions.restapi.RestApiException;
|
||||||
@@ -149,7 +148,7 @@ public class RebaseChangeOp implements BatchUpdateOp {
|
|||||||
@Override
|
@Override
|
||||||
public void updateRepo(RepoContext ctx)
|
public void updateRepo(RepoContext ctx)
|
||||||
throws MergeConflictException, InvalidChangeOperationException, RestApiException, IOException,
|
throws MergeConflictException, InvalidChangeOperationException, RestApiException, IOException,
|
||||||
StorageException, NoSuchChangeException, PermissionBackendException {
|
NoSuchChangeException, PermissionBackendException {
|
||||||
// Ok that originalPatchSet was not read in a transaction, since we just
|
// Ok that originalPatchSet was not read in a transaction, since we just
|
||||||
// need its revision.
|
// need its revision.
|
||||||
RevId oldRev = originalPatchSet.getRevision();
|
RevId oldRev = originalPatchSet.getRevision();
|
||||||
@@ -213,15 +212,14 @@ public class RebaseChangeOp implements BatchUpdateOp {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean updateChange(ChangeContext ctx)
|
public boolean updateChange(ChangeContext ctx) throws ResourceConflictException, IOException {
|
||||||
throws ResourceConflictException, StorageException, IOException {
|
|
||||||
boolean ret = patchSetInserter.updateChange(ctx);
|
boolean ret = patchSetInserter.updateChange(ctx);
|
||||||
rebasedPatchSet = patchSetInserter.getPatchSet();
|
rebasedPatchSet = patchSetInserter.getPatchSet();
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void postUpdate(Context ctx) throws StorageException {
|
public void postUpdate(Context ctx) {
|
||||||
patchSetInserter.postUpdate(ctx);
|
patchSetInserter.postUpdate(ctx);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -83,7 +83,7 @@ public class RebaseUtil {
|
|||||||
public abstract PatchSet patchSet();
|
public abstract PatchSet patchSet();
|
||||||
}
|
}
|
||||||
|
|
||||||
public Base parseBase(RevisionResource rsrc, String base) throws StorageException {
|
public Base parseBase(RevisionResource rsrc, String base) {
|
||||||
// Try parsing the base as a ref string.
|
// Try parsing the base as a ref string.
|
||||||
PatchSet.Id basePatchSetId = PatchSet.Id.fromRef(base);
|
PatchSet.Id basePatchSetId = PatchSet.Id.fromRef(base);
|
||||||
if (basePatchSetId != null) {
|
if (basePatchSetId != null) {
|
||||||
@@ -119,7 +119,7 @@ public class RebaseUtil {
|
|||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
private ChangeNotes notesFor(RevisionResource rsrc, Change.Id id) throws StorageException {
|
private ChangeNotes notesFor(RevisionResource rsrc, Change.Id id) {
|
||||||
if (rsrc.getChange().getId().equals(id)) {
|
if (rsrc.getChange().getId().equals(id)) {
|
||||||
return rsrc.getNotes();
|
return rsrc.getNotes();
|
||||||
}
|
}
|
||||||
@@ -139,11 +139,10 @@ public class RebaseUtil {
|
|||||||
* @return the commit onto which the patch set should be rebased.
|
* @return the commit onto which the patch set should be rebased.
|
||||||
* @throws RestApiException if rebase is not possible.
|
* @throws RestApiException if rebase is not possible.
|
||||||
* @throws IOException if accessing the repository fails.
|
* @throws IOException if accessing the repository fails.
|
||||||
* @throws StorageException if accessing the database fails.
|
|
||||||
*/
|
*/
|
||||||
public ObjectId findBaseRevision(
|
public ObjectId findBaseRevision(
|
||||||
PatchSet patchSet, Branch.NameKey destBranch, Repository git, RevWalk rw)
|
PatchSet patchSet, Branch.NameKey destBranch, Repository git, RevWalk rw)
|
||||||
throws RestApiException, IOException, StorageException {
|
throws RestApiException, IOException {
|
||||||
String baseRev = null;
|
String baseRev = null;
|
||||||
RevCommit commit = rw.parseCommit(ObjectId.fromString(patchSet.getRevision().get()));
|
RevCommit commit = rw.parseCommit(ObjectId.fromString(patchSet.getRevision().get()));
|
||||||
|
|
||||||
|
@@ -31,7 +31,6 @@ import com.google.common.collect.Streams;
|
|||||||
import com.google.common.flogger.FluentLogger;
|
import com.google.common.flogger.FluentLogger;
|
||||||
import com.google.gerrit.common.Nullable;
|
import com.google.gerrit.common.Nullable;
|
||||||
import com.google.gerrit.common.data.GroupDescription;
|
import com.google.gerrit.common.data.GroupDescription;
|
||||||
import com.google.gerrit.exceptions.StorageException;
|
|
||||||
import com.google.gerrit.extensions.api.changes.AddReviewerInput;
|
import com.google.gerrit.extensions.api.changes.AddReviewerInput;
|
||||||
import com.google.gerrit.extensions.api.changes.AddReviewerResult;
|
import com.google.gerrit.extensions.api.changes.AddReviewerResult;
|
||||||
import com.google.gerrit.extensions.api.changes.NotifyHandling;
|
import com.google.gerrit.extensions.api.changes.NotifyHandling;
|
||||||
@@ -188,14 +187,13 @@ public class ReviewerAdder {
|
|||||||
* @return handle describing the addition operation. If the {@code op} field is present, this
|
* @return handle describing the addition operation. If the {@code op} field is present, this
|
||||||
* operation may be added to a {@code BatchUpdate}. Otherwise, the {@code error} field
|
* operation may be added to a {@code BatchUpdate}. Otherwise, the {@code error} field
|
||||||
* contains information about an error that occurred
|
* contains information about an error that occurred
|
||||||
* @throws StorageException
|
|
||||||
* @throws IOException
|
* @throws IOException
|
||||||
* @throws PermissionBackendException
|
* @throws PermissionBackendException
|
||||||
* @throws ConfigInvalidException
|
* @throws ConfigInvalidException
|
||||||
*/
|
*/
|
||||||
public ReviewerAddition prepare(
|
public ReviewerAddition prepare(
|
||||||
ChangeNotes notes, CurrentUser user, AddReviewerInput input, boolean allowGroup)
|
ChangeNotes notes, CurrentUser user, AddReviewerInput input, boolean allowGroup)
|
||||||
throws StorageException, IOException, PermissionBackendException, ConfigInvalidException {
|
throws IOException, PermissionBackendException, ConfigInvalidException {
|
||||||
requireNonNull(input.reviewer);
|
requireNonNull(input.reviewer);
|
||||||
boolean confirmed = input.confirmed();
|
boolean confirmed = input.confirmed();
|
||||||
boolean allowByEmail =
|
boolean allowByEmail =
|
||||||
@@ -245,7 +243,7 @@ public class ReviewerAdder {
|
|||||||
@Nullable
|
@Nullable
|
||||||
private ReviewerAddition addByAccountId(
|
private ReviewerAddition addByAccountId(
|
||||||
AddReviewerInput input, ChangeNotes notes, CurrentUser user)
|
AddReviewerInput input, ChangeNotes notes, CurrentUser user)
|
||||||
throws StorageException, PermissionBackendException, IOException, ConfigInvalidException {
|
throws PermissionBackendException, IOException, ConfigInvalidException {
|
||||||
IdentifiedUser reviewerUser;
|
IdentifiedUser reviewerUser;
|
||||||
boolean exactMatchFound = false;
|
boolean exactMatchFound = false;
|
||||||
try {
|
try {
|
||||||
@@ -449,7 +447,7 @@ public class ReviewerAdder {
|
|||||||
: ImmutableSet.of();
|
: ImmutableSet.of();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void gatherResults(ChangeData cd) throws StorageException, PermissionBackendException {
|
public void gatherResults(ChangeData cd) throws PermissionBackendException {
|
||||||
checkState(op != null, "addition did not result in an update op");
|
checkState(op != null, "addition did not result in an update op");
|
||||||
checkState(op.getResult() != null, "op did not return a result");
|
checkState(op.getResult() != null, "op did not return a result");
|
||||||
|
|
||||||
@@ -510,7 +508,7 @@ public class ReviewerAdder {
|
|||||||
CurrentUser user,
|
CurrentUser user,
|
||||||
Iterable<? extends AddReviewerInput> inputs,
|
Iterable<? extends AddReviewerInput> inputs,
|
||||||
boolean allowGroup)
|
boolean allowGroup)
|
||||||
throws StorageException, IOException, PermissionBackendException, ConfigInvalidException {
|
throws IOException, PermissionBackendException, ConfigInvalidException {
|
||||||
// Process CC ops before reviewer ops, so a user that appears in both lists ends up as a
|
// Process CC ops before reviewer ops, so a user that appears in both lists ends up as a
|
||||||
// reviewer; the last call to ChangeUpdate#putReviewer wins. This can happen if the caller
|
// reviewer; the last call to ChangeUpdate#putReviewer wins. This can happen if the caller
|
||||||
// specifies the same string twice, or less obviously if they specify multiple groups with
|
// specifies the same string twice, or less obviously if they specify multiple groups with
|
||||||
@@ -558,7 +556,7 @@ public class ReviewerAdder {
|
|||||||
// We never call updateRepo on the addition ops, which is only ok because it's a no-op.
|
// We never call updateRepo on the addition ops, which is only ok because it's a no-op.
|
||||||
|
|
||||||
public void updateChange(ChangeContext ctx, PatchSet patchSet)
|
public void updateChange(ChangeContext ctx, PatchSet patchSet)
|
||||||
throws StorageException, RestApiException, IOException {
|
throws RestApiException, IOException {
|
||||||
for (ReviewerAddition addition : additions()) {
|
for (ReviewerAddition addition : additions()) {
|
||||||
addition.op.setPatchSet(patchSet);
|
addition.op.setPatchSet(patchSet);
|
||||||
addition.op.updateChange(ctx);
|
addition.op.updateChange(ctx);
|
||||||
|
@@ -21,7 +21,6 @@ import com.google.common.collect.Lists;
|
|||||||
import com.google.gerrit.common.data.LabelType;
|
import com.google.gerrit.common.data.LabelType;
|
||||||
import com.google.gerrit.common.data.LabelTypes;
|
import com.google.gerrit.common.data.LabelTypes;
|
||||||
import com.google.gerrit.common.data.SubmitRecord;
|
import com.google.gerrit.common.data.SubmitRecord;
|
||||||
import com.google.gerrit.exceptions.StorageException;
|
|
||||||
import com.google.gerrit.extensions.api.changes.ReviewerInfo;
|
import com.google.gerrit.extensions.api.changes.ReviewerInfo;
|
||||||
import com.google.gerrit.extensions.restapi.AuthException;
|
import com.google.gerrit.extensions.restapi.AuthException;
|
||||||
import com.google.gerrit.mail.Address;
|
import com.google.gerrit.mail.Address;
|
||||||
@@ -65,7 +64,7 @@ public class ReviewerJson {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public List<ReviewerInfo> format(Collection<ReviewerResource> rsrcs)
|
public List<ReviewerInfo> format(Collection<ReviewerResource> rsrcs)
|
||||||
throws StorageException, PermissionBackendException {
|
throws PermissionBackendException {
|
||||||
List<ReviewerInfo> infos = Lists.newArrayListWithCapacity(rsrcs.size());
|
List<ReviewerInfo> infos = Lists.newArrayListWithCapacity(rsrcs.size());
|
||||||
AccountLoader loader = accountLoaderFactory.create(true);
|
AccountLoader loader = accountLoaderFactory.create(true);
|
||||||
ChangeData cd = null;
|
ChangeData cd = null;
|
||||||
@@ -88,13 +87,12 @@ public class ReviewerJson {
|
|||||||
return infos;
|
return infos;
|
||||||
}
|
}
|
||||||
|
|
||||||
public List<ReviewerInfo> format(ReviewerResource rsrc)
|
public List<ReviewerInfo> format(ReviewerResource rsrc) throws PermissionBackendException {
|
||||||
throws StorageException, PermissionBackendException {
|
|
||||||
return format(ImmutableList.of(rsrc));
|
return format(ImmutableList.of(rsrc));
|
||||||
}
|
}
|
||||||
|
|
||||||
public ReviewerInfo format(ReviewerInfo out, Account.Id reviewerAccountId, ChangeData cd)
|
public ReviewerInfo format(ReviewerInfo out, Account.Id reviewerAccountId, ChangeData cd)
|
||||||
throws StorageException, PermissionBackendException {
|
throws PermissionBackendException {
|
||||||
PatchSet.Id psId = cd.change().currentPatchSetId();
|
PatchSet.Id psId = cd.change().currentPatchSetId();
|
||||||
return format(
|
return format(
|
||||||
out,
|
out,
|
||||||
@@ -108,7 +106,7 @@ public class ReviewerJson {
|
|||||||
Account.Id reviewerAccountId,
|
Account.Id reviewerAccountId,
|
||||||
ChangeData cd,
|
ChangeData cd,
|
||||||
Iterable<PatchSetApproval> approvals)
|
Iterable<PatchSetApproval> approvals)
|
||||||
throws StorageException, PermissionBackendException {
|
throws PermissionBackendException {
|
||||||
LabelTypes labelTypes = cd.getLabelTypes();
|
LabelTypes labelTypes = cd.getLabelTypes();
|
||||||
|
|
||||||
out.approvals = new TreeMap<>(labelTypes.nameComparator());
|
out.approvals = new TreeMap<>(labelTypes.nameComparator());
|
||||||
|
@@ -32,7 +32,6 @@ import com.google.common.collect.ImmutableSet;
|
|||||||
import com.google.common.collect.Sets;
|
import com.google.common.collect.Sets;
|
||||||
import com.google.common.flogger.FluentLogger;
|
import com.google.common.flogger.FluentLogger;
|
||||||
import com.google.gerrit.common.Nullable;
|
import com.google.gerrit.common.Nullable;
|
||||||
import com.google.gerrit.exceptions.StorageException;
|
|
||||||
import com.google.gerrit.extensions.client.ListChangesOption;
|
import com.google.gerrit.extensions.client.ListChangesOption;
|
||||||
import com.google.gerrit.extensions.common.ChangeInfo;
|
import com.google.gerrit.extensions.common.ChangeInfo;
|
||||||
import com.google.gerrit.extensions.common.CommitInfo;
|
import com.google.gerrit.extensions.common.CommitInfo;
|
||||||
@@ -155,8 +154,7 @@ public class RevisionJson {
|
|||||||
* depending on the options provided when constructing this instance.
|
* depending on the options provided when constructing this instance.
|
||||||
*/
|
*/
|
||||||
public RevisionInfo getRevisionInfo(ChangeData cd, PatchSet in)
|
public RevisionInfo getRevisionInfo(ChangeData cd, PatchSet in)
|
||||||
throws PatchListNotAvailableException, GpgException, StorageException, IOException,
|
throws PatchListNotAvailableException, GpgException, IOException, PermissionBackendException {
|
||||||
PermissionBackendException {
|
|
||||||
AccountLoader accountLoader = accountLoaderFactory.create(has(DETAILED_ACCOUNTS));
|
AccountLoader accountLoader = accountLoaderFactory.create(has(DETAILED_ACCOUNTS));
|
||||||
try (Repository repo = openRepoIfNecessary(cd.project());
|
try (Repository repo = openRepoIfNecessary(cd.project());
|
||||||
RevWalk rw = newRevWalk(repo)) {
|
RevWalk rw = newRevWalk(repo)) {
|
||||||
@@ -213,8 +211,7 @@ public class RevisionJson {
|
|||||||
Map<PatchSet.Id, PatchSet> map,
|
Map<PatchSet.Id, PatchSet> map,
|
||||||
Optional<PatchSet.Id> limitToPsId,
|
Optional<PatchSet.Id> limitToPsId,
|
||||||
ChangeInfo changeInfo)
|
ChangeInfo changeInfo)
|
||||||
throws PatchListNotAvailableException, GpgException, StorageException, IOException,
|
throws PatchListNotAvailableException, GpgException, IOException, PermissionBackendException {
|
||||||
PermissionBackendException {
|
|
||||||
Map<String, RevisionInfo> res = new LinkedHashMap<>();
|
Map<String, RevisionInfo> res = new LinkedHashMap<>();
|
||||||
try (Repository repo = openRepoIfNecessary(cd.project());
|
try (Repository repo = openRepoIfNecessary(cd.project());
|
||||||
RevWalk rw = newRevWalk(repo)) {
|
RevWalk rw = newRevWalk(repo)) {
|
||||||
@@ -239,7 +236,7 @@ public class RevisionJson {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private Map<String, FetchInfo> makeFetchMap(ChangeData cd, PatchSet in)
|
private Map<String, FetchInfo> makeFetchMap(ChangeData cd, PatchSet in)
|
||||||
throws PermissionBackendException, StorageException, IOException {
|
throws PermissionBackendException, IOException {
|
||||||
Map<String, FetchInfo> r = new LinkedHashMap<>();
|
Map<String, FetchInfo> r = new LinkedHashMap<>();
|
||||||
for (Extension<DownloadScheme> e : downloadSchemes) {
|
for (Extension<DownloadScheme> e : downloadSchemes) {
|
||||||
String schemeName = e.getExportName();
|
String schemeName = e.getExportName();
|
||||||
@@ -275,8 +272,7 @@ public class RevisionJson {
|
|||||||
@Nullable RevWalk rw,
|
@Nullable RevWalk rw,
|
||||||
boolean fillCommit,
|
boolean fillCommit,
|
||||||
@Nullable ChangeInfo changeInfo)
|
@Nullable ChangeInfo changeInfo)
|
||||||
throws PatchListNotAvailableException, GpgException, StorageException, IOException,
|
throws PatchListNotAvailableException, GpgException, IOException, PermissionBackendException {
|
||||||
PermissionBackendException {
|
|
||||||
Change c = cd.change();
|
Change c = cd.change();
|
||||||
RevisionInfo out = new RevisionInfo();
|
RevisionInfo out = new RevisionInfo();
|
||||||
out.isCurrent = in.getId().equals(c.currentPatchSetId());
|
out.isCurrent = in.getId().equals(c.currentPatchSetId());
|
||||||
@@ -350,14 +346,13 @@ public class RevisionJson {
|
|||||||
* lazyload}.
|
* lazyload}.
|
||||||
*/
|
*/
|
||||||
private PermissionBackend.ForChange permissionBackendForChange(
|
private PermissionBackend.ForChange permissionBackendForChange(
|
||||||
PermissionBackend.WithUser withUser, ChangeData cd) throws StorageException {
|
PermissionBackend.WithUser withUser, ChangeData cd) {
|
||||||
return lazyLoad
|
return lazyLoad
|
||||||
? withUser.change(cd)
|
? withUser.change(cd)
|
||||||
: withUser.indexedChange(cd, notesFactory.createFromIndexedChange(cd.change()));
|
: withUser.indexedChange(cd, notesFactory.createFromIndexedChange(cd.change()));
|
||||||
}
|
}
|
||||||
|
|
||||||
private boolean isWorldReadable(ChangeData cd)
|
private boolean isWorldReadable(ChangeData cd) throws PermissionBackendException, IOException {
|
||||||
throws StorageException, PermissionBackendException, IOException {
|
|
||||||
try {
|
try {
|
||||||
permissionBackendForChange(permissionBackend.user(anonymous), cd)
|
permissionBackendForChange(permissionBackend.user(anonymous), cd)
|
||||||
.check(ChangePermission.READ);
|
.check(ChangePermission.READ);
|
||||||
|
@@ -17,7 +17,6 @@ package com.google.gerrit.server.change;
|
|||||||
import static java.util.Objects.requireNonNull;
|
import static java.util.Objects.requireNonNull;
|
||||||
|
|
||||||
import com.google.common.flogger.FluentLogger;
|
import com.google.common.flogger.FluentLogger;
|
||||||
import com.google.gerrit.exceptions.StorageException;
|
|
||||||
import com.google.gerrit.extensions.restapi.ResourceConflictException;
|
import com.google.gerrit.extensions.restapi.ResourceConflictException;
|
||||||
import com.google.gerrit.extensions.restapi.RestApiException;
|
import com.google.gerrit.extensions.restapi.RestApiException;
|
||||||
import com.google.gerrit.reviewdb.client.Change;
|
import com.google.gerrit.reviewdb.client.Change;
|
||||||
@@ -74,7 +73,7 @@ public class SetAssigneeOp implements BatchUpdateOp {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean updateChange(ChangeContext ctx) throws StorageException, RestApiException {
|
public boolean updateChange(ChangeContext ctx) throws RestApiException {
|
||||||
change = ctx.getChange();
|
change = ctx.getChange();
|
||||||
if (newAssignee.getAccountId().equals(change.getAssignee())) {
|
if (newAssignee.getAccountId().equals(change.getAssignee())) {
|
||||||
return false;
|
return false;
|
||||||
@@ -117,7 +116,7 @@ public class SetAssigneeOp implements BatchUpdateOp {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void postUpdate(Context ctx) throws StorageException {
|
public void postUpdate(Context ctx) {
|
||||||
try {
|
try {
|
||||||
SetAssigneeSender cm =
|
SetAssigneeSender cm =
|
||||||
setAssigneeSenderFactory.create(
|
setAssigneeSenderFactory.create(
|
||||||
|
@@ -21,7 +21,6 @@ import com.google.common.base.Joiner;
|
|||||||
import com.google.common.collect.ImmutableSortedSet;
|
import com.google.common.collect.ImmutableSortedSet;
|
||||||
import com.google.common.collect.Ordering;
|
import com.google.common.collect.Ordering;
|
||||||
import com.google.gerrit.common.Nullable;
|
import com.google.gerrit.common.Nullable;
|
||||||
import com.google.gerrit.exceptions.StorageException;
|
|
||||||
import com.google.gerrit.extensions.api.changes.HashtagsInput;
|
import com.google.gerrit.extensions.api.changes.HashtagsInput;
|
||||||
import com.google.gerrit.extensions.restapi.AuthException;
|
import com.google.gerrit.extensions.restapi.AuthException;
|
||||||
import com.google.gerrit.extensions.restapi.BadRequestException;
|
import com.google.gerrit.extensions.restapi.BadRequestException;
|
||||||
@@ -82,8 +81,7 @@ public class SetHashtagsOp implements BatchUpdateOp {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean updateChange(ChangeContext ctx)
|
public boolean updateChange(ChangeContext ctx)
|
||||||
throws AuthException, BadRequestException, MethodNotAllowedException, StorageException,
|
throws AuthException, BadRequestException, MethodNotAllowedException, IOException {
|
||||||
IOException {
|
|
||||||
if (input == null || (input.add == null && input.remove == null)) {
|
if (input == null || (input.add == null && input.remove == null)) {
|
||||||
updatedHashtags = ImmutableSortedSet.of();
|
updatedHashtags = ImmutableSortedSet.of();
|
||||||
return false;
|
return false;
|
||||||
@@ -146,7 +144,7 @@ public class SetHashtagsOp implements BatchUpdateOp {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void postUpdate(Context ctx) throws StorageException {
|
public void postUpdate(Context ctx) {
|
||||||
if (updated() && fireEvent) {
|
if (updated() && fireEvent) {
|
||||||
hashtagsEdited.fire(
|
hashtagsEdited.fire(
|
||||||
change, ctx.getAccount(), updatedHashtags, toAdd, toRemove, ctx.getWhen());
|
change, ctx.getAccount(), updatedHashtags, toAdd, toRemove, ctx.getWhen());
|
||||||
|
@@ -16,7 +16,6 @@ package com.google.gerrit.server.change;
|
|||||||
|
|
||||||
import com.google.common.base.Strings;
|
import com.google.common.base.Strings;
|
||||||
import com.google.gerrit.common.Nullable;
|
import com.google.gerrit.common.Nullable;
|
||||||
import com.google.gerrit.exceptions.StorageException;
|
|
||||||
import com.google.gerrit.extensions.restapi.BadRequestException;
|
import com.google.gerrit.extensions.restapi.BadRequestException;
|
||||||
import com.google.gerrit.extensions.restapi.ResourceConflictException;
|
import com.google.gerrit.extensions.restapi.ResourceConflictException;
|
||||||
import com.google.gerrit.reviewdb.client.Change;
|
import com.google.gerrit.reviewdb.client.Change;
|
||||||
@@ -75,7 +74,7 @@ public class SetPrivateOp implements BatchUpdateOp {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean updateChange(ChangeContext ctx)
|
public boolean updateChange(ChangeContext ctx)
|
||||||
throws ResourceConflictException, StorageException, BadRequestException {
|
throws ResourceConflictException, BadRequestException {
|
||||||
change = ctx.getChange();
|
change = ctx.getChange();
|
||||||
if (ctx.getChange().isPrivate() == isPrivate) {
|
if (ctx.getChange().isPrivate() == isPrivate) {
|
||||||
// No-op
|
// No-op
|
||||||
|
@@ -98,7 +98,7 @@ public class WalkSorter {
|
|||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Iterable<PatchSetData> sort(Iterable<ChangeData> in) throws StorageException, IOException {
|
public Iterable<PatchSetData> sort(Iterable<ChangeData> in) throws IOException {
|
||||||
ListMultimap<Project.NameKey, ChangeData> byProject =
|
ListMultimap<Project.NameKey, ChangeData> byProject =
|
||||||
MultimapBuilder.hashKeys().arrayListValues().build();
|
MultimapBuilder.hashKeys().arrayListValues().build();
|
||||||
for (ChangeData cd : in) {
|
for (ChangeData cd : in) {
|
||||||
@@ -114,7 +114,7 @@ public class WalkSorter {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private List<PatchSetData> sortProject(Project.NameKey project, Collection<ChangeData> in)
|
private List<PatchSetData> sortProject(Project.NameKey project, Collection<ChangeData> in)
|
||||||
throws StorageException, IOException {
|
throws IOException {
|
||||||
try (Repository repo = repoManager.openRepository(project);
|
try (Repository repo = repoManager.openRepository(project);
|
||||||
RevWalk rw = new RevWalk(repo)) {
|
RevWalk rw = new RevWalk(repo)) {
|
||||||
rw.setRetainBody(retainBody);
|
rw.setRetainBody(retainBody);
|
||||||
@@ -217,7 +217,7 @@ public class WalkSorter {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private ListMultimap<RevCommit, PatchSetData> byCommit(RevWalk rw, Collection<ChangeData> in)
|
private ListMultimap<RevCommit, PatchSetData> byCommit(RevWalk rw, Collection<ChangeData> in)
|
||||||
throws StorageException, IOException {
|
throws IOException {
|
||||||
ListMultimap<RevCommit, PatchSetData> byCommit =
|
ListMultimap<RevCommit, PatchSetData> byCommit =
|
||||||
MultimapBuilder.hashKeys(in.size()).arrayListValues(1).build();
|
MultimapBuilder.hashKeys(in.size()).arrayListValues(1).build();
|
||||||
for (ChangeData cd : in) {
|
for (ChangeData cd : in) {
|
||||||
|
@@ -17,7 +17,6 @@ package com.google.gerrit.server.change;
|
|||||||
import com.google.common.base.Strings;
|
import com.google.common.base.Strings;
|
||||||
import com.google.common.collect.ImmutableList;
|
import com.google.common.collect.ImmutableList;
|
||||||
import com.google.gerrit.common.Nullable;
|
import com.google.gerrit.common.Nullable;
|
||||||
import com.google.gerrit.exceptions.StorageException;
|
|
||||||
import com.google.gerrit.extensions.api.changes.NotifyHandling;
|
import com.google.gerrit.extensions.api.changes.NotifyHandling;
|
||||||
import com.google.gerrit.reviewdb.client.Change;
|
import com.google.gerrit.reviewdb.client.Change;
|
||||||
import com.google.gerrit.reviewdb.client.ChangeMessage;
|
import com.google.gerrit.reviewdb.client.ChangeMessage;
|
||||||
@@ -85,7 +84,7 @@ public class WorkInProgressOp implements BatchUpdateOp {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean updateChange(ChangeContext ctx) throws StorageException {
|
public boolean updateChange(ChangeContext ctx) {
|
||||||
change = ctx.getChange();
|
change = ctx.getChange();
|
||||||
notes = ctx.getNotes();
|
notes = ctx.getNotes();
|
||||||
ps = psUtil.get(ctx.getNotes(), change.currentPatchSetId());
|
ps = psUtil.get(ctx.getNotes(), change.currentPatchSetId());
|
||||||
|
@@ -15,7 +15,6 @@
|
|||||||
package com.google.gerrit.server.edit;
|
package com.google.gerrit.server.edit;
|
||||||
|
|
||||||
import com.google.common.collect.ImmutableList;
|
import com.google.common.collect.ImmutableList;
|
||||||
import com.google.gerrit.exceptions.StorageException;
|
|
||||||
import com.google.gerrit.extensions.restapi.AuthException;
|
import com.google.gerrit.extensions.restapi.AuthException;
|
||||||
import com.google.gerrit.extensions.restapi.BadRequestException;
|
import com.google.gerrit.extensions.restapi.BadRequestException;
|
||||||
import com.google.gerrit.extensions.restapi.MergeConflictException;
|
import com.google.gerrit.extensions.restapi.MergeConflictException;
|
||||||
@@ -114,7 +113,7 @@ public class ChangeEditModifier {
|
|||||||
* @throws PermissionBackendException
|
* @throws PermissionBackendException
|
||||||
*/
|
*/
|
||||||
public void createEdit(Repository repository, ChangeNotes notes)
|
public void createEdit(Repository repository, ChangeNotes notes)
|
||||||
throws AuthException, IOException, InvalidChangeOperationException, StorageException,
|
throws AuthException, IOException, InvalidChangeOperationException,
|
||||||
PermissionBackendException, ResourceConflictException {
|
PermissionBackendException, ResourceConflictException {
|
||||||
assertCanEdit(notes);
|
assertCanEdit(notes);
|
||||||
|
|
||||||
@@ -142,8 +141,8 @@ public class ChangeEditModifier {
|
|||||||
* @throws PermissionBackendException
|
* @throws PermissionBackendException
|
||||||
*/
|
*/
|
||||||
public void rebaseEdit(Repository repository, ChangeNotes notes)
|
public void rebaseEdit(Repository repository, ChangeNotes notes)
|
||||||
throws AuthException, InvalidChangeOperationException, IOException, StorageException,
|
throws AuthException, InvalidChangeOperationException, IOException, MergeConflictException,
|
||||||
MergeConflictException, PermissionBackendException, ResourceConflictException {
|
PermissionBackendException, ResourceConflictException {
|
||||||
assertCanEdit(notes);
|
assertCanEdit(notes);
|
||||||
|
|
||||||
Optional<ChangeEdit> optionalChangeEdit = lookupChangeEdit(notes);
|
Optional<ChangeEdit> optionalChangeEdit = lookupChangeEdit(notes);
|
||||||
@@ -207,7 +206,7 @@ public class ChangeEditModifier {
|
|||||||
* @throws BadRequestException if the commit message is malformed
|
* @throws BadRequestException if the commit message is malformed
|
||||||
*/
|
*/
|
||||||
public void modifyMessage(Repository repository, ChangeNotes notes, String newCommitMessage)
|
public void modifyMessage(Repository repository, ChangeNotes notes, String newCommitMessage)
|
||||||
throws AuthException, IOException, UnchangedCommitMessageException, StorageException,
|
throws AuthException, IOException, UnchangedCommitMessageException,
|
||||||
PermissionBackendException, BadRequestException, ResourceConflictException {
|
PermissionBackendException, BadRequestException, ResourceConflictException {
|
||||||
assertCanEdit(notes);
|
assertCanEdit(notes);
|
||||||
newCommitMessage = CommitMessageUtil.checkAndSanitizeCommitMessage(newCommitMessage);
|
newCommitMessage = CommitMessageUtil.checkAndSanitizeCommitMessage(newCommitMessage);
|
||||||
@@ -250,7 +249,7 @@ public class ChangeEditModifier {
|
|||||||
*/
|
*/
|
||||||
public void modifyFile(
|
public void modifyFile(
|
||||||
Repository repository, ChangeNotes notes, String filePath, RawInput newContent)
|
Repository repository, ChangeNotes notes, String filePath, RawInput newContent)
|
||||||
throws AuthException, InvalidChangeOperationException, IOException, StorageException,
|
throws AuthException, InvalidChangeOperationException, IOException,
|
||||||
PermissionBackendException, ResourceConflictException {
|
PermissionBackendException, ResourceConflictException {
|
||||||
modifyTree(repository, notes, new ChangeFileContentModification(filePath, newContent));
|
modifyTree(repository, notes, new ChangeFileContentModification(filePath, newContent));
|
||||||
}
|
}
|
||||||
@@ -268,7 +267,7 @@ public class ChangeEditModifier {
|
|||||||
* @throws ResourceConflictException if the project state does not permit the operation
|
* @throws ResourceConflictException if the project state does not permit the operation
|
||||||
*/
|
*/
|
||||||
public void deleteFile(Repository repository, ChangeNotes notes, String file)
|
public void deleteFile(Repository repository, ChangeNotes notes, String file)
|
||||||
throws AuthException, InvalidChangeOperationException, IOException, StorageException,
|
throws AuthException, InvalidChangeOperationException, IOException,
|
||||||
PermissionBackendException, ResourceConflictException {
|
PermissionBackendException, ResourceConflictException {
|
||||||
modifyTree(repository, notes, new DeleteFileModification(file));
|
modifyTree(repository, notes, new DeleteFileModification(file));
|
||||||
}
|
}
|
||||||
@@ -289,7 +288,7 @@ public class ChangeEditModifier {
|
|||||||
*/
|
*/
|
||||||
public void renameFile(
|
public void renameFile(
|
||||||
Repository repository, ChangeNotes notes, String currentFilePath, String newFilePath)
|
Repository repository, ChangeNotes notes, String currentFilePath, String newFilePath)
|
||||||
throws AuthException, InvalidChangeOperationException, IOException, StorageException,
|
throws AuthException, InvalidChangeOperationException, IOException,
|
||||||
PermissionBackendException, ResourceConflictException {
|
PermissionBackendException, ResourceConflictException {
|
||||||
modifyTree(repository, notes, new RenameFileModification(currentFilePath, newFilePath));
|
modifyTree(repository, notes, new RenameFileModification(currentFilePath, newFilePath));
|
||||||
}
|
}
|
||||||
@@ -307,14 +306,14 @@ public class ChangeEditModifier {
|
|||||||
* @throws PermissionBackendException
|
* @throws PermissionBackendException
|
||||||
*/
|
*/
|
||||||
public void restoreFile(Repository repository, ChangeNotes notes, String file)
|
public void restoreFile(Repository repository, ChangeNotes notes, String file)
|
||||||
throws AuthException, InvalidChangeOperationException, IOException, StorageException,
|
throws AuthException, InvalidChangeOperationException, IOException,
|
||||||
PermissionBackendException, ResourceConflictException {
|
PermissionBackendException, ResourceConflictException {
|
||||||
modifyTree(repository, notes, new RestoreFileModification(file));
|
modifyTree(repository, notes, new RestoreFileModification(file));
|
||||||
}
|
}
|
||||||
|
|
||||||
private void modifyTree(
|
private void modifyTree(
|
||||||
Repository repository, ChangeNotes notes, TreeModification treeModification)
|
Repository repository, ChangeNotes notes, TreeModification treeModification)
|
||||||
throws AuthException, IOException, StorageException, InvalidChangeOperationException,
|
throws AuthException, IOException, InvalidChangeOperationException,
|
||||||
PermissionBackendException, ResourceConflictException {
|
PermissionBackendException, ResourceConflictException {
|
||||||
assertCanEdit(notes);
|
assertCanEdit(notes);
|
||||||
|
|
||||||
@@ -360,7 +359,7 @@ public class ChangeEditModifier {
|
|||||||
PatchSet patchSet,
|
PatchSet patchSet,
|
||||||
List<TreeModification> treeModifications)
|
List<TreeModification> treeModifications)
|
||||||
throws AuthException, IOException, InvalidChangeOperationException, MergeConflictException,
|
throws AuthException, IOException, InvalidChangeOperationException, MergeConflictException,
|
||||||
StorageException, PermissionBackendException, ResourceConflictException {
|
PermissionBackendException, ResourceConflictException {
|
||||||
assertCanEdit(notes);
|
assertCanEdit(notes);
|
||||||
|
|
||||||
Optional<ChangeEdit> optionalChangeEdit = lookupChangeEdit(notes);
|
Optional<ChangeEdit> optionalChangeEdit = lookupChangeEdit(notes);
|
||||||
@@ -391,8 +390,7 @@ public class ChangeEditModifier {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private void assertCanEdit(ChangeNotes notes)
|
private void assertCanEdit(ChangeNotes notes)
|
||||||
throws AuthException, PermissionBackendException, IOException, ResourceConflictException,
|
throws AuthException, PermissionBackendException, IOException, ResourceConflictException {
|
||||||
StorageException {
|
|
||||||
if (!currentUser.get().isIdentifiedUser()) {
|
if (!currentUser.get().isIdentifiedUser()) {
|
||||||
throw new AuthException("Authentication required");
|
throw new AuthException("Authentication required");
|
||||||
}
|
}
|
||||||
@@ -442,13 +440,12 @@ public class ChangeEditModifier {
|
|||||||
return changeEditUtil.byChange(notes);
|
return changeEditUtil.byChange(notes);
|
||||||
}
|
}
|
||||||
|
|
||||||
private PatchSet getBasePatchSet(Optional<ChangeEdit> optionalChangeEdit, ChangeNotes notes)
|
private PatchSet getBasePatchSet(Optional<ChangeEdit> optionalChangeEdit, ChangeNotes notes) {
|
||||||
throws StorageException {
|
|
||||||
Optional<PatchSet> editBasePatchSet = optionalChangeEdit.map(ChangeEdit::getBasePatchSet);
|
Optional<PatchSet> editBasePatchSet = optionalChangeEdit.map(ChangeEdit::getBasePatchSet);
|
||||||
return editBasePatchSet.isPresent() ? editBasePatchSet.get() : lookupCurrentPatchSet(notes);
|
return editBasePatchSet.isPresent() ? editBasePatchSet.get() : lookupCurrentPatchSet(notes);
|
||||||
}
|
}
|
||||||
|
|
||||||
private PatchSet lookupCurrentPatchSet(ChangeNotes notes) throws StorageException {
|
private PatchSet lookupCurrentPatchSet(ChangeNotes notes) {
|
||||||
return patchSetUtil.current(notes);
|
return patchSetUtil.current(notes);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -146,7 +146,6 @@ public class ChangeEditUtil {
|
|||||||
* @param notify Notify handling that defines to whom email notifications should be sent after the
|
* @param notify Notify handling that defines to whom email notifications should be sent after the
|
||||||
* change edit is published.
|
* change edit is published.
|
||||||
* @throws IOException
|
* @throws IOException
|
||||||
* @throws StorageException
|
|
||||||
* @throws UpdateException
|
* @throws UpdateException
|
||||||
* @throws RestApiException
|
* @throws RestApiException
|
||||||
*/
|
*/
|
||||||
@@ -156,7 +155,7 @@ public class ChangeEditUtil {
|
|||||||
CurrentUser user,
|
CurrentUser user,
|
||||||
ChangeEdit edit,
|
ChangeEdit edit,
|
||||||
NotifyResolver.Result notify)
|
NotifyResolver.Result notify)
|
||||||
throws IOException, StorageException, RestApiException, UpdateException {
|
throws IOException, RestApiException, UpdateException {
|
||||||
Change change = edit.getChange();
|
Change change = edit.getChange();
|
||||||
try (Repository repo = gitManager.openRepository(change.getProject());
|
try (Repository repo = gitManager.openRepository(change.getProject());
|
||||||
ObjectInserter oi = repo.newObjectInserter();
|
ObjectInserter oi = repo.newObjectInserter();
|
||||||
@@ -210,9 +209,8 @@ public class ChangeEditUtil {
|
|||||||
*
|
*
|
||||||
* @param edit change edit to delete
|
* @param edit change edit to delete
|
||||||
* @throws IOException
|
* @throws IOException
|
||||||
* @throws StorageException
|
|
||||||
*/
|
*/
|
||||||
public void delete(ChangeEdit edit) throws IOException, StorageException {
|
public void delete(ChangeEdit edit) throws IOException {
|
||||||
Change change = edit.getChange();
|
Change change = edit.getChange();
|
||||||
try (Repository repo = gitManager.openRepository(change.getProject())) {
|
try (Repository repo = gitManager.openRepository(change.getProject())) {
|
||||||
deleteRef(repo, edit);
|
deleteRef(repo, edit);
|
||||||
|
@@ -15,7 +15,6 @@
|
|||||||
package com.google.gerrit.server.events;
|
package com.google.gerrit.server.events;
|
||||||
|
|
||||||
import com.google.common.flogger.FluentLogger;
|
import com.google.common.flogger.FluentLogger;
|
||||||
import com.google.gerrit.exceptions.StorageException;
|
|
||||||
import com.google.gerrit.extensions.registration.DynamicItem;
|
import com.google.gerrit.extensions.registration.DynamicItem;
|
||||||
import com.google.gerrit.extensions.restapi.AuthException;
|
import com.google.gerrit.extensions.restapi.AuthException;
|
||||||
import com.google.gerrit.lifecycle.LifecycleModule;
|
import com.google.gerrit.lifecycle.LifecycleModule;
|
||||||
@@ -77,8 +76,7 @@ public class EventBroker implements EventDispatcher {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void postEvent(Change change, ChangeEvent event)
|
public void postEvent(Change change, ChangeEvent event) throws PermissionBackendException {
|
||||||
throws StorageException, PermissionBackendException {
|
|
||||||
fireEvent(change, event);
|
fireEvent(change, event);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -94,7 +92,7 @@ public class EventBroker implements EventDispatcher {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void postEvent(Event event) throws StorageException, PermissionBackendException {
|
public void postEvent(Event event) throws PermissionBackendException {
|
||||||
fireEvent(event);
|
fireEvent(event);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -102,8 +100,7 @@ public class EventBroker implements EventDispatcher {
|
|||||||
unrestrictedListeners.runEach(l -> l.onEvent(event));
|
unrestrictedListeners.runEach(l -> l.onEvent(event));
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void fireEvent(Change change, ChangeEvent event)
|
protected void fireEvent(Change change, ChangeEvent event) throws PermissionBackendException {
|
||||||
throws StorageException, PermissionBackendException {
|
|
||||||
for (PluginSetEntryContext<UserScopedEventListener> c : listeners) {
|
for (PluginSetEntryContext<UserScopedEventListener> c : listeners) {
|
||||||
CurrentUser user = c.call(UserScopedEventListener::getUser);
|
CurrentUser user = c.call(UserScopedEventListener::getUser);
|
||||||
if (isVisibleTo(change, user)) {
|
if (isVisibleTo(change, user)) {
|
||||||
@@ -134,7 +131,7 @@ public class EventBroker implements EventDispatcher {
|
|||||||
fireEventForUnrestrictedListeners(event);
|
fireEventForUnrestrictedListeners(event);
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void fireEvent(Event event) throws StorageException, PermissionBackendException {
|
protected void fireEvent(Event event) throws PermissionBackendException {
|
||||||
for (PluginSetEntryContext<UserScopedEventListener> c : listeners) {
|
for (PluginSetEntryContext<UserScopedEventListener> c : listeners) {
|
||||||
CurrentUser user = c.call(UserScopedEventListener::getUser);
|
CurrentUser user = c.call(UserScopedEventListener::getUser);
|
||||||
if (isVisibleTo(event, user)) {
|
if (isVisibleTo(event, user)) {
|
||||||
@@ -158,8 +155,7 @@ public class EventBroker implements EventDispatcher {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
protected boolean isVisibleTo(Change change, CurrentUser user)
|
protected boolean isVisibleTo(Change change, CurrentUser user) throws PermissionBackendException {
|
||||||
throws StorageException, PermissionBackendException {
|
|
||||||
if (change == null) {
|
if (change == null) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@@ -193,8 +189,7 @@ public class EventBroker implements EventDispatcher {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
protected boolean isVisibleTo(Event event, CurrentUser user)
|
protected boolean isVisibleTo(Event event, CurrentUser user) throws PermissionBackendException {
|
||||||
throws StorageException, PermissionBackendException {
|
|
||||||
if (event instanceof RefEvent) {
|
if (event instanceof RefEvent) {
|
||||||
RefEvent refEvent = (RefEvent) event;
|
RefEvent refEvent = (RefEvent) event;
|
||||||
String ref = refEvent.getRefName();
|
String ref = refEvent.getRefName();
|
||||||
|
@@ -14,7 +14,6 @@
|
|||||||
|
|
||||||
package com.google.gerrit.server.events;
|
package com.google.gerrit.server.events;
|
||||||
|
|
||||||
import com.google.gerrit.exceptions.StorageException;
|
|
||||||
import com.google.gerrit.reviewdb.client.Branch;
|
import com.google.gerrit.reviewdb.client.Branch;
|
||||||
import com.google.gerrit.reviewdb.client.Change;
|
import com.google.gerrit.reviewdb.client.Change;
|
||||||
import com.google.gerrit.reviewdb.client.Project;
|
import com.google.gerrit.reviewdb.client.Project;
|
||||||
@@ -27,11 +26,9 @@ public interface EventDispatcher {
|
|||||||
*
|
*
|
||||||
* @param change The change that the event is related to
|
* @param change The change that the event is related to
|
||||||
* @param event The event to post
|
* @param event The event to post
|
||||||
* @throws StorageException on failure to post the event due to DB error
|
|
||||||
* @throws PermissionBackendException on failure of permission checks
|
* @throws PermissionBackendException on failure of permission checks
|
||||||
*/
|
*/
|
||||||
void postEvent(Change change, ChangeEvent event)
|
void postEvent(Change change, ChangeEvent event) throws PermissionBackendException;
|
||||||
throws StorageException, PermissionBackendException;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Post a stream event that is related to a branch
|
* Post a stream event that is related to a branch
|
||||||
@@ -57,8 +54,7 @@ public interface EventDispatcher {
|
|||||||
* specific postEvent methods for those use cases.
|
* specific postEvent methods for those use cases.
|
||||||
*
|
*
|
||||||
* @param event The event to post.
|
* @param event The event to post.
|
||||||
* @throws StorageException on failure to post the event due to DB error
|
|
||||||
* @throws PermissionBackendException on failure of permission checks
|
* @throws PermissionBackendException on failure of permission checks
|
||||||
*/
|
*/
|
||||||
void postEvent(Event event) throws StorageException, PermissionBackendException;
|
void postEvent(Event event) throws PermissionBackendException;
|
||||||
}
|
}
|
||||||
|
@@ -155,8 +155,7 @@ public class EventFactory {
|
|||||||
* @param notes
|
* @param notes
|
||||||
* @return object suitable for serialization to JSON
|
* @return object suitable for serialization to JSON
|
||||||
*/
|
*/
|
||||||
public ChangeAttribute asChangeAttribute(Change change, ChangeNotes notes)
|
public ChangeAttribute asChangeAttribute(Change change, ChangeNotes notes) {
|
||||||
throws StorageException {
|
|
||||||
ChangeAttribute a = asChangeAttribute(change);
|
ChangeAttribute a = asChangeAttribute(change);
|
||||||
Set<String> hashtags = notes.load().getHashtags();
|
Set<String> hashtags = notes.load().getHashtags();
|
||||||
if (!hashtags.isEmpty()) {
|
if (!hashtags.isEmpty()) {
|
||||||
@@ -201,7 +200,7 @@ public class EventFactory {
|
|||||||
* @param a
|
* @param a
|
||||||
* @param notes
|
* @param notes
|
||||||
*/
|
*/
|
||||||
public void addAllReviewers(ChangeAttribute a, ChangeNotes notes) throws StorageException {
|
public void addAllReviewers(ChangeAttribute a, ChangeNotes notes) {
|
||||||
Collection<Account.Id> reviewers = approvalsUtil.getReviewers(notes).all();
|
Collection<Account.Id> reviewers = approvalsUtil.getReviewers(notes).all();
|
||||||
if (!reviewers.isEmpty()) {
|
if (!reviewers.isEmpty()) {
|
||||||
a.allReviewers = Lists.newArrayListWithCapacity(reviewers.size());
|
a.allReviewers = Lists.newArrayListWithCapacity(reviewers.size());
|
||||||
@@ -285,7 +284,7 @@ public class EventFactory {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private void addDependsOn(RevWalk rw, ChangeAttribute ca, Change change, PatchSet currentPs)
|
private void addDependsOn(RevWalk rw, ChangeAttribute ca, Change change, PatchSet currentPs)
|
||||||
throws StorageException, IOException {
|
throws IOException {
|
||||||
RevCommit commit = rw.parseCommit(ObjectId.fromString(currentPs.getRevision().get()));
|
RevCommit commit = rw.parseCommit(ObjectId.fromString(currentPs.getRevision().get()));
|
||||||
final List<String> parentNames = new ArrayList<>(commit.getParentCount());
|
final List<String> parentNames = new ArrayList<>(commit.getParentCount());
|
||||||
for (RevCommit p : commit.getParents()) {
|
for (RevCommit p : commit.getParents()) {
|
||||||
@@ -318,7 +317,7 @@ public class EventFactory {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private void addNeededBy(RevWalk rw, ChangeAttribute ca, Change change, PatchSet currentPs)
|
private void addNeededBy(RevWalk rw, ChangeAttribute ca, Change change, PatchSet currentPs)
|
||||||
throws StorageException, IOException {
|
throws IOException {
|
||||||
if (currentPs.getGroups().isEmpty()) {
|
if (currentPs.getGroups().isEmpty()) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@@ -507,7 +506,7 @@ public class EventFactory {
|
|||||||
|
|
||||||
// TODO: The same method exists in PatchSetInfoFactory, find a common place
|
// TODO: The same method exists in PatchSetInfoFactory, find a common place
|
||||||
// for it
|
// for it
|
||||||
private UserIdentity toUserIdentity(PersonIdent who) throws IOException, StorageException {
|
private UserIdentity toUserIdentity(PersonIdent who) throws IOException {
|
||||||
UserIdentity u = new UserIdentity();
|
UserIdentity u = new UserIdentity();
|
||||||
u.setName(who.getName());
|
u.setName(who.getName());
|
||||||
u.setEmail(who.getEmailAddress());
|
u.setEmail(who.getEmailAddress());
|
||||||
|
@@ -135,7 +135,7 @@ public class StreamEventsApiListener
|
|||||||
this.changeNotesFactory = changeNotesFactory;
|
this.changeNotesFactory = changeNotesFactory;
|
||||||
}
|
}
|
||||||
|
|
||||||
private ChangeNotes getNotes(ChangeInfo info) throws StorageException {
|
private ChangeNotes getNotes(ChangeInfo info) {
|
||||||
try {
|
try {
|
||||||
return changeNotesFactory.createChecked(new Change.Id(info._number));
|
return changeNotesFactory.createChecked(new Change.Id(info._number));
|
||||||
} catch (NoSuchChangeException e) {
|
} catch (NoSuchChangeException e) {
|
||||||
@@ -143,7 +143,7 @@ public class StreamEventsApiListener
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private PatchSet getPatchSet(ChangeNotes notes, RevisionInfo info) throws StorageException {
|
private PatchSet getPatchSet(ChangeNotes notes, RevisionInfo info) {
|
||||||
return psUtil.get(notes, PatchSet.Id.fromRef(info.ref));
|
return psUtil.get(notes, PatchSet.Id.fromRef(info.ref));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -16,7 +16,6 @@ package com.google.gerrit.server.extensions.events;
|
|||||||
|
|
||||||
import com.google.common.collect.ImmutableSet;
|
import com.google.common.collect.ImmutableSet;
|
||||||
import com.google.common.collect.Sets;
|
import com.google.common.collect.Sets;
|
||||||
import com.google.gerrit.exceptions.StorageException;
|
|
||||||
import com.google.gerrit.extensions.client.ListChangesOption;
|
import com.google.gerrit.extensions.client.ListChangesOption;
|
||||||
import com.google.gerrit.extensions.common.AccountInfo;
|
import com.google.gerrit.extensions.common.AccountInfo;
|
||||||
import com.google.gerrit.extensions.common.ApprovalInfo;
|
import com.google.gerrit.extensions.common.ApprovalInfo;
|
||||||
@@ -74,19 +73,17 @@ public class EventUtil {
|
|||||||
this.revisionJsonFactory = revisionJsonFactory;
|
this.revisionJsonFactory = revisionJsonFactory;
|
||||||
}
|
}
|
||||||
|
|
||||||
public ChangeInfo changeInfo(Change change) throws StorageException {
|
public ChangeInfo changeInfo(Change change) {
|
||||||
return changeJsonFactory.create(CHANGE_OPTIONS).format(change);
|
return changeJsonFactory.create(CHANGE_OPTIONS).format(change);
|
||||||
}
|
}
|
||||||
|
|
||||||
public RevisionInfo revisionInfo(Project project, PatchSet ps)
|
public RevisionInfo revisionInfo(Project project, PatchSet ps)
|
||||||
throws StorageException, PatchListNotAvailableException, GpgException, IOException,
|
throws PatchListNotAvailableException, GpgException, IOException, PermissionBackendException {
|
||||||
PermissionBackendException {
|
|
||||||
return revisionInfo(project.getNameKey(), ps);
|
return revisionInfo(project.getNameKey(), ps);
|
||||||
}
|
}
|
||||||
|
|
||||||
public RevisionInfo revisionInfo(Project.NameKey project, PatchSet ps)
|
public RevisionInfo revisionInfo(Project.NameKey project, PatchSet ps)
|
||||||
throws StorageException, PatchListNotAvailableException, GpgException, IOException,
|
throws PatchListNotAvailableException, GpgException, IOException, PermissionBackendException {
|
||||||
PermissionBackendException {
|
|
||||||
ChangeData cd = changeDataFactory.create(project, ps.getId().getParentKey());
|
ChangeData cd = changeDataFactory.create(project, ps.getId().getParentKey());
|
||||||
return revisionJsonFactory.create(CHANGE_OPTIONS).getRevisionInfo(cd, ps);
|
return revisionJsonFactory.create(CHANGE_OPTIONS).getRevisionInfo(cd, ps);
|
||||||
}
|
}
|
||||||
|
@@ -28,7 +28,6 @@ import com.google.common.collect.SetMultimap;
|
|||||||
import com.google.common.collect.Sets;
|
import com.google.common.collect.Sets;
|
||||||
import com.google.common.collect.SortedSetMultimap;
|
import com.google.common.collect.SortedSetMultimap;
|
||||||
import com.google.common.flogger.FluentLogger;
|
import com.google.common.flogger.FluentLogger;
|
||||||
import com.google.gerrit.exceptions.StorageException;
|
|
||||||
import com.google.gerrit.reviewdb.client.PatchSet;
|
import com.google.gerrit.reviewdb.client.PatchSet;
|
||||||
import com.google.gerrit.reviewdb.client.Project;
|
import com.google.gerrit.reviewdb.client.Project;
|
||||||
import com.google.gerrit.server.PatchSetUtil;
|
import com.google.gerrit.server.PatchSetUtil;
|
||||||
@@ -89,7 +88,7 @@ public class GroupCollector {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private interface Lookup {
|
private interface Lookup {
|
||||||
List<String> lookup(PatchSet.Id psId) throws StorageException;
|
List<String> lookup(PatchSet.Id psId);
|
||||||
}
|
}
|
||||||
|
|
||||||
private final ListMultimap<ObjectId, PatchSet.Id> patchSetsBySha;
|
private final ListMultimap<ObjectId, PatchSet.Id> patchSetsBySha;
|
||||||
@@ -198,7 +197,7 @@ public class GroupCollector {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public SortedSetMultimap<ObjectId, String> getGroups() throws StorageException {
|
public SortedSetMultimap<ObjectId, String> getGroups() {
|
||||||
done = true;
|
done = true;
|
||||||
SortedSetMultimap<ObjectId, String> result =
|
SortedSetMultimap<ObjectId, String> result =
|
||||||
MultimapBuilder.hashKeys(groups.keySet().size()).treeSetValues().build();
|
MultimapBuilder.hashKeys(groups.keySet().size()).treeSetValues().build();
|
||||||
@@ -224,8 +223,7 @@ public class GroupCollector {
|
|||||||
return id != null && patchSetsBySha.containsKey(id);
|
return id != null && patchSetsBySha.containsKey(id);
|
||||||
}
|
}
|
||||||
|
|
||||||
private Set<String> resolveGroups(ObjectId forCommit, Collection<String> candidates)
|
private Set<String> resolveGroups(ObjectId forCommit, Collection<String> candidates) {
|
||||||
throws StorageException {
|
|
||||||
Set<String> actual = Sets.newTreeSet();
|
Set<String> actual = Sets.newTreeSet();
|
||||||
Set<String> done = Sets.newHashSetWithExpectedSize(candidates.size());
|
Set<String> done = Sets.newHashSetWithExpectedSize(candidates.size());
|
||||||
Set<String> seen = Sets.newHashSetWithExpectedSize(candidates.size());
|
Set<String> seen = Sets.newHashSetWithExpectedSize(candidates.size());
|
||||||
@@ -260,7 +258,7 @@ public class GroupCollector {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private Iterable<String> resolveGroup(ObjectId forCommit, String group) throws StorageException {
|
private Iterable<String> resolveGroup(ObjectId forCommit, String group) {
|
||||||
ObjectId id = parseGroup(forCommit, group);
|
ObjectId id = parseGroup(forCommit, group);
|
||||||
if (id != null) {
|
if (id != null) {
|
||||||
PatchSet.Id psId = Iterables.getFirst(patchSetsBySha.get(id), null);
|
PatchSet.Id psId = Iterables.getFirst(patchSetsBySha.get(id), null);
|
||||||
|
@@ -17,7 +17,6 @@ package com.google.gerrit.server.git;
|
|||||||
import static java.util.Objects.requireNonNull;
|
import static java.util.Objects.requireNonNull;
|
||||||
|
|
||||||
import com.google.common.flogger.FluentLogger;
|
import com.google.common.flogger.FluentLogger;
|
||||||
import com.google.gerrit.exceptions.StorageException;
|
|
||||||
import com.google.gerrit.reviewdb.client.Change;
|
import com.google.gerrit.reviewdb.client.Change;
|
||||||
import com.google.gerrit.reviewdb.client.ChangeMessage;
|
import com.google.gerrit.reviewdb.client.ChangeMessage;
|
||||||
import com.google.gerrit.reviewdb.client.LabelId;
|
import com.google.gerrit.reviewdb.client.LabelId;
|
||||||
@@ -105,7 +104,7 @@ public class MergedByPushOp implements BatchUpdateOp {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean updateChange(ChangeContext ctx) throws StorageException, IOException {
|
public boolean updateChange(ChangeContext ctx) throws IOException {
|
||||||
change = ctx.getChange();
|
change = ctx.getChange();
|
||||||
correctBranch = refName.equals(change.getDest().get());
|
correctBranch = refName.equals(change.getDest().get());
|
||||||
if (!correctBranch) {
|
if (!correctBranch) {
|
||||||
@@ -193,7 +192,7 @@ public class MergedByPushOp implements BatchUpdateOp {
|
|||||||
change, patchSet, ctx.getAccount(), patchSet.getRevision().get(), ctx.getWhen());
|
change, patchSet, ctx.getAccount(), patchSet.getRevision().get(), ctx.getWhen());
|
||||||
}
|
}
|
||||||
|
|
||||||
private PatchSetInfo getPatchSetInfo(ChangeContext ctx) throws IOException, StorageException {
|
private PatchSetInfo getPatchSetInfo(ChangeContext ctx) throws IOException {
|
||||||
RevWalk rw = ctx.getRevWalk();
|
RevWalk rw = ctx.getRevWalk();
|
||||||
RevCommit commit =
|
RevCommit commit =
|
||||||
rw.parseCommit(ObjectId.fromString(requireNonNull(patchSet).getRevision().get()));
|
rw.parseCommit(ObjectId.fromString(requireNonNull(patchSet).getRevision().get()));
|
||||||
|
@@ -18,7 +18,6 @@ import com.google.common.annotations.VisibleForTesting;
|
|||||||
import com.google.common.base.Throwables;
|
import com.google.common.base.Throwables;
|
||||||
import com.google.common.cache.CacheLoader;
|
import com.google.common.cache.CacheLoader;
|
||||||
import com.google.common.cache.LoadingCache;
|
import com.google.common.cache.LoadingCache;
|
||||||
import com.google.gerrit.exceptions.StorageException;
|
|
||||||
import com.google.gerrit.extensions.restapi.BadRequestException;
|
import com.google.gerrit.extensions.restapi.BadRequestException;
|
||||||
import com.google.gerrit.reviewdb.client.Change;
|
import com.google.gerrit.reviewdb.client.Change;
|
||||||
import com.google.gerrit.reviewdb.client.Project;
|
import com.google.gerrit.reviewdb.client.Project;
|
||||||
@@ -87,11 +86,9 @@ public class PureRevertCache {
|
|||||||
*
|
*
|
||||||
* @return {@code true} if {@code claimedRevert} is a pure (clean) revert.
|
* @return {@code true} if {@code claimedRevert} is a pure (clean) revert.
|
||||||
* @throws IOException if there was a problem with the storage layer
|
* @throws IOException if there was a problem with the storage layer
|
||||||
* @throws StorageException if there was a problem with the storage layer
|
|
||||||
* @throws BadRequestException if there is a problem with the provided {@link ChangeNotes}
|
* @throws BadRequestException if there is a problem with the provided {@link ChangeNotes}
|
||||||
*/
|
*/
|
||||||
public boolean isPureRevert(ChangeNotes claimedRevert)
|
public boolean isPureRevert(ChangeNotes claimedRevert) throws IOException, BadRequestException {
|
||||||
throws StorageException, IOException, BadRequestException {
|
|
||||||
if (claimedRevert.getChange().getRevertOf() == null) {
|
if (claimedRevert.getChange().getRevertOf() == null) {
|
||||||
throw new BadRequestException("revertOf not set");
|
throw new BadRequestException("revertOf not set");
|
||||||
}
|
}
|
||||||
|
@@ -2274,7 +2274,7 @@ class ReceiveCommits {
|
|||||||
return newChanges;
|
return newChanges;
|
||||||
}
|
}
|
||||||
|
|
||||||
private boolean foundInExistingRef(Collection<Ref> existingRefs) throws StorageException {
|
private boolean foundInExistingRef(Collection<Ref> existingRefs) {
|
||||||
for (Ref ref : existingRefs) {
|
for (Ref ref : existingRefs) {
|
||||||
ChangeNotes notes =
|
ChangeNotes notes =
|
||||||
notesFactory.create(project.getNameKey(), Change.Id.fromRef(ref.getName()));
|
notesFactory.create(project.getNameKey(), Change.Id.fromRef(ref.getName()));
|
||||||
@@ -2394,11 +2394,11 @@ class ReceiveCommits {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private ChangeLookup lookupByChangeKey(RevCommit c, Change.Key key) throws StorageException {
|
private ChangeLookup lookupByChangeKey(RevCommit c, Change.Key key) {
|
||||||
return new ChangeLookup(c, key, queryProvider.get().byBranchKey(magicBranch.dest, key));
|
return new ChangeLookup(c, key, queryProvider.get().byBranchKey(magicBranch.dest, key));
|
||||||
}
|
}
|
||||||
|
|
||||||
private ChangeLookup lookupByCommit(RevCommit c) throws StorageException {
|
private ChangeLookup lookupByCommit(RevCommit c) {
|
||||||
return new ChangeLookup(
|
return new ChangeLookup(
|
||||||
c, null, queryProvider.get().byBranchCommit(magicBranch.dest, c.getName()));
|
c, null, queryProvider.get().byBranchCommit(magicBranch.dest, c.getName()));
|
||||||
}
|
}
|
||||||
@@ -2525,8 +2525,8 @@ class ReceiveCommits {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private void submit(Collection<CreateRequest> create, Collection<ReplaceRequest> replace)
|
private void submit(Collection<CreateRequest> create, Collection<ReplaceRequest> replace)
|
||||||
throws StorageException, RestApiException, UpdateException, IOException,
|
throws RestApiException, UpdateException, IOException, ConfigInvalidException,
|
||||||
ConfigInvalidException, PermissionBackendException {
|
PermissionBackendException {
|
||||||
Map<ObjectId, Change> bySha = Maps.newHashMapWithExpectedSize(create.size() + replace.size());
|
Map<ObjectId, Change> bySha = Maps.newHashMapWithExpectedSize(create.size() + replace.size());
|
||||||
for (CreateRequest r : create) {
|
for (CreateRequest r : create) {
|
||||||
requireNonNull(
|
requireNonNull(
|
||||||
@@ -2582,7 +2582,7 @@ class ReceiveCommits {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void readChangesForReplace() throws StorageException {
|
private void readChangesForReplace() {
|
||||||
Collection<ChangeNotes> allNotes =
|
Collection<ChangeNotes> allNotes =
|
||||||
notesFactory.create(
|
notesFactory.create(
|
||||||
replaceByChange.values().stream().map(r -> r.ontoChange).collect(toList()));
|
replaceByChange.values().stream().map(r -> r.ontoChange).collect(toList()));
|
||||||
@@ -2646,10 +2646,9 @@ class ReceiveCommits {
|
|||||||
*
|
*
|
||||||
* @return whether the new commit is valid
|
* @return whether the new commit is valid
|
||||||
* @throws IOException
|
* @throws IOException
|
||||||
* @throws StorageException
|
|
||||||
* @throws PermissionBackendException
|
* @throws PermissionBackendException
|
||||||
*/
|
*/
|
||||||
boolean validateNewPatchSet() throws IOException, StorageException, PermissionBackendException {
|
boolean validateNewPatchSet() throws IOException, PermissionBackendException {
|
||||||
if (!validateNewPatchSetNoteDb()) {
|
if (!validateNewPatchSetNoteDb()) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@@ -2670,8 +2669,7 @@ class ReceiveCommits {
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
boolean validateNewPatchSetForAutoClose()
|
boolean validateNewPatchSetForAutoClose() throws IOException, PermissionBackendException {
|
||||||
throws IOException, StorageException, PermissionBackendException {
|
|
||||||
if (!validateNewPatchSetNoteDb()) {
|
if (!validateNewPatchSetNoteDb()) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@@ -2681,8 +2679,7 @@ class ReceiveCommits {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/** Validates the new PS against permissions and notedb status. */
|
/** Validates the new PS against permissions and notedb status. */
|
||||||
private boolean validateNewPatchSetNoteDb()
|
private boolean validateNewPatchSetNoteDb() throws IOException, PermissionBackendException {
|
||||||
throws IOException, StorageException, PermissionBackendException {
|
|
||||||
if (notes == null) {
|
if (notes == null) {
|
||||||
reject(inputCommand, "change " + ontoChange + " not found");
|
reject(inputCommand, "change " + ontoChange + " not found");
|
||||||
return false;
|
return false;
|
||||||
@@ -2845,7 +2842,7 @@ class ReceiveCommits {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/** Updates 'this' to add a new patchset. */
|
/** Updates 'this' to add a new patchset. */
|
||||||
private void newPatchSet() throws IOException, StorageException {
|
private void newPatchSet() throws IOException {
|
||||||
RevCommit newCommit = receivePack.getRevWalk().parseCommit(newCommitId);
|
RevCommit newCommit = receivePack.getRevWalk().parseCommit(newCommitId);
|
||||||
psId =
|
psId =
|
||||||
ChangeUtil.nextPatchSetIdFromAllRefsMap(allRefs(), notes.getChange().currentPatchSetId());
|
ChangeUtil.nextPatchSetIdFromAllRefsMap(allRefs(), notes.getChange().currentPatchSetId());
|
||||||
@@ -2909,7 +2906,7 @@ class ReceiveCommits {
|
|||||||
psId.getParentKey(),
|
psId.getParentKey(),
|
||||||
new BatchUpdateOp() {
|
new BatchUpdateOp() {
|
||||||
@Override
|
@Override
|
||||||
public boolean updateChange(ChangeContext ctx) throws StorageException {
|
public boolean updateChange(ChangeContext ctx) {
|
||||||
PatchSet ps = psUtil.get(ctx.getNotes(), psId);
|
PatchSet ps = psUtil.get(ctx.getNotes(), psId);
|
||||||
List<String> oldGroups = ps.getGroups();
|
List<String> oldGroups = ps.getGroups();
|
||||||
if (oldGroups == null) {
|
if (oldGroups == null) {
|
||||||
@@ -3241,7 +3238,7 @@ class ReceiveCommits {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private Optional<ChangeNotes> getChangeNotes(Change.Id changeId) throws StorageException {
|
private Optional<ChangeNotes> getChangeNotes(Change.Id changeId) {
|
||||||
try {
|
try {
|
||||||
return Optional.of(notesFactory.createChecked(project.getNameKey(), changeId));
|
return Optional.of(notesFactory.createChecked(project.getNameKey(), changeId));
|
||||||
} catch (NoSuchChangeException e) {
|
} catch (NoSuchChangeException e) {
|
||||||
@@ -3249,7 +3246,7 @@ class ReceiveCommits {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private <T> T executeIndexQuery(Action<T> action) throws StorageException {
|
private <T> T executeIndexQuery(Action<T> action) {
|
||||||
try {
|
try {
|
||||||
return retryHelper.execute(
|
return retryHelper.execute(
|
||||||
ActionType.INDEX_QUERY, action, StorageException.class::isInstance);
|
ActionType.INDEX_QUERY, action, StorageException.class::isInstance);
|
||||||
@@ -3260,8 +3257,7 @@ class ReceiveCommits {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private Map<Change.Key, ChangeNotes> openChangesByKeyByBranch(Branch.NameKey branch)
|
private Map<Change.Key, ChangeNotes> openChangesByKeyByBranch(Branch.NameKey branch) {
|
||||||
throws StorageException {
|
|
||||||
Map<Change.Key, ChangeNotes> r = new HashMap<>();
|
Map<Change.Key, ChangeNotes> r = new HashMap<>();
|
||||||
for (ChangeData cd : queryProvider.get().byBranchOpen(branch)) {
|
for (ChangeData cd : queryProvider.get().byBranchOpen(branch)) {
|
||||||
try {
|
try {
|
||||||
|
@@ -29,7 +29,6 @@ import com.google.common.collect.Streams;
|
|||||||
import com.google.common.flogger.FluentLogger;
|
import com.google.common.flogger.FluentLogger;
|
||||||
import com.google.gerrit.common.Nullable;
|
import com.google.gerrit.common.Nullable;
|
||||||
import com.google.gerrit.common.data.LabelType;
|
import com.google.gerrit.common.data.LabelType;
|
||||||
import com.google.gerrit.exceptions.StorageException;
|
|
||||||
import com.google.gerrit.extensions.api.changes.AddReviewerInput;
|
import com.google.gerrit.extensions.api.changes.AddReviewerInput;
|
||||||
import com.google.gerrit.extensions.api.changes.NotifyHandling;
|
import com.google.gerrit.extensions.api.changes.NotifyHandling;
|
||||||
import com.google.gerrit.extensions.client.ChangeKind;
|
import com.google.gerrit.extensions.client.ChangeKind;
|
||||||
@@ -242,8 +241,7 @@ public class ReplaceOp implements BatchUpdateOp {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean updateChange(ChangeContext ctx)
|
public boolean updateChange(ChangeContext ctx)
|
||||||
throws RestApiException, StorageException, IOException, PermissionBackendException,
|
throws RestApiException, IOException, PermissionBackendException, ConfigInvalidException {
|
||||||
ConfigInvalidException {
|
|
||||||
notes = ctx.getNotes();
|
notes = ctx.getNotes();
|
||||||
Change change = notes.getChange();
|
Change change = notes.getChange();
|
||||||
if (change == null || change.isClosed()) {
|
if (change == null || change.isClosed()) {
|
||||||
@@ -387,7 +385,7 @@ public class ReplaceOp implements BatchUpdateOp {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private ChangeMessage createChangeMessage(ChangeContext ctx, String reviewMessage)
|
private ChangeMessage createChangeMessage(ChangeContext ctx, String reviewMessage)
|
||||||
throws StorageException, IOException {
|
throws IOException {
|
||||||
String approvalMessage =
|
String approvalMessage =
|
||||||
ApprovalsUtil.renderMessageWithApprovals(
|
ApprovalsUtil.renderMessageWithApprovals(
|
||||||
patchSetId.get(), approvals, scanLabels(ctx, approvals));
|
patchSetId.get(), approvals, scanLabels(ctx, approvals));
|
||||||
@@ -441,7 +439,7 @@ public class ReplaceOp implements BatchUpdateOp {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private Map<String, PatchSetApproval> scanLabels(ChangeContext ctx, Map<String, Short> approvals)
|
private Map<String, PatchSetApproval> scanLabels(ChangeContext ctx, Map<String, Short> approvals)
|
||||||
throws StorageException, IOException {
|
throws IOException {
|
||||||
Map<String, PatchSetApproval> current = new HashMap<>();
|
Map<String, PatchSetApproval> current = new HashMap<>();
|
||||||
// We optimize here and only retrieve current when approvals provided
|
// We optimize here and only retrieve current when approvals provided
|
||||||
if (!approvals.isEmpty()) {
|
if (!approvals.isEmpty()) {
|
||||||
@@ -485,8 +483,7 @@ public class ReplaceOp implements BatchUpdateOp {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private List<Comment> publishComments(ChangeContext ctx, boolean workInProgress)
|
private List<Comment> publishComments(ChangeContext ctx, boolean workInProgress) {
|
||||||
throws StorageException {
|
|
||||||
List<Comment> comments =
|
List<Comment> comments =
|
||||||
commentsUtil.draftByChangeAuthor(ctx.getNotes(), ctx.getUser().getAccountId());
|
commentsUtil.draftByChangeAuthor(ctx.getNotes(), ctx.getUser().getAccountId());
|
||||||
publishCommentUtil.publish(
|
publishCommentUtil.publish(
|
||||||
|
@@ -16,7 +16,6 @@ package com.google.gerrit.server.index.account;
|
|||||||
|
|
||||||
import static com.google.common.base.Preconditions.checkState;
|
import static com.google.common.base.Preconditions.checkState;
|
||||||
|
|
||||||
import com.google.gerrit.exceptions.StorageException;
|
|
||||||
import com.google.gerrit.index.Index;
|
import com.google.gerrit.index.Index;
|
||||||
import com.google.gerrit.index.QueryOptions;
|
import com.google.gerrit.index.QueryOptions;
|
||||||
import com.google.gerrit.index.query.DataSource;
|
import com.google.gerrit.index.query.DataSource;
|
||||||
@@ -37,7 +36,7 @@ public class IndexedAccountQuery extends IndexedQuery<Account.Id, AccountState>
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean match(AccountState accountState) throws StorageException {
|
public boolean match(AccountState accountState) {
|
||||||
Predicate<AccountState> pred = getChild(0);
|
Predicate<AccountState> pred = getChild(0);
|
||||||
checkState(
|
checkState(
|
||||||
pred.isMatchable(),
|
pred.isMatchable(),
|
||||||
|
@@ -154,7 +154,7 @@ public class ChangeField {
|
|||||||
exact(ChangeQueryBuilder.FIELD_FILE)
|
exact(ChangeQueryBuilder.FIELD_FILE)
|
||||||
.buildRepeatable(cd -> firstNonNull(cd.currentFilePaths(), ImmutableList.of()));
|
.buildRepeatable(cd -> firstNonNull(cd.currentFilePaths(), ImmutableList.of()));
|
||||||
|
|
||||||
public static Set<String> getFileParts(ChangeData cd) throws StorageException {
|
public static Set<String> getFileParts(ChangeData cd) {
|
||||||
List<String> paths;
|
List<String> paths;
|
||||||
try {
|
try {
|
||||||
paths = cd.currentFilePaths();
|
paths = cd.currentFilePaths();
|
||||||
@@ -191,7 +191,7 @@ public class ChangeField {
|
|||||||
public static final FieldDef<ChangeData, Iterable<String>> EXTENSION =
|
public static final FieldDef<ChangeData, Iterable<String>> EXTENSION =
|
||||||
exact(ChangeQueryBuilder.FIELD_EXTENSION).buildRepeatable(ChangeField::getExtensions);
|
exact(ChangeQueryBuilder.FIELD_EXTENSION).buildRepeatable(ChangeField::getExtensions);
|
||||||
|
|
||||||
public static Set<String> getExtensions(ChangeData cd) throws StorageException {
|
public static Set<String> getExtensions(ChangeData cd) {
|
||||||
return extensions(cd).collect(toSet());
|
return extensions(cd).collect(toSet());
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -202,7 +202,7 @@ public class ChangeField {
|
|||||||
public static final FieldDef<ChangeData, String> ONLY_EXTENSIONS =
|
public static final FieldDef<ChangeData, String> ONLY_EXTENSIONS =
|
||||||
exact(ChangeQueryBuilder.FIELD_ONLY_EXTENSIONS).build(ChangeField::getAllExtensionsAsList);
|
exact(ChangeQueryBuilder.FIELD_ONLY_EXTENSIONS).build(ChangeField::getAllExtensionsAsList);
|
||||||
|
|
||||||
public static String getAllExtensionsAsList(ChangeData cd) throws StorageException {
|
public static String getAllExtensionsAsList(ChangeData cd) {
|
||||||
return extensions(cd).distinct().sorted().collect(joining(","));
|
return extensions(cd).distinct().sorted().collect(joining(","));
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -214,7 +214,7 @@ public class ChangeField {
|
|||||||
* <p>If the change contains multiple files with the same extension the extension is returned
|
* <p>If the change contains multiple files with the same extension the extension is returned
|
||||||
* multiple times in the stream (once per file).
|
* multiple times in the stream (once per file).
|
||||||
*/
|
*/
|
||||||
private static Stream<String> extensions(ChangeData cd) throws StorageException {
|
private static Stream<String> extensions(ChangeData cd) {
|
||||||
try {
|
try {
|
||||||
return cd.currentFilePaths().stream()
|
return cd.currentFilePaths().stream()
|
||||||
// Use case-insensitive file extensions even though other file fields are case-sensitive.
|
// Use case-insensitive file extensions even though other file fields are case-sensitive.
|
||||||
@@ -231,7 +231,7 @@ public class ChangeField {
|
|||||||
public static final FieldDef<ChangeData, Iterable<String>> FOOTER =
|
public static final FieldDef<ChangeData, Iterable<String>> FOOTER =
|
||||||
exact(ChangeQueryBuilder.FIELD_FOOTER).buildRepeatable(ChangeField::getFooters);
|
exact(ChangeQueryBuilder.FIELD_FOOTER).buildRepeatable(ChangeField::getFooters);
|
||||||
|
|
||||||
public static Set<String> getFooters(ChangeData cd) throws StorageException {
|
public static Set<String> getFooters(ChangeData cd) {
|
||||||
try {
|
try {
|
||||||
return cd.commitFooters().stream()
|
return cd.commitFooters().stream()
|
||||||
.map(f -> f.toString().toLowerCase(Locale.US))
|
.map(f -> f.toString().toLowerCase(Locale.US))
|
||||||
@@ -245,7 +245,7 @@ public class ChangeField {
|
|||||||
public static final FieldDef<ChangeData, Iterable<String>> DIRECTORY =
|
public static final FieldDef<ChangeData, Iterable<String>> DIRECTORY =
|
||||||
exact(ChangeQueryBuilder.FIELD_DIRECTORY).buildRepeatable(ChangeField::getDirectories);
|
exact(ChangeQueryBuilder.FIELD_DIRECTORY).buildRepeatable(ChangeField::getDirectories);
|
||||||
|
|
||||||
public static Set<String> getDirectories(ChangeData cd) throws StorageException {
|
public static Set<String> getDirectories(ChangeData cd) {
|
||||||
List<String> paths;
|
List<String> paths;
|
||||||
try {
|
try {
|
||||||
paths = cd.currentFilePaths();
|
paths = cd.currentFilePaths();
|
||||||
@@ -470,7 +470,7 @@ public class ChangeField {
|
|||||||
public static final FieldDef<ChangeData, Iterable<String>> EXACT_COMMIT =
|
public static final FieldDef<ChangeData, Iterable<String>> EXACT_COMMIT =
|
||||||
exact(ChangeQueryBuilder.FIELD_EXACTCOMMIT).buildRepeatable(ChangeField::getRevisions);
|
exact(ChangeQueryBuilder.FIELD_EXACTCOMMIT).buildRepeatable(ChangeField::getRevisions);
|
||||||
|
|
||||||
private static Set<String> getRevisions(ChangeData cd) throws StorageException {
|
private static Set<String> getRevisions(ChangeData cd) {
|
||||||
Set<String> revisions = new HashSet<>();
|
Set<String> revisions = new HashSet<>();
|
||||||
for (PatchSet ps : cd.patchSets()) {
|
for (PatchSet ps : cd.patchSets()) {
|
||||||
if (ps.getRevision() != null) {
|
if (ps.getRevision() != null) {
|
||||||
@@ -489,7 +489,7 @@ public class ChangeField {
|
|||||||
public static final FieldDef<ChangeData, Iterable<String>> LABEL =
|
public static final FieldDef<ChangeData, Iterable<String>> LABEL =
|
||||||
exact("label2").buildRepeatable(cd -> getLabels(cd, true));
|
exact("label2").buildRepeatable(cd -> getLabels(cd, true));
|
||||||
|
|
||||||
private static Iterable<String> getLabels(ChangeData cd, boolean owners) throws StorageException {
|
private static Iterable<String> getLabels(ChangeData cd, boolean owners) {
|
||||||
Set<String> allApprovals = new HashSet<>();
|
Set<String> allApprovals = new HashSet<>();
|
||||||
Set<String> distinctApprovals = new HashSet<>();
|
Set<String> distinctApprovals = new HashSet<>();
|
||||||
for (PatchSetApproval a : cd.currentApprovals()) {
|
for (PatchSetApproval a : cd.currentApprovals()) {
|
||||||
@@ -506,21 +506,19 @@ public class ChangeField {
|
|||||||
return allApprovals;
|
return allApprovals;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static Set<String> getAuthorParts(ChangeData cd) throws StorageException, IOException {
|
public static Set<String> getAuthorParts(ChangeData cd) throws IOException {
|
||||||
return SchemaUtil.getPersonParts(cd.getAuthor());
|
return SchemaUtil.getPersonParts(cd.getAuthor());
|
||||||
}
|
}
|
||||||
|
|
||||||
public static Set<String> getAuthorNameAndEmail(ChangeData cd)
|
public static Set<String> getAuthorNameAndEmail(ChangeData cd) throws IOException {
|
||||||
throws StorageException, IOException {
|
|
||||||
return getNameAndEmail(cd.getAuthor());
|
return getNameAndEmail(cd.getAuthor());
|
||||||
}
|
}
|
||||||
|
|
||||||
public static Set<String> getCommitterParts(ChangeData cd) throws StorageException, IOException {
|
public static Set<String> getCommitterParts(ChangeData cd) throws IOException {
|
||||||
return SchemaUtil.getPersonParts(cd.getCommitter());
|
return SchemaUtil.getPersonParts(cd.getCommitter());
|
||||||
}
|
}
|
||||||
|
|
||||||
public static Set<String> getCommitterNameAndEmail(ChangeData cd)
|
public static Set<String> getCommitterNameAndEmail(ChangeData cd) throws IOException {
|
||||||
throws StorageException, IOException {
|
|
||||||
return getNameAndEmail(cd.getCommitter());
|
return getNameAndEmail(cd.getCommitter());
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -856,7 +854,7 @@ public class ChangeField {
|
|||||||
return storedSubmitRecords(cd.submitRecords(opts));
|
return storedSubmitRecords(cd.submitRecords(opts));
|
||||||
}
|
}
|
||||||
|
|
||||||
public static List<String> formatSubmitRecordValues(ChangeData cd) throws StorageException {
|
public static List<String> formatSubmitRecordValues(ChangeData cd) {
|
||||||
return formatSubmitRecordValues(
|
return formatSubmitRecordValues(
|
||||||
cd.submitRecords(SUBMIT_RULE_OPTIONS_STRICT), cd.change().getOwner());
|
cd.submitRecords(SUBMIT_RULE_OPTIONS_STRICT), cd.change().getOwner());
|
||||||
}
|
}
|
||||||
@@ -944,7 +942,7 @@ public class ChangeField {
|
|||||||
return result;
|
return result;
|
||||||
});
|
});
|
||||||
|
|
||||||
private static String getTopic(ChangeData cd) throws StorageException {
|
private static String getTopic(ChangeData cd) {
|
||||||
Change c = cd.change();
|
Change c = cd.change();
|
||||||
if (c == null) {
|
if (c == null) {
|
||||||
return null;
|
return null;
|
||||||
|
@@ -22,7 +22,6 @@ import com.google.common.annotations.VisibleForTesting;
|
|||||||
import com.google.common.collect.ImmutableList;
|
import com.google.common.collect.ImmutableList;
|
||||||
import com.google.common.collect.ImmutableSet;
|
import com.google.common.collect.ImmutableSet;
|
||||||
import com.google.common.collect.Iterables;
|
import com.google.common.collect.Iterables;
|
||||||
import com.google.gerrit.exceptions.StorageException;
|
|
||||||
import com.google.gerrit.index.IndexConfig;
|
import com.google.gerrit.index.IndexConfig;
|
||||||
import com.google.gerrit.index.QueryOptions;
|
import com.google.gerrit.index.QueryOptions;
|
||||||
import com.google.gerrit.index.query.DataSource;
|
import com.google.gerrit.index.query.DataSource;
|
||||||
@@ -81,7 +80,7 @@ public class IndexedChangeQuery extends IndexedQuery<Change.Id, ChangeData>
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public ResultSet<ChangeData> read() throws StorageException {
|
public ResultSet<ChangeData> read() {
|
||||||
final DataSource<ChangeData> currSource = source;
|
final DataSource<ChangeData> currSource = source;
|
||||||
final ResultSet<ChangeData> rs = currSource.read();
|
final ResultSet<ChangeData> rs = currSource.read();
|
||||||
|
|
||||||
@@ -114,7 +113,7 @@ public class IndexedChangeQuery extends IndexedQuery<Change.Id, ChangeData>
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean match(ChangeData cd) throws StorageException {
|
public boolean match(ChangeData cd) {
|
||||||
if (source != null && fromSource.get(cd) == source) {
|
if (source != null && fromSource.get(cd) == source) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
@@ -21,7 +21,6 @@ import com.google.common.flogger.FluentLogger;
|
|||||||
import com.google.common.util.concurrent.FutureCallback;
|
import com.google.common.util.concurrent.FutureCallback;
|
||||||
import com.google.common.util.concurrent.Futures;
|
import com.google.common.util.concurrent.Futures;
|
||||||
import com.google.common.util.concurrent.ListeningExecutorService;
|
import com.google.common.util.concurrent.ListeningExecutorService;
|
||||||
import com.google.gerrit.exceptions.StorageException;
|
|
||||||
import com.google.gerrit.extensions.events.GitReferenceUpdatedListener;
|
import com.google.gerrit.extensions.events.GitReferenceUpdatedListener;
|
||||||
import com.google.gerrit.reviewdb.client.Account;
|
import com.google.gerrit.reviewdb.client.Account;
|
||||||
import com.google.gerrit.reviewdb.client.Branch;
|
import com.google.gerrit.reviewdb.client.Branch;
|
||||||
@@ -152,7 +151,7 @@ public class ReindexAfterRefUpdate implements GitReferenceUpdatedListener {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected List<Change> impl(RequestContext ctx) throws StorageException {
|
protected List<Change> impl(RequestContext ctx) {
|
||||||
String ref = event.getRefName();
|
String ref = event.getRefName();
|
||||||
Project.NameKey project = new Project.NameKey(event.getProjectName());
|
Project.NameKey project = new Project.NameKey(event.getProjectName());
|
||||||
if (ref.equals(RefNames.REFS_CONFIG)) {
|
if (ref.equals(RefNames.REFS_CONFIG)) {
|
||||||
@@ -179,7 +178,7 @@ public class ReindexAfterRefUpdate implements GitReferenceUpdatedListener {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected Void impl(RequestContext ctx) throws StorageException, IOException {
|
protected Void impl(RequestContext ctx) throws IOException {
|
||||||
// Reload change, as some time may have passed since GetChanges.
|
// Reload change, as some time may have passed since GetChanges.
|
||||||
try {
|
try {
|
||||||
Change c =
|
Change c =
|
||||||
|
@@ -18,7 +18,6 @@ import static com.google.gerrit.server.notedb.ReviewerStateInternal.CC;
|
|||||||
import static com.google.gerrit.server.notedb.ReviewerStateInternal.REVIEWER;
|
import static com.google.gerrit.server.notedb.ReviewerStateInternal.REVIEWER;
|
||||||
|
|
||||||
import com.google.gerrit.common.FooterConstants;
|
import com.google.gerrit.common.FooterConstants;
|
||||||
import com.google.gerrit.exceptions.StorageException;
|
|
||||||
import com.google.gerrit.extensions.restapi.UnprocessableEntityException;
|
import com.google.gerrit.extensions.restapi.UnprocessableEntityException;
|
||||||
import com.google.gerrit.reviewdb.client.Account;
|
import com.google.gerrit.reviewdb.client.Account;
|
||||||
import com.google.gerrit.server.ReviewerSet;
|
import com.google.gerrit.server.ReviewerSet;
|
||||||
@@ -37,7 +36,7 @@ public class MailUtil {
|
|||||||
|
|
||||||
public static MailRecipients getRecipientsFromFooters(
|
public static MailRecipients getRecipientsFromFooters(
|
||||||
AccountResolver accountResolver, List<FooterLine> footerLines)
|
AccountResolver accountResolver, List<FooterLine> footerLines)
|
||||||
throws StorageException, IOException, ConfigInvalidException {
|
throws IOException, ConfigInvalidException {
|
||||||
MailRecipients recipients = new MailRecipients();
|
MailRecipients recipients = new MailRecipients();
|
||||||
for (FooterLine footerLine : footerLines) {
|
for (FooterLine footerLine : footerLines) {
|
||||||
try {
|
try {
|
||||||
@@ -62,7 +61,7 @@ public class MailUtil {
|
|||||||
|
|
||||||
@SuppressWarnings("deprecation")
|
@SuppressWarnings("deprecation")
|
||||||
private static Account.Id toAccountId(AccountResolver accountResolver, String nameOrEmail)
|
private static Account.Id toAccountId(AccountResolver accountResolver, String nameOrEmail)
|
||||||
throws StorageException, UnprocessableEntityException, IOException, ConfigInvalidException {
|
throws UnprocessableEntityException, IOException, ConfigInvalidException {
|
||||||
return accountResolver.resolveByNameOrEmail(nameOrEmail).asUnique().getAccount().getId();
|
return accountResolver.resolveByNameOrEmail(nameOrEmail).asUnique().getAccount().getId();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -147,7 +147,7 @@ public class MailProcessor {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private void processImpl(BatchUpdate.Factory buf, MailMessage message)
|
private void processImpl(BatchUpdate.Factory buf, MailMessage message)
|
||||||
throws StorageException, UpdateException, RestApiException, IOException {
|
throws UpdateException, RestApiException, IOException {
|
||||||
for (Extension<MailFilter> filter : mailFilters) {
|
for (Extension<MailFilter> filter : mailFilters) {
|
||||||
if (!filter.getProvider().get().shouldProcessMessage(message)) {
|
if (!filter.getProvider().get().shouldProcessMessage(message)) {
|
||||||
logger.atWarning().log(
|
logger.atWarning().log(
|
||||||
@@ -208,7 +208,7 @@ public class MailProcessor {
|
|||||||
|
|
||||||
private void persistComments(
|
private void persistComments(
|
||||||
BatchUpdate.Factory buf, MailMessage message, MailMetadata metadata, Account.Id sender)
|
BatchUpdate.Factory buf, MailMessage message, MailMetadata metadata, Account.Id sender)
|
||||||
throws StorageException, UpdateException, RestApiException {
|
throws UpdateException, RestApiException {
|
||||||
try (ManualRequestContext ctx = oneOffRequestContext.openAs(sender)) {
|
try (ManualRequestContext ctx = oneOffRequestContext.openAs(sender)) {
|
||||||
List<ChangeData> changeDataList =
|
List<ChangeData> changeDataList =
|
||||||
queryProvider.get().byLegacyChangeId(new Change.Id(metadata.changeNumber));
|
queryProvider.get().byLegacyChangeId(new Change.Id(metadata.changeNumber));
|
||||||
@@ -283,7 +283,7 @@ public class MailProcessor {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean updateChange(ChangeContext ctx)
|
public boolean updateChange(ChangeContext ctx)
|
||||||
throws StorageException, UnprocessableEntityException, PatchListNotAvailableException {
|
throws UnprocessableEntityException, PatchListNotAvailableException {
|
||||||
patchSet = psUtil.get(ctx.getNotes(), psId);
|
patchSet = psUtil.get(ctx.getNotes(), psId);
|
||||||
notes = ctx.getNotes();
|
notes = ctx.getNotes();
|
||||||
if (patchSet == null) {
|
if (patchSet == null) {
|
||||||
@@ -358,7 +358,7 @@ public class MailProcessor {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private PatchSet targetPatchSetForComment(
|
private PatchSet targetPatchSetForComment(
|
||||||
ChangeContext ctx, MailComment mailComment, PatchSet current) throws StorageException {
|
ChangeContext ctx, MailComment mailComment, PatchSet current) {
|
||||||
if (mailComment.getInReplyTo() != null) {
|
if (mailComment.getInReplyTo() != null) {
|
||||||
return psUtil.get(
|
return psUtil.get(
|
||||||
ctx.getNotes(),
|
ctx.getNotes(),
|
||||||
@@ -369,7 +369,7 @@ public class MailProcessor {
|
|||||||
|
|
||||||
private Comment persistentCommentFromMailComment(
|
private Comment persistentCommentFromMailComment(
|
||||||
ChangeContext ctx, MailComment mailComment, PatchSet patchSetForComment)
|
ChangeContext ctx, MailComment mailComment, PatchSet patchSetForComment)
|
||||||
throws StorageException, UnprocessableEntityException, PatchListNotAvailableException {
|
throws UnprocessableEntityException, PatchListNotAvailableException {
|
||||||
String fileName;
|
String fileName;
|
||||||
// The patch set that this comment is based on is different if this
|
// The patch set that this comment is based on is different if this
|
||||||
// comment was sent in reply to a comment on a previous patch set.
|
// comment was sent in reply to a comment on a previous patch set.
|
||||||
@@ -412,7 +412,7 @@ public class MailProcessor {
|
|||||||
return "(" + numComments + (numComments > 1 ? " comments)" : " comment)");
|
return "(" + numComments + (numComments > 1 ? " comments)" : " comment)");
|
||||||
}
|
}
|
||||||
|
|
||||||
private Set<String> existingMessageIds(ChangeData cd) throws StorageException {
|
private Set<String> existingMessageIds(ChangeData cd) {
|
||||||
Set<String> existingMessageIds = new HashSet<>();
|
Set<String> existingMessageIds = new HashSet<>();
|
||||||
cd.messages().stream()
|
cd.messages().stream()
|
||||||
.forEach(
|
.forEach(
|
||||||
|
@@ -15,7 +15,6 @@
|
|||||||
package com.google.gerrit.server.mail.send;
|
package com.google.gerrit.server.mail.send;
|
||||||
|
|
||||||
import com.google.gerrit.exceptions.EmailException;
|
import com.google.gerrit.exceptions.EmailException;
|
||||||
import com.google.gerrit.exceptions.StorageException;
|
|
||||||
import com.google.gerrit.reviewdb.client.Change;
|
import com.google.gerrit.reviewdb.client.Change;
|
||||||
import com.google.gerrit.reviewdb.client.Project;
|
import com.google.gerrit.reviewdb.client.Project;
|
||||||
import com.google.gerrit.server.account.ProjectWatches.NotifyType;
|
import com.google.gerrit.server.account.ProjectWatches.NotifyType;
|
||||||
@@ -31,8 +30,7 @@ public class AbandonedSender extends ReplyToChangeSender {
|
|||||||
|
|
||||||
@Inject
|
@Inject
|
||||||
public AbandonedSender(
|
public AbandonedSender(
|
||||||
EmailArguments ea, @Assisted Project.NameKey project, @Assisted Change.Id id)
|
EmailArguments ea, @Assisted Project.NameKey project, @Assisted Change.Id id) {
|
||||||
throws StorageException {
|
|
||||||
super(ea, "abandon", ChangeEmail.newChangeData(ea, project, id));
|
super(ea, "abandon", ChangeEmail.newChangeData(ea, project, id));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -15,7 +15,6 @@
|
|||||||
package com.google.gerrit.server.mail.send;
|
package com.google.gerrit.server.mail.send;
|
||||||
|
|
||||||
import com.google.gerrit.exceptions.EmailException;
|
import com.google.gerrit.exceptions.EmailException;
|
||||||
import com.google.gerrit.exceptions.StorageException;
|
|
||||||
import com.google.gerrit.reviewdb.client.Change;
|
import com.google.gerrit.reviewdb.client.Change;
|
||||||
import com.google.gerrit.reviewdb.client.Project;
|
import com.google.gerrit.reviewdb.client.Project;
|
||||||
import com.google.inject.Inject;
|
import com.google.inject.Inject;
|
||||||
@@ -29,8 +28,7 @@ public class AddReviewerSender extends NewChangeSender {
|
|||||||
|
|
||||||
@Inject
|
@Inject
|
||||||
public AddReviewerSender(
|
public AddReviewerSender(
|
||||||
EmailArguments ea, @Assisted Project.NameKey project, @Assisted Change.Id id)
|
EmailArguments ea, @Assisted Project.NameKey project, @Assisted Change.Id id) {
|
||||||
throws StorageException {
|
|
||||||
super(ea, newChangeData(ea, project, id));
|
super(ea, newChangeData(ea, project, id));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -84,7 +84,7 @@ public abstract class ChangeEmail extends NotificationEmail {
|
|||||||
protected Set<Account.Id> authors;
|
protected Set<Account.Id> authors;
|
||||||
protected boolean emailOnlyAuthors;
|
protected boolean emailOnlyAuthors;
|
||||||
|
|
||||||
protected ChangeEmail(EmailArguments ea, String mc, ChangeData cd) throws StorageException {
|
protected ChangeEmail(EmailArguments ea, String mc, ChangeData cd) {
|
||||||
super(ea, mc, cd.change().getDest());
|
super(ea, mc, cd.change().getDest());
|
||||||
changeData = cd;
|
changeData = cd;
|
||||||
change = cd.change();
|
change = cd.change();
|
||||||
@@ -343,8 +343,7 @@ public abstract class ChangeEmail extends NotificationEmail {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected final Watchers getWatchers(NotifyType type, boolean includeWatchersFromNotifyConfig)
|
protected final Watchers getWatchers(NotifyType type, boolean includeWatchersFromNotifyConfig) {
|
||||||
throws StorageException {
|
|
||||||
if (!NotifyHandling.ALL.equals(notify.handling())) {
|
if (!NotifyHandling.ALL.equals(notify.handling())) {
|
||||||
return new Watchers();
|
return new Watchers();
|
||||||
}
|
}
|
||||||
|
@@ -119,8 +119,7 @@ public class CommentSender extends ReplyToChangeSender {
|
|||||||
CommentsUtil commentsUtil,
|
CommentsUtil commentsUtil,
|
||||||
@GerritServerConfig Config cfg,
|
@GerritServerConfig Config cfg,
|
||||||
@Assisted Project.NameKey project,
|
@Assisted Project.NameKey project,
|
||||||
@Assisted Change.Id id)
|
@Assisted Change.Id id) {
|
||||||
throws StorageException {
|
|
||||||
super(ea, "comment", newChangeData(ea, project, id));
|
super(ea, "comment", newChangeData(ea, project, id));
|
||||||
this.commentsUtil = commentsUtil;
|
this.commentsUtil = commentsUtil;
|
||||||
this.incomingEmailEnabled =
|
this.incomingEmailEnabled =
|
||||||
@@ -129,7 +128,7 @@ public class CommentSender extends ReplyToChangeSender {
|
|||||||
this.replyToAddress = cfg.getString("sendemail", null, "replyToAddress");
|
this.replyToAddress = cfg.getString("sendemail", null, "replyToAddress");
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setComments(List<Comment> comments) throws StorageException {
|
public void setComments(List<Comment> comments) {
|
||||||
inlineComments = comments;
|
inlineComments = comments;
|
||||||
|
|
||||||
Set<String> paths = new HashSet<>();
|
Set<String> paths = new HashSet<>();
|
||||||
|
@@ -44,8 +44,7 @@ public class CreateChangeSender extends NewChangeSender {
|
|||||||
EmailArguments ea,
|
EmailArguments ea,
|
||||||
PermissionBackend permissionBackend,
|
PermissionBackend permissionBackend,
|
||||||
@Assisted Project.NameKey project,
|
@Assisted Project.NameKey project,
|
||||||
@Assisted Change.Id id)
|
@Assisted Change.Id id) {
|
||||||
throws StorageException {
|
|
||||||
super(ea, newChangeData(ea, project, id));
|
super(ea, newChangeData(ea, project, id));
|
||||||
this.permissionBackend = permissionBackend;
|
this.permissionBackend = permissionBackend;
|
||||||
}
|
}
|
||||||
|
@@ -15,7 +15,6 @@
|
|||||||
package com.google.gerrit.server.mail.send;
|
package com.google.gerrit.server.mail.send;
|
||||||
|
|
||||||
import com.google.gerrit.exceptions.EmailException;
|
import com.google.gerrit.exceptions.EmailException;
|
||||||
import com.google.gerrit.exceptions.StorageException;
|
|
||||||
import com.google.gerrit.extensions.api.changes.RecipientType;
|
import com.google.gerrit.extensions.api.changes.RecipientType;
|
||||||
import com.google.gerrit.mail.Address;
|
import com.google.gerrit.mail.Address;
|
||||||
import com.google.gerrit.reviewdb.client.Account;
|
import com.google.gerrit.reviewdb.client.Account;
|
||||||
@@ -42,8 +41,7 @@ public class DeleteReviewerSender extends ReplyToChangeSender {
|
|||||||
|
|
||||||
@Inject
|
@Inject
|
||||||
public DeleteReviewerSender(
|
public DeleteReviewerSender(
|
||||||
EmailArguments ea, @Assisted Project.NameKey project, @Assisted Change.Id id)
|
EmailArguments ea, @Assisted Project.NameKey project, @Assisted Change.Id id) {
|
||||||
throws StorageException {
|
|
||||||
super(ea, "deleteReviewer", newChangeData(ea, project, id));
|
super(ea, "deleteReviewer", newChangeData(ea, project, id));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -15,7 +15,6 @@
|
|||||||
package com.google.gerrit.server.mail.send;
|
package com.google.gerrit.server.mail.send;
|
||||||
|
|
||||||
import com.google.gerrit.exceptions.EmailException;
|
import com.google.gerrit.exceptions.EmailException;
|
||||||
import com.google.gerrit.exceptions.StorageException;
|
|
||||||
import com.google.gerrit.reviewdb.client.Change;
|
import com.google.gerrit.reviewdb.client.Change;
|
||||||
import com.google.gerrit.reviewdb.client.Project;
|
import com.google.gerrit.reviewdb.client.Project;
|
||||||
import com.google.gerrit.server.account.ProjectWatches.NotifyType;
|
import com.google.gerrit.server.account.ProjectWatches.NotifyType;
|
||||||
@@ -31,8 +30,7 @@ public class DeleteVoteSender extends ReplyToChangeSender {
|
|||||||
|
|
||||||
@Inject
|
@Inject
|
||||||
protected DeleteVoteSender(
|
protected DeleteVoteSender(
|
||||||
EmailArguments ea, @Assisted Project.NameKey project, @Assisted Change.Id id)
|
EmailArguments ea, @Assisted Project.NameKey project, @Assisted Change.Id id) {
|
||||||
throws StorageException {
|
|
||||||
super(ea, "deleteVote", newChangeData(ea, project, id));
|
super(ea, "deleteVote", newChangeData(ea, project, id));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -38,8 +38,8 @@ public class MergedSender extends ReplyToChangeSender {
|
|||||||
private final LabelTypes labelTypes;
|
private final LabelTypes labelTypes;
|
||||||
|
|
||||||
@Inject
|
@Inject
|
||||||
public MergedSender(EmailArguments ea, @Assisted Project.NameKey project, @Assisted Change.Id id)
|
public MergedSender(
|
||||||
throws StorageException {
|
EmailArguments ea, @Assisted Project.NameKey project, @Assisted Change.Id id) {
|
||||||
super(ea, "merged", newChangeData(ea, project, id));
|
super(ea, "merged", newChangeData(ea, project, id));
|
||||||
labelTypes = changeData.getLabelTypes();
|
labelTypes = changeData.getLabelTypes();
|
||||||
}
|
}
|
||||||
|
@@ -15,7 +15,6 @@
|
|||||||
package com.google.gerrit.server.mail.send;
|
package com.google.gerrit.server.mail.send;
|
||||||
|
|
||||||
import com.google.gerrit.exceptions.EmailException;
|
import com.google.gerrit.exceptions.EmailException;
|
||||||
import com.google.gerrit.exceptions.StorageException;
|
|
||||||
import com.google.gerrit.extensions.api.changes.RecipientType;
|
import com.google.gerrit.extensions.api.changes.RecipientType;
|
||||||
import com.google.gerrit.mail.Address;
|
import com.google.gerrit.mail.Address;
|
||||||
import com.google.gerrit.reviewdb.client.Account;
|
import com.google.gerrit.reviewdb.client.Account;
|
||||||
@@ -33,7 +32,7 @@ public abstract class NewChangeSender extends ChangeEmail {
|
|||||||
private final Set<Account.Id> extraCC = new HashSet<>();
|
private final Set<Account.Id> extraCC = new HashSet<>();
|
||||||
private final Set<Address> extraCCByEmail = new HashSet<>();
|
private final Set<Address> extraCCByEmail = new HashSet<>();
|
||||||
|
|
||||||
protected NewChangeSender(EmailArguments ea, ChangeData cd) throws StorageException {
|
protected NewChangeSender(EmailArguments ea, ChangeData cd) {
|
||||||
super(ea, "newchange", cd);
|
super(ea, "newchange", cd);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -77,8 +77,7 @@ public abstract class NotificationEmail extends OutgoingEmail {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/** Returns all watchers that are relevant */
|
/** Returns all watchers that are relevant */
|
||||||
protected abstract Watchers getWatchers(NotifyType type, boolean includeWatchersFromNotifyConfig)
|
protected abstract Watchers getWatchers(NotifyType type, boolean includeWatchersFromNotifyConfig);
|
||||||
throws StorageException;
|
|
||||||
|
|
||||||
/** Add users or email addresses to the TO, CC, or BCC list. */
|
/** Add users or email addresses to the TO, CC, or BCC list. */
|
||||||
protected void add(RecipientType type, Watchers.List list) {
|
protected void add(RecipientType type, Watchers.List list) {
|
||||||
|
@@ -19,7 +19,6 @@ import com.google.common.collect.ImmutableSet;
|
|||||||
import com.google.common.flogger.FluentLogger;
|
import com.google.common.flogger.FluentLogger;
|
||||||
import com.google.gerrit.common.data.GroupDescription;
|
import com.google.gerrit.common.data.GroupDescription;
|
||||||
import com.google.gerrit.common.data.GroupReference;
|
import com.google.gerrit.common.data.GroupReference;
|
||||||
import com.google.gerrit.exceptions.StorageException;
|
|
||||||
import com.google.gerrit.index.query.Predicate;
|
import com.google.gerrit.index.query.Predicate;
|
||||||
import com.google.gerrit.index.query.QueryParseException;
|
import com.google.gerrit.index.query.QueryParseException;
|
||||||
import com.google.gerrit.mail.Address;
|
import com.google.gerrit.mail.Address;
|
||||||
@@ -62,8 +61,7 @@ public class ProjectWatch {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/** Returns all watchers that are relevant */
|
/** Returns all watchers that are relevant */
|
||||||
public final Watchers getWatchers(NotifyType type, boolean includeWatchersFromNotifyConfig)
|
public final Watchers getWatchers(NotifyType type, boolean includeWatchersFromNotifyConfig) {
|
||||||
throws StorageException {
|
|
||||||
Watchers matching = new Watchers();
|
Watchers matching = new Watchers();
|
||||||
Set<Account.Id> projectWatchers = new HashSet<>();
|
Set<Account.Id> projectWatchers = new HashSet<>();
|
||||||
|
|
||||||
@@ -148,8 +146,7 @@ public class ProjectWatch {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void add(Watchers matching, NotifyConfig nc)
|
private void add(Watchers matching, NotifyConfig nc) throws QueryParseException {
|
||||||
throws StorageException, QueryParseException {
|
|
||||||
for (GroupReference ref : nc.getGroups()) {
|
for (GroupReference ref : nc.getGroups()) {
|
||||||
CurrentUser user = new SingleGroupUser(ref.getUUID());
|
CurrentUser user = new SingleGroupUser(ref.getUUID());
|
||||||
if (filterMatch(user, nc.getFilter())) {
|
if (filterMatch(user, nc.getFilter())) {
|
||||||
@@ -203,8 +200,7 @@ public class ProjectWatch {
|
|||||||
Account.Id accountId,
|
Account.Id accountId,
|
||||||
ProjectWatchKey key,
|
ProjectWatchKey key,
|
||||||
Set<NotifyType> watchedTypes,
|
Set<NotifyType> watchedTypes,
|
||||||
NotifyType type)
|
NotifyType type) {
|
||||||
throws StorageException {
|
|
||||||
IdentifiedUser user = args.identifiedUserFactory.create(accountId);
|
IdentifiedUser user = args.identifiedUserFactory.create(accountId);
|
||||||
|
|
||||||
try {
|
try {
|
||||||
@@ -222,8 +218,7 @@ public class ProjectWatch {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
private boolean filterMatch(CurrentUser user, String filter)
|
private boolean filterMatch(CurrentUser user, String filter) throws QueryParseException {
|
||||||
throws StorageException, QueryParseException {
|
|
||||||
ChangeQueryBuilder qb;
|
ChangeQueryBuilder qb;
|
||||||
Predicate<ChangeData> p = null;
|
Predicate<ChangeData> p = null;
|
||||||
|
|
||||||
|
@@ -15,7 +15,6 @@
|
|||||||
package com.google.gerrit.server.mail.send;
|
package com.google.gerrit.server.mail.send;
|
||||||
|
|
||||||
import com.google.gerrit.exceptions.EmailException;
|
import com.google.gerrit.exceptions.EmailException;
|
||||||
import com.google.gerrit.exceptions.StorageException;
|
|
||||||
import com.google.gerrit.extensions.api.changes.NotifyHandling;
|
import com.google.gerrit.extensions.api.changes.NotifyHandling;
|
||||||
import com.google.gerrit.extensions.api.changes.RecipientType;
|
import com.google.gerrit.extensions.api.changes.RecipientType;
|
||||||
import com.google.gerrit.reviewdb.client.Account;
|
import com.google.gerrit.reviewdb.client.Account;
|
||||||
@@ -41,8 +40,7 @@ public class ReplacePatchSetSender extends ReplyToChangeSender {
|
|||||||
|
|
||||||
@Inject
|
@Inject
|
||||||
public ReplacePatchSetSender(
|
public ReplacePatchSetSender(
|
||||||
EmailArguments ea, @Assisted Project.NameKey project, @Assisted Change.Id id)
|
EmailArguments ea, @Assisted Project.NameKey project, @Assisted Change.Id id) {
|
||||||
throws StorageException {
|
|
||||||
super(ea, "newpatchset", newChangeData(ea, project, id));
|
super(ea, "newpatchset", newChangeData(ea, project, id));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -15,7 +15,6 @@
|
|||||||
package com.google.gerrit.server.mail.send;
|
package com.google.gerrit.server.mail.send;
|
||||||
|
|
||||||
import com.google.gerrit.exceptions.EmailException;
|
import com.google.gerrit.exceptions.EmailException;
|
||||||
import com.google.gerrit.exceptions.StorageException;
|
|
||||||
import com.google.gerrit.extensions.api.changes.RecipientType;
|
import com.google.gerrit.extensions.api.changes.RecipientType;
|
||||||
import com.google.gerrit.reviewdb.client.Change;
|
import com.google.gerrit.reviewdb.client.Change;
|
||||||
import com.google.gerrit.reviewdb.client.Project;
|
import com.google.gerrit.reviewdb.client.Project;
|
||||||
@@ -27,8 +26,7 @@ public abstract class ReplyToChangeSender extends ChangeEmail {
|
|||||||
T create(Project.NameKey project, Change.Id id);
|
T create(Project.NameKey project, Change.Id id);
|
||||||
}
|
}
|
||||||
|
|
||||||
protected ReplyToChangeSender(EmailArguments ea, String mc, ChangeData cd)
|
protected ReplyToChangeSender(EmailArguments ea, String mc, ChangeData cd) {
|
||||||
throws StorageException {
|
|
||||||
super(ea, mc, cd);
|
super(ea, mc, cd);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -15,7 +15,6 @@
|
|||||||
package com.google.gerrit.server.mail.send;
|
package com.google.gerrit.server.mail.send;
|
||||||
|
|
||||||
import com.google.gerrit.exceptions.EmailException;
|
import com.google.gerrit.exceptions.EmailException;
|
||||||
import com.google.gerrit.exceptions.StorageException;
|
|
||||||
import com.google.gerrit.reviewdb.client.Change;
|
import com.google.gerrit.reviewdb.client.Change;
|
||||||
import com.google.gerrit.reviewdb.client.Project;
|
import com.google.gerrit.reviewdb.client.Project;
|
||||||
import com.google.gerrit.server.account.ProjectWatches.NotifyType;
|
import com.google.gerrit.server.account.ProjectWatches.NotifyType;
|
||||||
@@ -31,8 +30,7 @@ public class RestoredSender extends ReplyToChangeSender {
|
|||||||
|
|
||||||
@Inject
|
@Inject
|
||||||
public RestoredSender(
|
public RestoredSender(
|
||||||
EmailArguments ea, @Assisted Project.NameKey project, @Assisted Change.Id id)
|
EmailArguments ea, @Assisted Project.NameKey project, @Assisted Change.Id id) {
|
||||||
throws StorageException {
|
|
||||||
super(ea, "restore", ChangeEmail.newChangeData(ea, project, id));
|
super(ea, "restore", ChangeEmail.newChangeData(ea, project, id));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user