diff --git a/Documentation/dev-plugins.txt b/Documentation/dev-plugins.txt index bb59590c80..def1f152e9 100644 --- a/Documentation/dev-plugins.txt +++ b/Documentation/dev-plugins.txt @@ -455,7 +455,7 @@ its own custom event class derived from ---- import com.google.gerrit.common.EventDispatcher; import com.google.gerrit.extensions.registration.DynamicItem; -import com.google.gwtorm.server.OrmException; +import com.google.exceptions.StorageException; import com.google.inject.Inject; class MyPlugin { @@ -469,7 +469,7 @@ class MyPlugin { private void postEvent(MyPluginEvent event) { try { eventDispatcher.get().postEvent(event); - } catch (OrmException e) { + } catch (StorageException e) { // error handling } } diff --git a/java/com/google/gerrit/acceptance/AbstractDaemonTest.java b/java/com/google/gerrit/acceptance/AbstractDaemonTest.java index 2cc7b5946c..8513b42c93 100644 --- a/java/com/google/gerrit/acceptance/AbstractDaemonTest.java +++ b/java/com/google/gerrit/acceptance/AbstractDaemonTest.java @@ -53,6 +53,7 @@ import com.google.gerrit.common.data.Permission; import com.google.gerrit.common.data.PermissionRange; import com.google.gerrit.common.data.PermissionRule; 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.changes.ReviewInput; import com.google.gerrit.extensions.api.changes.RevisionApi; @@ -132,7 +133,6 @@ import com.google.gerrit.testing.FakeEmailSender; import com.google.gerrit.testing.FakeEmailSender.Message; import com.google.gerrit.testing.SshMode; import com.google.gson.Gson; -import com.google.gwtorm.server.OrmException; import com.google.inject.Inject; import com.google.inject.Module; import com.google.inject.Provider; @@ -1087,7 +1087,7 @@ public abstract class AbstractDaemonTest { .inOrder(); } - protected PatchSet getPatchSet(PatchSet.Id psId) throws OrmException { + protected PatchSet getPatchSet(PatchSet.Id psId) throws StorageException { return changeDataFactory.create(project, psId.getParentKey()).patchSet(psId); } @@ -1416,7 +1416,7 @@ public abstract class AbstractDaemonTest { } protected void watch(PushOneCommit.Result r, ProjectWatchInfoConfiguration config) - throws OrmException, RestApiException { + throws StorageException, RestApiException { watch(r.getChange().project().get(), config); } diff --git a/java/com/google/gerrit/acceptance/AccountCreator.java b/java/com/google/gerrit/acceptance/AccountCreator.java index 284f52cbda..5b9d631ef2 100644 --- a/java/com/google/gerrit/acceptance/AccountCreator.java +++ b/java/com/google/gerrit/acceptance/AccountCreator.java @@ -21,6 +21,7 @@ import com.google.common.collect.ImmutableSet; import com.google.common.collect.Sets; import com.google.gerrit.common.Nullable; 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.AccountGroup; import com.google.gerrit.server.ServerInitiated; @@ -31,7 +32,6 @@ import com.google.gerrit.server.group.InternalGroup; import com.google.gerrit.server.group.db.GroupsUpdate; import com.google.gerrit.server.group.db.InternalGroupUpdate; import com.google.gerrit.server.notedb.Sequences; -import com.google.gwtorm.server.OrmException; import com.google.inject.Inject; import com.google.inject.Provider; import com.google.inject.Singleton; @@ -157,7 +157,7 @@ public class AccountCreator { } private void addGroupMember(AccountGroup.UUID groupUuid, Account.Id accountId) - throws OrmException, IOException, NoSuchGroupException, ConfigInvalidException { + throws StorageException, IOException, NoSuchGroupException, ConfigInvalidException { InternalGroupUpdate groupUpdate = InternalGroupUpdate.builder() .setMemberModification(memberIds -> Sets.union(memberIds, ImmutableSet.of(accountId))) diff --git a/java/com/google/gerrit/acceptance/BUILD b/java/com/google/gerrit/acceptance/BUILD index 239ceca4b7..ed0de9cdfb 100644 --- a/java/com/google/gerrit/acceptance/BUILD +++ b/java/com/google/gerrit/acceptance/BUILD @@ -34,7 +34,6 @@ java_library( "//java/com/google/gerrit/server/restapi", "//java/com/google/gerrit/sshd", "//java/com/google/gerrit/testing:gerrit-test-util", - "//java/com/google/gwtorm", "//lib:args4j", "//lib:gson", "//lib:guava-retrying", @@ -117,7 +116,6 @@ java_library2( "//java/com/google/gerrit/server/schema", "//java/com/google/gerrit/server/util/time", "//java/com/google/gerrit/sshd", - "//java/com/google/gwtorm", "//lib:args4j", "//lib:gson", "//lib:guava-retrying", diff --git a/java/com/google/gerrit/acceptance/InMemoryTestingDatabaseModule.java b/java/com/google/gerrit/acceptance/InMemoryTestingDatabaseModule.java index 844d6c847c..9335146e1f 100644 --- a/java/com/google/gerrit/acceptance/InMemoryTestingDatabaseModule.java +++ b/java/com/google/gerrit/acceptance/InMemoryTestingDatabaseModule.java @@ -17,6 +17,8 @@ package com.google.gerrit.acceptance; import static com.google.inject.Scopes.SINGLETON; import com.google.gerrit.common.Nullable; +import com.google.gerrit.exceptions.StorageException; +import com.google.gerrit.exceptions.StorageRuntimeException; import com.google.gerrit.extensions.events.LifecycleListener; import com.google.gerrit.lifecycle.LifecycleModule; import com.google.gerrit.metrics.DisabledMetricMaker; @@ -30,8 +32,6 @@ import com.google.gerrit.server.git.GitRepositoryManager; import com.google.gerrit.server.schema.SchemaCreator; import com.google.gerrit.server.schema.SchemaModule; import com.google.gerrit.testing.InMemoryRepositoryManager; -import com.google.gwtorm.server.OrmException; -import com.google.gwtorm.server.OrmRuntimeException; import com.google.inject.Inject; import com.google.inject.ProvisionException; import java.io.IOException; @@ -91,8 +91,8 @@ class InMemoryTestingDatabaseModule extends LifecycleModule { public void start() { try { schemaCreator.ensureCreated(); - } catch (OrmException | IOException | ConfigInvalidException e) { - throw new OrmRuntimeException(e); + } catch (StorageException | IOException | ConfigInvalidException e) { + throw new StorageRuntimeException(e); } } diff --git a/java/com/google/gerrit/acceptance/PushOneCommit.java b/java/com/google/gerrit/acceptance/PushOneCommit.java index f16f1d3892..b9ade26ac2 100644 --- a/java/com/google/gerrit/acceptance/PushOneCommit.java +++ b/java/com/google/gerrit/acceptance/PushOneCommit.java @@ -24,6 +24,7 @@ import com.google.common.collect.ImmutableMap; import com.google.common.collect.Iterables; import com.google.common.collect.Sets; 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.Change; import com.google.gerrit.reviewdb.client.PatchSet; @@ -32,7 +33,6 @@ import com.google.gerrit.server.notedb.ChangeNotes; import com.google.gerrit.server.notedb.ReviewerStateInternal; import com.google.gerrit.server.query.change.ChangeData; import com.google.gerrit.server.query.change.InternalChangeQuery; -import com.google.gwtorm.server.OrmException; import com.google.inject.Provider; import com.google.inject.assistedinject.Assisted; import com.google.inject.assistedinject.AssistedInject; @@ -334,15 +334,15 @@ public class PushOneCommit { this.resSubj = subject; } - public ChangeData getChange() throws OrmException { + public ChangeData getChange() throws StorageException { return Iterables.getOnlyElement(queryProvider.get().byKeyPrefix(changeId)); } - public PatchSet getPatchSet() throws OrmException { + public PatchSet getPatchSet() throws StorageException { return getChange().currentPatchSet(); } - public PatchSet.Id getPatchSetId() throws OrmException { + public PatchSet.Id getPatchSetId() throws StorageException { return getChange().change().currentPatchSetId(); } @@ -360,7 +360,7 @@ public class PushOneCommit { public void assertChange( Change.Status expectedStatus, String expectedTopic, TestAccount... expectedReviewers) - throws OrmException { + throws StorageException { assertChange( expectedStatus, expectedTopic, Arrays.asList(expectedReviewers), ImmutableList.of()); } @@ -370,7 +370,7 @@ public class PushOneCommit { String expectedTopic, List expectedReviewers, List expectedCcs) - throws OrmException { + throws StorageException { Change c = getChange().change(); assertThat(c.getSubject()).isEqualTo(resSubj); assertThat(c.getStatus()).isEqualTo(expectedStatus); @@ -381,7 +381,7 @@ public class PushOneCommit { private void assertReviewers( Change c, ReviewerStateInternal state, List expectedReviewers) - throws OrmException { + throws StorageException { Iterable actualIds = approvalsUtil.getReviewers(notesFactory.createChecked(c)).byState(state); assertThat(actualIds) diff --git a/java/com/google/gerrit/acceptance/testsuite/account/AccountOperationsImpl.java b/java/com/google/gerrit/acceptance/testsuite/account/AccountOperationsImpl.java index 113c19c402..d57cb81fbc 100644 --- a/java/com/google/gerrit/acceptance/testsuite/account/AccountOperationsImpl.java +++ b/java/com/google/gerrit/acceptance/testsuite/account/AccountOperationsImpl.java @@ -16,6 +16,7 @@ package com.google.gerrit.acceptance.testsuite.account; 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.server.ServerInitiated; import com.google.gerrit.server.account.AccountState; @@ -24,7 +25,6 @@ import com.google.gerrit.server.account.AccountsUpdate; import com.google.gerrit.server.account.InternalAccountUpdate; import com.google.gerrit.server.account.externalids.ExternalId; import com.google.gerrit.server.notedb.Sequences; -import com.google.gwtorm.server.OrmException; import com.google.inject.Inject; import java.io.IOException; import java.util.Optional; @@ -68,7 +68,7 @@ public class AccountOperationsImpl implements AccountOperations { } private AccountState createAccount(AccountsUpdate.AccountUpdater accountUpdater) - throws OrmException, IOException, ConfigInvalidException { + throws StorageException, IOException, ConfigInvalidException { Account.Id accountId = new Account.Id(seq.nextAccountId()); return accountsUpdate.insert("Create Test Account", accountId, accountUpdater); } @@ -146,7 +146,7 @@ public class AccountOperationsImpl implements AccountOperations { } private void updateAccount(TestAccountUpdate accountUpdate) - throws OrmException, IOException, ConfigInvalidException { + throws StorageException, IOException, ConfigInvalidException { AccountsUpdate.AccountUpdater accountUpdater = (account, updateBuilder) -> fillBuilder(updateBuilder, accountUpdate, accountId); Optional updatedAccount = updateAccount(accountUpdater); @@ -154,7 +154,7 @@ public class AccountOperationsImpl implements AccountOperations { } private Optional updateAccount(AccountsUpdate.AccountUpdater accountUpdater) - throws OrmException, IOException, ConfigInvalidException { + throws StorageException, IOException, ConfigInvalidException { return accountsUpdate.update("Update Test Account", accountId, accountUpdater); } diff --git a/java/com/google/gerrit/acceptance/testsuite/group/GroupOperationsImpl.java b/java/com/google/gerrit/acceptance/testsuite/group/GroupOperationsImpl.java index 1cdded3d11..33c87dca57 100644 --- a/java/com/google/gerrit/acceptance/testsuite/group/GroupOperationsImpl.java +++ b/java/com/google/gerrit/acceptance/testsuite/group/GroupOperationsImpl.java @@ -16,7 +16,9 @@ package com.google.gerrit.acceptance.testsuite.group; import static com.google.common.base.Preconditions.checkState; +import com.google.gerrit.exceptions.DuplicateKeyException; import com.google.gerrit.exceptions.NoSuchGroupException; +import com.google.gerrit.exceptions.StorageException; import com.google.gerrit.reviewdb.client.AccountGroup; import com.google.gerrit.server.GerritPersonIdent; import com.google.gerrit.server.ServerInitiated; @@ -27,8 +29,6 @@ import com.google.gerrit.server.group.db.GroupsUpdate; import com.google.gerrit.server.group.db.InternalGroupCreation; import com.google.gerrit.server.group.db.InternalGroupUpdate; import com.google.gerrit.server.notedb.Sequences; -import com.google.gwtorm.server.OrmDuplicateKeyException; -import com.google.gwtorm.server.OrmException; import com.google.inject.Inject; import java.io.IOException; import java.util.Optional; @@ -70,7 +70,7 @@ public class GroupOperationsImpl implements GroupOperations { } private AccountGroup.UUID createNewGroup(TestGroupCreation groupCreation) - throws ConfigInvalidException, IOException, OrmException { + throws ConfigInvalidException, IOException, StorageException { InternalGroupCreation internalGroupCreation = toInternalGroupCreation(groupCreation); InternalGroupUpdate internalGroupUpdate = toInternalGroupUpdate(groupCreation); InternalGroup internalGroup = @@ -79,7 +79,7 @@ public class GroupOperationsImpl implements GroupOperations { } private InternalGroupCreation toInternalGroupCreation(TestGroupCreation groupCreation) - throws OrmException { + throws StorageException { AccountGroup.Id groupId = new AccountGroup.Id(seq.nextGroupId()); String groupName = groupCreation.name().orElse("group-with-id-" + groupId.get()); AccountGroup.UUID groupUuid = GroupUUID.make(groupName, serverIdent); @@ -148,7 +148,7 @@ public class GroupOperationsImpl implements GroupOperations { } private void updateGroup(TestGroupUpdate groupUpdate) - throws OrmDuplicateKeyException, NoSuchGroupException, ConfigInvalidException, IOException { + throws DuplicateKeyException, NoSuchGroupException, ConfigInvalidException, IOException { InternalGroupUpdate internalGroupUpdate = toInternalGroupUpdate(groupUpdate); groupsUpdate.updateGroup(groupUuid, internalGroupUpdate); } diff --git a/java/com/google/gerrit/elasticsearch/AbstractElasticIndex.java b/java/com/google/gerrit/elasticsearch/AbstractElasticIndex.java index 9669c375c1..97b64807b0 100644 --- a/java/com/google/gerrit/elasticsearch/AbstractElasticIndex.java +++ b/java/com/google/gerrit/elasticsearch/AbstractElasticIndex.java @@ -32,6 +32,7 @@ import com.google.gerrit.elasticsearch.ElasticMapping.MappingProperties; import com.google.gerrit.elasticsearch.builders.QueryBuilder; import com.google.gerrit.elasticsearch.builders.SearchSourceBuilder; import com.google.gerrit.elasticsearch.bulk.DeleteRequest; +import com.google.gerrit.exceptions.StorageException; import com.google.gerrit.index.FieldDef; import com.google.gerrit.index.FieldType; import com.google.gerrit.index.Index; @@ -53,7 +54,6 @@ import com.google.gson.JsonArray; import com.google.gson.JsonElement; import com.google.gson.JsonObject; import com.google.gson.JsonParser; -import com.google.gwtorm.server.OrmException; import com.google.protobuf.MessageLite; import java.io.IOException; import java.io.InputStream; @@ -377,16 +377,16 @@ abstract class AbstractElasticIndex implements Index { } @Override - public ResultSet read() throws OrmException { + public ResultSet read() throws StorageException { return readImpl((doc) -> AbstractElasticIndex.this.fromDocument(doc, opts.fields())); } @Override - public ResultSet readRaw() throws OrmException { + public ResultSet readRaw() throws StorageException { return readImpl(AbstractElasticIndex.this::toFieldBundle); } - private ResultSet readImpl(Function mapper) throws OrmException { + private ResultSet readImpl(Function mapper) throws StorageException { try { String uri = getURI(index, SEARCH); Response response = @@ -412,7 +412,7 @@ abstract class AbstractElasticIndex implements Index { } return new ListResultSet<>(ImmutableList.of()); } catch (IOException e) { - throw new OrmException(e); + throw new StorageException(e); } } } diff --git a/java/com/google/gerrit/elasticsearch/BUILD b/java/com/google/gerrit/elasticsearch/BUILD index 0b5ca490a5..f919aade4e 100644 --- a/java/com/google/gerrit/elasticsearch/BUILD +++ b/java/com/google/gerrit/elasticsearch/BUILD @@ -4,6 +4,7 @@ java_library( visibility = ["//visibility:public"], deps = [ "//java/com/google/gerrit/common:annotations", + "//java/com/google/gerrit/exceptions", "//java/com/google/gerrit/extensions:api", "//java/com/google/gerrit/index", "//java/com/google/gerrit/index:query_exception", @@ -12,7 +13,6 @@ java_library( "//java/com/google/gerrit/proto", "//java/com/google/gerrit/reviewdb:server", "//java/com/google/gerrit/server", - "//java/com/google/gwtorm", "//lib:gson", "//lib:guava", "//lib:protobuf", diff --git a/java/com/google/gerrit/elasticsearch/ElasticChangeIndex.java b/java/com/google/gerrit/elasticsearch/ElasticChangeIndex.java index 344e10c6d0..066bca78f3 100644 --- a/java/com/google/gerrit/elasticsearch/ElasticChangeIndex.java +++ b/java/com/google/gerrit/elasticsearch/ElasticChangeIndex.java @@ -33,6 +33,7 @@ import com.google.gerrit.elasticsearch.bulk.BulkRequest; import com.google.gerrit.elasticsearch.bulk.DeleteRequest; import com.google.gerrit.elasticsearch.bulk.IndexRequest; import com.google.gerrit.elasticsearch.bulk.UpdateRequest; +import com.google.gerrit.exceptions.StorageException; import com.google.gerrit.index.QueryOptions; import com.google.gerrit.index.Schema; import com.google.gerrit.index.query.DataSource; @@ -57,7 +58,6 @@ import com.google.gerrit.server.query.change.ChangeData; import com.google.gson.JsonArray; import com.google.gson.JsonElement; import com.google.gson.JsonObject; -import com.google.gwtorm.server.OrmException; import com.google.inject.Inject; import com.google.inject.assistedinject.Assisted; import java.io.IOException; @@ -119,7 +119,7 @@ class ElasticChangeIndex extends AbstractElasticIndex insertIndex = CLOSED_CHANGES; deleteIndex = OPEN_CHANGES; } - } catch (OrmException e) { + } catch (StorageException e) { throw new IOException(e); } diff --git a/java/com/google/gwtorm/server/OrmDuplicateKeyException.java b/java/com/google/gerrit/exceptions/DuplicateKeyException.java similarity index 78% rename from java/com/google/gwtorm/server/OrmDuplicateKeyException.java rename to java/com/google/gerrit/exceptions/DuplicateKeyException.java index c2840f5835..d052450f74 100644 --- a/java/com/google/gwtorm/server/OrmDuplicateKeyException.java +++ b/java/com/google/gerrit/exceptions/DuplicateKeyException.java @@ -12,17 +12,17 @@ // See the License for the specific language governing permissions and // limitations under the License. -package com.google.gwtorm.server; +package com.google.gerrit.exceptions; /** Indicates one or more entities were concurrently inserted with the same key. */ -public class OrmDuplicateKeyException extends OrmException { +public class DuplicateKeyException extends StorageException { private static final long serialVersionUID = 1L; - public OrmDuplicateKeyException(String msg) { + public DuplicateKeyException(String msg) { super(msg); } - public OrmDuplicateKeyException(String msg, Throwable why) { + public DuplicateKeyException(String msg, Throwable why) { super(msg, why); } } diff --git a/java/com/google/gwtorm/server/OrmRuntimeException.java b/java/com/google/gerrit/exceptions/StorageException.java similarity index 56% rename from java/com/google/gwtorm/server/OrmRuntimeException.java rename to java/com/google/gerrit/exceptions/StorageException.java index 84d1fafb4b..e97bdcd982 100644 --- a/java/com/google/gwtorm/server/OrmRuntimeException.java +++ b/java/com/google/gerrit/exceptions/StorageException.java @@ -12,21 +12,33 @@ // See the License for the specific language governing permissions and // limitations under the License. -package com.google.gwtorm.server; +package com.google.gerrit.exceptions; -/** Any data store read or write error. */ -public class OrmRuntimeException extends RuntimeException { +/** + * Any read/write error in a storage layer. + * + *

This includes but is not limited to: + * + *

    + *
  • NoteDb exceptions + *
  • Secondary index exceptions + *
  • {@code AccountPatchReviewStore} exceptions + *
  • Wrapped JGit exceptions + *
  • Other wrapped {@code IOException}s + *
+ */ +public class StorageException extends Exception { private static final long serialVersionUID = 1L; - public OrmRuntimeException(String message) { + public StorageException(String message) { super(message); } - public OrmRuntimeException(String message, Throwable why) { + public StorageException(String message, Throwable why) { super(message, why); } - public OrmRuntimeException(Throwable why) { + public StorageException(Throwable why) { super(why); } } diff --git a/java/com/google/gwtorm/server/OrmException.java b/java/com/google/gerrit/exceptions/StorageRuntimeException.java similarity index 73% rename from java/com/google/gwtorm/server/OrmException.java rename to java/com/google/gerrit/exceptions/StorageRuntimeException.java index c25a1d907b..7c501afb38 100644 --- a/java/com/google/gwtorm/server/OrmException.java +++ b/java/com/google/gerrit/exceptions/StorageRuntimeException.java @@ -12,21 +12,21 @@ // See the License for the specific language governing permissions and // limitations under the License. -package com.google.gwtorm.server; +package com.google.gerrit.exceptions; /** Any data store read or write error. */ -public class OrmException extends Exception { +public class StorageRuntimeException extends RuntimeException { private static final long serialVersionUID = 1L; - public OrmException(String message) { + public StorageRuntimeException(String message) { super(message); } - public OrmException(String message, Throwable why) { + public StorageRuntimeException(String message, Throwable why) { super(message, why); } - public OrmException(Throwable why) { + public StorageRuntimeException(Throwable why) { super(why); } } diff --git a/java/com/google/gerrit/gpg/BUILD b/java/com/google/gerrit/gpg/BUILD index 2633e9113a..fb93b03039 100644 --- a/java/com/google/gerrit/gpg/BUILD +++ b/java/com/google/gerrit/gpg/BUILD @@ -8,7 +8,6 @@ java_library( "//java/com/google/gerrit/extensions:api", "//java/com/google/gerrit/reviewdb:server", "//java/com/google/gerrit/server", - "//java/com/google/gwtorm", "//lib:guava", "//lib/bouncycastle:bcpg-neverlink", "//lib/bouncycastle:bcprov-neverlink", diff --git a/java/com/google/gerrit/gpg/GerritPublicKeyChecker.java b/java/com/google/gerrit/gpg/GerritPublicKeyChecker.java index b6ecbc5a2f..d05f4e7d24 100644 --- a/java/com/google/gerrit/gpg/GerritPublicKeyChecker.java +++ b/java/com/google/gerrit/gpg/GerritPublicKeyChecker.java @@ -22,6 +22,7 @@ import com.google.common.collect.ImmutableMap; import com.google.common.collect.Maps; import com.google.common.flogger.FluentLogger; import com.google.common.io.BaseEncoding; +import com.google.gerrit.exceptions.StorageException; import com.google.gerrit.extensions.registration.DynamicItem; import com.google.gerrit.server.IdentifiedUser; import com.google.gerrit.server.account.AccountState; @@ -29,7 +30,6 @@ import com.google.gerrit.server.account.externalids.ExternalId; import com.google.gerrit.server.config.GerritServerConfig; import com.google.gerrit.server.config.UrlFormatter; import com.google.gerrit.server.query.account.InternalAccountQuery; -import com.google.gwtorm.server.OrmException; import com.google.inject.Inject; import com.google.inject.Provider; import com.google.inject.Singleton; @@ -135,7 +135,7 @@ public class GerritPublicKeyChecker extends PublicKeyChecker { return checkIdsForExpectedUser(key); } return checkIdsForArbitraryUser(key); - } catch (PGPException | OrmException e) { + } catch (PGPException | StorageException e) { String msg = "Error checking user IDs for key"; logger.atWarning().withCause(e).log("%s %s", msg, keyIdToString(key.getKeyID())); return CheckResult.bad(msg); @@ -156,7 +156,8 @@ public class GerritPublicKeyChecker extends PublicKeyChecker { return CheckResult.bad(missingUserIds(allowedUserIds)); } - private CheckResult checkIdsForArbitraryUser(PGPPublicKey key) throws PGPException, OrmException { + private CheckResult checkIdsForArbitraryUser(PGPPublicKey key) + throws PGPException, StorageException { List accountStates = accountQueryProvider.get().byExternalId(toExtIdKey(key)); if (accountStates.isEmpty()) { return CheckResult.bad("Key is not associated with any users"); diff --git a/java/com/google/gerrit/gpg/api/GpgApiAdapterImpl.java b/java/com/google/gerrit/gpg/api/GpgApiAdapterImpl.java index 967259ad89..af943c2698 100644 --- a/java/com/google/gerrit/gpg/api/GpgApiAdapterImpl.java +++ b/java/com/google/gerrit/gpg/api/GpgApiAdapterImpl.java @@ -14,6 +14,7 @@ package com.google.gerrit.gpg.api; +import com.google.gerrit.exceptions.StorageException; import com.google.gerrit.extensions.api.accounts.GpgKeyApi; import com.google.gerrit.extensions.api.accounts.GpgKeysInput; import com.google.gerrit.extensions.common.GpgKeyInfo; @@ -28,7 +29,6 @@ import com.google.gerrit.server.GpgException; import com.google.gerrit.server.IdentifiedUser; import com.google.gerrit.server.account.AccountResource; import com.google.gerrit.server.account.GpgApiAdapter; -import com.google.gwtorm.server.OrmException; import com.google.inject.Inject; import com.google.inject.Provider; import java.io.IOException; @@ -67,7 +67,7 @@ public class GpgApiAdapterImpl implements GpgApiAdapter { throws RestApiException, GpgException { try { return gpgKeys.get().list().apply(account); - } catch (OrmException | PGPException | IOException e) { + } catch (StorageException | PGPException | IOException e) { throw new GpgException(e); } } @@ -81,7 +81,7 @@ public class GpgApiAdapterImpl implements GpgApiAdapter { in.delete = delete; try { return postGpgKeys.get().apply(account, in); - } catch (PGPException | OrmException | IOException | ConfigInvalidException e) { + } catch (PGPException | StorageException | IOException | ConfigInvalidException e) { throw new GpgException(e); } } @@ -91,7 +91,7 @@ public class GpgApiAdapterImpl implements GpgApiAdapter { throws RestApiException, GpgException { try { return gpgKeyApiFactory.create(gpgKeys.get().parse(account, idStr)); - } catch (PGPException | OrmException | IOException e) { + } catch (PGPException | StorageException | IOException e) { throw new GpgException(e); } } diff --git a/java/com/google/gerrit/gpg/api/GpgKeyApiImpl.java b/java/com/google/gerrit/gpg/api/GpgKeyApiImpl.java index 25b472d9f6..ce517a7abb 100644 --- a/java/com/google/gerrit/gpg/api/GpgKeyApiImpl.java +++ b/java/com/google/gerrit/gpg/api/GpgKeyApiImpl.java @@ -14,6 +14,7 @@ package com.google.gerrit.gpg.api; +import com.google.gerrit.exceptions.StorageException; import com.google.gerrit.extensions.api.accounts.GpgKeyApi; import com.google.gerrit.extensions.common.GpgKeyInfo; import com.google.gerrit.extensions.common.Input; @@ -21,7 +22,6 @@ import com.google.gerrit.extensions.restapi.RestApiException; import com.google.gerrit.gpg.server.DeleteGpgKey; import com.google.gerrit.gpg.server.GpgKey; import com.google.gerrit.gpg.server.GpgKeys; -import com.google.gwtorm.server.OrmException; import com.google.inject.Inject; import com.google.inject.assistedinject.Assisted; import java.io.IOException; @@ -57,7 +57,7 @@ public class GpgKeyApiImpl implements GpgKeyApi { public void delete() throws RestApiException { try { delete.apply(rsrc, new Input()); - } catch (PGPException | OrmException | IOException | ConfigInvalidException e) { + } catch (PGPException | StorageException | IOException | ConfigInvalidException e) { throw new RestApiException("Cannot delete GPG key", e); } } diff --git a/java/com/google/gerrit/gpg/server/DeleteGpgKey.java b/java/com/google/gerrit/gpg/server/DeleteGpgKey.java index a636a8b491..22c773fc3f 100644 --- a/java/com/google/gerrit/gpg/server/DeleteGpgKey.java +++ b/java/com/google/gerrit/gpg/server/DeleteGpgKey.java @@ -18,6 +18,7 @@ import static com.google.gerrit.gpg.PublicKeyStore.keyIdToString; import static com.google.gerrit.server.account.externalids.ExternalId.SCHEME_GPGKEY; import com.google.common.io.BaseEncoding; +import com.google.gerrit.exceptions.StorageException; import com.google.gerrit.extensions.common.Input; import com.google.gerrit.extensions.restapi.ResourceConflictException; import com.google.gerrit.extensions.restapi.ResourceNotFoundException; @@ -30,7 +31,6 @@ import com.google.gerrit.server.UserInitiated; import com.google.gerrit.server.account.AccountsUpdate; import com.google.gerrit.server.account.externalids.ExternalId; import com.google.gerrit.server.account.externalids.ExternalIds; -import com.google.gwtorm.server.OrmException; import com.google.inject.Inject; import com.google.inject.Provider; import java.io.IOException; @@ -63,7 +63,7 @@ public class DeleteGpgKey implements RestModifyView { @Override public Response apply(GpgKey rsrc, Input input) - throws RestApiException, PGPException, OrmException, IOException, ConfigInvalidException { + throws RestApiException, PGPException, StorageException, IOException, ConfigInvalidException { PGPPublicKey key = rsrc.getKeyRing().getPublicKey(); String fingerprint = BaseEncoding.base16().encode(key.getFingerprint()); Optional extId = externalIds.get(ExternalId.Key.create(SCHEME_GPGKEY, fingerprint)); diff --git a/java/com/google/gerrit/gpg/server/GpgKeys.java b/java/com/google/gerrit/gpg/server/GpgKeys.java index e555f07554..981aaee352 100644 --- a/java/com/google/gerrit/gpg/server/GpgKeys.java +++ b/java/com/google/gerrit/gpg/server/GpgKeys.java @@ -21,6 +21,7 @@ import com.google.common.base.CharMatcher; import com.google.common.collect.ImmutableList; import com.google.common.flogger.FluentLogger; import com.google.common.io.BaseEncoding; +import com.google.gerrit.exceptions.StorageException; import com.google.gerrit.extensions.common.GpgKeyInfo; import com.google.gerrit.extensions.registration.DynamicMap; import com.google.gerrit.extensions.restapi.AuthException; @@ -39,7 +40,6 @@ import com.google.gerrit.server.CurrentUser; import com.google.gerrit.server.account.AccountResource; import com.google.gerrit.server.account.externalids.ExternalId; import com.google.gerrit.server.account.externalids.ExternalIds; -import com.google.gwtorm.server.OrmException; import com.google.inject.Inject; import com.google.inject.Provider; import com.google.inject.Singleton; @@ -86,7 +86,7 @@ public class GpgKeys implements ChildCollection { @Override public GpgKey parse(AccountResource parent, IdString id) - throws ResourceNotFoundException, PGPException, OrmException, IOException { + throws ResourceNotFoundException, PGPException, StorageException, IOException { checkVisible(self, parent); ExternalId gpgKeyExtId = findGpgKey(id.get(), getGpgExtIds(parent)); @@ -142,7 +142,7 @@ public class GpgKeys implements ChildCollection { public class ListGpgKeys implements RestReadView { @Override public Map apply(AccountResource rsrc) - throws OrmException, PGPException, IOException, ResourceNotFoundException { + throws StorageException, PGPException, IOException, ResourceNotFoundException { checkVisible(self, rsrc); Map keys = new HashMap<>(); try (PublicKeyStore store = storeProvider.get()) { diff --git a/java/com/google/gerrit/gpg/server/PostGpgKeys.java b/java/com/google/gerrit/gpg/server/PostGpgKeys.java index df9723e167..6323ed139d 100644 --- a/java/com/google/gerrit/gpg/server/PostGpgKeys.java +++ b/java/com/google/gerrit/gpg/server/PostGpgKeys.java @@ -27,6 +27,7 @@ import com.google.common.collect.Maps; import com.google.common.flogger.FluentLogger; import com.google.common.io.BaseEncoding; 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.common.GpgKeyInfo; import com.google.gerrit.extensions.restapi.BadRequestException; @@ -50,7 +51,6 @@ import com.google.gerrit.server.account.externalids.ExternalId; import com.google.gerrit.server.account.externalids.ExternalIds; import com.google.gerrit.server.mail.send.AddKeySender; import com.google.gerrit.server.query.account.InternalAccountQuery; -import com.google.gwtorm.server.OrmException; import com.google.inject.Inject; import com.google.inject.Provider; import com.google.inject.Singleton; @@ -108,7 +108,7 @@ public class PostGpgKeys implements RestModifyView apply(AccountResource rsrc, GpgKeysInput input) throws ResourceNotFoundException, BadRequestException, ResourceConflictException, - PGPException, OrmException, IOException, ConfigInvalidException { + PGPException, StorageException, IOException, ConfigInvalidException { GpgKeys.checkVisible(self, rsrc); Collection existingExtIds = @@ -249,7 +249,7 @@ public class PostGpgKeys implements RestModifyView accountStates = accountQueryProvider.get().byExternalId(extIdKey); if (accountStates.isEmpty()) { diff --git a/java/com/google/gerrit/httpd/BUILD b/java/com/google/gerrit/httpd/BUILD index 5a196b4150..5ed8169363 100644 --- a/java/com/google/gerrit/httpd/BUILD +++ b/java/com/google/gerrit/httpd/BUILD @@ -10,6 +10,7 @@ java_library( deps = [ "//java/com/google/gerrit/common:annotations", "//java/com/google/gerrit/common:server", + "//java/com/google/gerrit/exceptions", "//java/com/google/gerrit/extensions:api", "//java/com/google/gerrit/git", "//java/com/google/gerrit/json", @@ -26,7 +27,6 @@ java_library( "//java/com/google/gerrit/server/util/time", "//java/com/google/gerrit/util/cli", "//java/com/google/gerrit/util/http", - "//java/com/google/gwtorm", "//java/org/eclipse/jgit:server", "//lib:args4j", "//lib:gson", diff --git a/java/com/google/gerrit/httpd/NumericChangeIdRedirectServlet.java b/java/com/google/gerrit/httpd/NumericChangeIdRedirectServlet.java index 164f957455..fdde08e268 100644 --- a/java/com/google/gerrit/httpd/NumericChangeIdRedirectServlet.java +++ b/java/com/google/gerrit/httpd/NumericChangeIdRedirectServlet.java @@ -15,13 +15,13 @@ package com.google.gerrit.httpd; import com.google.gerrit.common.PageLinks; +import com.google.gerrit.exceptions.StorageException; import com.google.gerrit.extensions.restapi.ResourceConflictException; import com.google.gerrit.extensions.restapi.ResourceNotFoundException; import com.google.gerrit.reviewdb.client.Change; import com.google.gerrit.server.change.ChangeResource; import com.google.gerrit.server.permissions.PermissionBackendException; import com.google.gerrit.server.restapi.change.ChangesCollection; -import com.google.gwtorm.server.OrmException; import com.google.inject.Inject; import com.google.inject.Singleton; import java.io.IOException; @@ -61,7 +61,7 @@ public class NumericChangeIdRedirectServlet extends HttpServlet { } catch (ResourceConflictException | ResourceNotFoundException e) { rsp.sendError(HttpServletResponse.SC_NOT_FOUND); return; - } catch (OrmException | PermissionBackendException e) { + } catch (StorageException | PermissionBackendException e) { throw new IOException("Unable to lookup change " + id.id, e); } String path = diff --git a/java/com/google/gerrit/httpd/RunAsFilter.java b/java/com/google/gerrit/httpd/RunAsFilter.java index 1ff8580f78..2af7243dc8 100644 --- a/java/com/google/gerrit/httpd/RunAsFilter.java +++ b/java/com/google/gerrit/httpd/RunAsFilter.java @@ -19,6 +19,7 @@ import static javax.servlet.http.HttpServletResponse.SC_FORBIDDEN; import static javax.servlet.http.HttpServletResponse.SC_INTERNAL_SERVER_ERROR; import com.google.common.flogger.FluentLogger; +import com.google.gerrit.exceptions.StorageException; import com.google.gerrit.extensions.registration.DynamicItem; import com.google.gerrit.extensions.restapi.AuthException; import com.google.gerrit.extensions.restapi.UnprocessableEntityException; @@ -29,7 +30,6 @@ import com.google.gerrit.server.config.AuthConfig; import com.google.gerrit.server.permissions.GlobalPermission; import com.google.gerrit.server.permissions.PermissionBackend; import com.google.gerrit.server.permissions.PermissionBackendException; -import com.google.gwtorm.server.OrmException; import com.google.inject.Inject; import com.google.inject.Singleton; import com.google.inject.servlet.ServletModule; @@ -110,7 +110,7 @@ class RunAsFilter implements Filter { } catch (UnprocessableEntityException e) { replyError(req, res, SC_FORBIDDEN, "no account matches " + RUN_AS, null); return; - } catch (OrmException | IOException | ConfigInvalidException e) { + } catch (StorageException | IOException | ConfigInvalidException e) { logger.atWarning().withCause(e).log("cannot resolve account for %s", RUN_AS); replyError(req, res, SC_INTERNAL_SERVER_ERROR, "cannot resolve " + RUN_AS, e); return; diff --git a/java/com/google/gerrit/httpd/auth/become/BecomeAnyAccountLoginServlet.java b/java/com/google/gerrit/httpd/auth/become/BecomeAnyAccountLoginServlet.java index d6ff2ec5bc..c647b822f0 100644 --- a/java/com/google/gerrit/httpd/auth/become/BecomeAnyAccountLoginServlet.java +++ b/java/com/google/gerrit/httpd/auth/become/BecomeAnyAccountLoginServlet.java @@ -18,6 +18,7 @@ import static com.google.gerrit.server.account.externalids.ExternalId.SCHEME_USE import static com.google.gerrit.server.account.externalids.ExternalId.SCHEME_UUID; import com.google.gerrit.common.PageLinks; +import com.google.gerrit.exceptions.StorageException; import com.google.gerrit.extensions.registration.DynamicItem; import com.google.gerrit.httpd.HtmlDomUtil; import com.google.gerrit.httpd.LoginUrlToken; @@ -34,7 +35,6 @@ import com.google.gerrit.server.account.AuthResult; import com.google.gerrit.server.account.externalids.ExternalId; import com.google.gerrit.server.query.account.InternalAccountQuery; import com.google.gerrit.util.http.CacheHeaders; -import com.google.gwtorm.server.OrmException; import com.google.inject.Inject; import com.google.inject.Provider; import com.google.inject.Singleton; @@ -200,7 +200,7 @@ class BecomeAnyAccountLoginServlet extends HttpServlet { return null; } return auth(accountStates.get(0).getAccount().getId()); - } catch (OrmException e) { + } catch (StorageException e) { getServletContext().log("cannot query account index", e); return null; } @@ -211,7 +211,7 @@ class BecomeAnyAccountLoginServlet extends HttpServlet { Optional match = queryProvider.get().byPreferredEmail(email).stream().findFirst(); return auth(match); - } catch (OrmException e) { + } catch (StorageException e) { getServletContext().log("cannot query database", e); return Optional.empty(); } diff --git a/java/com/google/gerrit/httpd/auth/container/HttpLoginServlet.java b/java/com/google/gerrit/httpd/auth/container/HttpLoginServlet.java index fd2f6282bf..728ace7cd3 100644 --- a/java/com/google/gerrit/httpd/auth/container/HttpLoginServlet.java +++ b/java/com/google/gerrit/httpd/auth/container/HttpLoginServlet.java @@ -19,6 +19,7 @@ import static java.nio.charset.StandardCharsets.UTF_8; import com.google.common.flogger.FluentLogger; import com.google.gerrit.common.PageLinks; +import com.google.gerrit.exceptions.StorageException; import com.google.gerrit.extensions.registration.DynamicItem; import com.google.gerrit.httpd.CanonicalWebUrl; import com.google.gerrit.httpd.HtmlDomUtil; @@ -31,7 +32,6 @@ import com.google.gerrit.server.account.AuthResult; import com.google.gerrit.server.account.externalids.ExternalId; import com.google.gerrit.server.config.AuthConfig; import com.google.gerrit.util.http.CacheHeaders; -import com.google.gwtorm.server.OrmException; import com.google.inject.Inject; import com.google.inject.Singleton; import java.io.IOException; @@ -128,7 +128,7 @@ class HttpLoginServlet extends HttpServlet { logger.atFine().log( "Associating external identity \"%s\" to user \"%s\"", remoteExternalId, user); updateRemoteExternalId(arsp, remoteExternalId); - } catch (AccountException | OrmException | ConfigInvalidException e) { + } catch (AccountException | StorageException | ConfigInvalidException e) { logger.atSevere().withCause(e).log( "Unable to associate external identity \"%s\" to user \"%s\"", remoteExternalId, user); rsp.sendError(HttpServletResponse.SC_FORBIDDEN); @@ -152,7 +152,7 @@ class HttpLoginServlet extends HttpServlet { } private void updateRemoteExternalId(AuthResult arsp, String remoteAuthToken) - throws AccountException, OrmException, IOException, ConfigInvalidException { + throws AccountException, StorageException, IOException, ConfigInvalidException { accountManager.updateLink( arsp.getAccountId(), new AuthRequest(ExternalId.Key.create(SCHEME_EXTERNAL, remoteAuthToken))); diff --git a/java/com/google/gerrit/httpd/auth/oauth/BUILD b/java/com/google/gerrit/httpd/auth/oauth/BUILD index 753a765f4f..dd3e5fc044 100644 --- a/java/com/google/gerrit/httpd/auth/oauth/BUILD +++ b/java/com/google/gerrit/httpd/auth/oauth/BUILD @@ -6,12 +6,12 @@ java_library( visibility = ["//visibility:public"], deps = [ "//java/com/google/gerrit/common:annotations", + "//java/com/google/gerrit/exceptions", "//java/com/google/gerrit/extensions:api", "//java/com/google/gerrit/httpd", "//java/com/google/gerrit/reviewdb:server", "//java/com/google/gerrit/server", "//java/com/google/gerrit/server/audit", - "//java/com/google/gwtorm", "//lib:gson", "//lib:guava", "//lib:servlet-api-3_1", diff --git a/java/com/google/gerrit/httpd/auth/oauth/OAuthSession.java b/java/com/google/gerrit/httpd/auth/oauth/OAuthSession.java index b780fa01e4..5344d21b90 100644 --- a/java/com/google/gerrit/httpd/auth/oauth/OAuthSession.java +++ b/java/com/google/gerrit/httpd/auth/oauth/OAuthSession.java @@ -19,6 +19,7 @@ import static javax.servlet.http.HttpServletResponse.SC_UNAUTHORIZED; import com.google.common.base.CharMatcher; import com.google.common.base.Strings; import com.google.common.flogger.FluentLogger; +import com.google.gerrit.exceptions.StorageException; import com.google.gerrit.extensions.auth.oauth.OAuthServiceProvider; import com.google.gerrit.extensions.auth.oauth.OAuthToken; import com.google.gerrit.extensions.auth.oauth.OAuthUserInfo; @@ -35,7 +36,6 @@ import com.google.gerrit.server.account.AuthRequest; import com.google.gerrit.server.account.AuthResult; import com.google.gerrit.server.account.externalids.ExternalId; import com.google.gerrit.server.auth.oauth.OAuthTokenCache; -import com.google.gwtorm.server.OrmException; import com.google.inject.Inject; import com.google.inject.Provider; import com.google.inject.servlet.SessionScoped; @@ -188,7 +188,7 @@ class OAuthSession { logger.atInfo().log("OAuth2: linking claimed identity to %s", claimedId.get().toString()); try { accountManager.link(claimedId.get(), req); - } catch (OrmException | ConfigInvalidException e) { + } catch (StorageException | ConfigInvalidException e) { logger.atSevere().log( "Cannot link: %s to user identity:\n Claimed ID: %s is %s", user.getExternalId(), claimedId.get(), claimedIdentifier); @@ -203,7 +203,7 @@ class OAuthSession { throws AccountException, IOException { try { accountManager.link(identifiedUser.get().getAccountId(), areq); - } catch (OrmException | ConfigInvalidException e) { + } catch (StorageException | ConfigInvalidException e) { logger.atSevere().log( "Cannot link: %s to user identity: %s", user.getExternalId(), identifiedUser.get().getAccountId()); diff --git a/java/com/google/gerrit/httpd/auth/openid/BUILD b/java/com/google/gerrit/httpd/auth/openid/BUILD index a4c1466eeb..f09f93def1 100644 --- a/java/com/google/gerrit/httpd/auth/openid/BUILD +++ b/java/com/google/gerrit/httpd/auth/openid/BUILD @@ -8,6 +8,7 @@ java_library( # We want all these deps to be provided_deps "//java/com/google/gerrit/common:annotations", "//java/com/google/gerrit/common:server", + "//java/com/google/gerrit/exceptions", "//java/com/google/gerrit/extensions:api", "//java/com/google/gerrit/httpd", "//java/com/google/gerrit/reviewdb:server", diff --git a/java/com/google/gerrit/httpd/auth/openid/OAuthSessionOverOpenID.java b/java/com/google/gerrit/httpd/auth/openid/OAuthSessionOverOpenID.java index a51a0abedc..48886da1c9 100644 --- a/java/com/google/gerrit/httpd/auth/openid/OAuthSessionOverOpenID.java +++ b/java/com/google/gerrit/httpd/auth/openid/OAuthSessionOverOpenID.java @@ -18,6 +18,7 @@ import static javax.servlet.http.HttpServletResponse.SC_UNAUTHORIZED; import com.google.common.base.Strings; import com.google.common.flogger.FluentLogger; +import com.google.gerrit.exceptions.StorageException; import com.google.gerrit.extensions.auth.oauth.OAuthServiceProvider; import com.google.gerrit.extensions.auth.oauth.OAuthToken; import com.google.gerrit.extensions.auth.oauth.OAuthUserInfo; @@ -33,7 +34,6 @@ import com.google.gerrit.server.account.AccountException; import com.google.gerrit.server.account.AccountManager; import com.google.gerrit.server.account.AuthResult; import com.google.gerrit.server.account.externalids.ExternalId; -import com.google.gwtorm.server.OrmException; import com.google.inject.Inject; import com.google.inject.Provider; import com.google.inject.servlet.SessionScoped; @@ -164,7 +164,7 @@ class OAuthSessionOverOpenID { logger.atFine().log("Claimed account already exists: link to it."); try { accountManager.link(claimedId.get(), areq); - } catch (OrmException | ConfigInvalidException e) { + } catch (StorageException | ConfigInvalidException e) { logger.atSevere().log( "Cannot link: %s to user identity:\n Claimed ID: %s is %s", user.getExternalId(), claimedId.get(), claimedIdentifier); @@ -178,7 +178,7 @@ class OAuthSessionOverOpenID { try { logger.atFine().log("Linking \"%s\" to \"%s\"", user.getExternalId(), accountId); accountManager.link(accountId, areq); - } catch (OrmException | ConfigInvalidException e) { + } catch (StorageException | ConfigInvalidException e) { logger.atSevere().log( "Cannot link: %s to user identity: %s", user.getExternalId(), accountId); rsp.sendError(HttpServletResponse.SC_FORBIDDEN); diff --git a/java/com/google/gerrit/httpd/init/BUILD b/java/com/google/gerrit/httpd/init/BUILD index f547bfac8b..df072b24f2 100644 --- a/java/com/google/gerrit/httpd/init/BUILD +++ b/java/com/google/gerrit/httpd/init/BUILD @@ -25,7 +25,6 @@ java_library( "//java/com/google/gerrit/server/restapi", "//java/com/google/gerrit/server/schema", "//java/com/google/gerrit/sshd", - "//java/com/google/gwtorm", "//lib:guava", "//lib:servlet-api-3_1", "//lib/flogger:api", diff --git a/java/com/google/gerrit/httpd/raw/CatServlet.java b/java/com/google/gerrit/httpd/raw/CatServlet.java index 1e60d31742..1739c03840 100644 --- a/java/com/google/gerrit/httpd/raw/CatServlet.java +++ b/java/com/google/gerrit/httpd/raw/CatServlet.java @@ -14,6 +14,7 @@ package com.google.gerrit.httpd.raw; +import com.google.gerrit.exceptions.StorageException; import com.google.gerrit.extensions.restapi.AuthException; import com.google.gerrit.extensions.restapi.ResourceConflictException; import com.google.gerrit.extensions.restapi.Url; @@ -29,7 +30,6 @@ import com.google.gerrit.server.permissions.PermissionBackend; import com.google.gerrit.server.permissions.PermissionBackendException; import com.google.gerrit.server.project.NoSuchChangeException; import com.google.gerrit.server.project.ProjectCache; -import com.google.gwtorm.server.OrmException; import com.google.inject.Inject; import com.google.inject.Singleton; import java.io.IOException; @@ -145,7 +145,7 @@ public class CatServlet extends HttpServlet { } catch (ResourceConflictException | NoSuchChangeException | AuthException e) { rsp.sendError(HttpServletResponse.SC_NOT_FOUND); return; - } catch (OrmException | PermissionBackendException | IOException e) { + } catch (StorageException | PermissionBackendException | IOException e) { getServletContext().log("Cannot query database", e); rsp.sendError(HttpServletResponse.SC_INTERNAL_SERVER_ERROR); return; diff --git a/java/com/google/gerrit/index/BUILD b/java/com/google/gerrit/index/BUILD index de7ed0cb58..dfdc01428f 100644 --- a/java/com/google/gerrit/index/BUILD +++ b/java/com/google/gerrit/index/BUILD @@ -20,12 +20,12 @@ java_library( ":query_exception", "//antlr3:query_parser", "//java/com/google/gerrit/common:annotations", + "//java/com/google/gerrit/exceptions", "//java/com/google/gerrit/extensions:api", "//java/com/google/gerrit/json", "//java/com/google/gerrit/metrics", "//java/com/google/gerrit/reviewdb:server", "//java/com/google/gerrit/server/logging", - "//java/com/google/gwtorm", "//lib:guava", "//lib/antlr:java-runtime", "//lib/auto:auto-value", diff --git a/java/com/google/gerrit/index/FieldDef.java b/java/com/google/gerrit/index/FieldDef.java index f565e52ad7..4e86c10a92 100644 --- a/java/com/google/gerrit/index/FieldDef.java +++ b/java/com/google/gerrit/index/FieldDef.java @@ -19,7 +19,7 @@ import static java.util.Objects.requireNonNull; import com.google.common.base.CharMatcher; import com.google.gerrit.common.Nullable; -import com.google.gwtorm.server.OrmException; +import com.google.gerrit.exceptions.StorageException; import java.io.IOException; import java.sql.Timestamp; @@ -62,7 +62,7 @@ public final class FieldDef { @FunctionalInterface public interface Getter { @Nullable - T get(I input) throws OrmException, IOException; + T get(I input) throws StorageException, IOException; } public static class Builder { @@ -133,14 +133,14 @@ public final class FieldDef { * * @param input input object. * @return the field value(s) to index. - * @throws OrmException + * @throws StorageException */ @Nullable - public T get(I input) throws OrmException { + public T get(I input) throws StorageException { try { return getter.get(input); } catch (IOException e) { - throw new OrmException(e); + throw new StorageException(e); } } diff --git a/java/com/google/gerrit/index/Index.java b/java/com/google/gerrit/index/Index.java index f60c08fe6f..e78604990a 100644 --- a/java/com/google/gerrit/index/Index.java +++ b/java/com/google/gerrit/index/Index.java @@ -15,12 +15,12 @@ package com.google.gerrit.index; import com.google.common.collect.ImmutableList; +import com.google.gerrit.exceptions.StorageException; import com.google.gerrit.index.query.DataSource; import com.google.gerrit.index.query.FieldBundle; import com.google.gerrit.index.query.IndexPredicate; import com.google.gerrit.index.query.Predicate; import com.google.gerrit.index.query.QueryParseException; -import com.google.gwtorm.server.OrmException; import java.io.IOException; import java.util.Optional; @@ -100,7 +100,7 @@ public interface Index { results = getSource(keyPredicate(key), opts).read().toList(); } catch (QueryParseException e) { throw new IOException("Unexpected QueryParseException during get()", e); - } catch (OrmException e) { + } catch (StorageException e) { throw new IOException(e); } if (results.size() > 1) { @@ -125,7 +125,7 @@ public interface Index { results = getSource(keyPredicate(key), opts).readRaw().toList(); } catch (QueryParseException e) { throw new IOException("Unexpected QueryParseException during get()", e); - } catch (OrmException e) { + } catch (StorageException e) { throw new IOException(e); } if (results.size() > 1) { diff --git a/java/com/google/gerrit/index/Schema.java b/java/com/google/gerrit/index/Schema.java index 2b3c63e4f3..821e8204b8 100644 --- a/java/com/google/gerrit/index/Schema.java +++ b/java/com/google/gerrit/index/Schema.java @@ -22,7 +22,7 @@ import com.google.common.collect.FluentIterable; import com.google.common.collect.ImmutableList; import com.google.common.collect.ImmutableMap; import com.google.common.flogger.FluentLogger; -import com.google.gwtorm.server.OrmException; +import com.google.gerrit.exceptions.StorageException; import java.util.ArrayList; import java.util.Arrays; import java.util.Collections; @@ -179,7 +179,7 @@ public class Schema { Object v; try { v = f.get(obj); - } catch (OrmException e) { + } catch (StorageException e) { logger.atSevere().withCause(e).log( "error getting field %s of %s", f.getName(), obj); return null; diff --git a/java/com/google/gerrit/index/query/AndPredicate.java b/java/com/google/gerrit/index/query/AndPredicate.java index 7fba05fccf..639f75ae51 100644 --- a/java/com/google/gerrit/index/query/AndPredicate.java +++ b/java/com/google/gerrit/index/query/AndPredicate.java @@ -16,7 +16,7 @@ package com.google.gerrit.index.query; import static com.google.common.base.Preconditions.checkState; -import com.google.gwtorm.server.OrmException; +import com.google.gerrit.exceptions.StorageException; import java.util.ArrayList; import java.util.Arrays; import java.util.Collection; @@ -82,7 +82,7 @@ public class AndPredicate extends Predicate implements Matchable { } @Override - public boolean match(T object) throws OrmException { + public boolean match(T object) throws StorageException { for (Predicate c : children) { checkState( c.isMatchable(), diff --git a/java/com/google/gerrit/index/query/AndSource.java b/java/com/google/gerrit/index/query/AndSource.java index 649dc32a02..40ffeac940 100644 --- a/java/com/google/gerrit/index/query/AndSource.java +++ b/java/com/google/gerrit/index/query/AndSource.java @@ -21,8 +21,8 @@ import com.google.common.base.Throwables; import com.google.common.collect.FluentIterable; import com.google.common.collect.ImmutableList; import com.google.common.collect.Iterables; -import com.google.gwtorm.server.OrmException; -import com.google.gwtorm.server.OrmRuntimeException; +import com.google.gerrit.exceptions.StorageException; +import com.google.gerrit.exceptions.StorageRuntimeException; import java.util.ArrayList; import java.util.Collection; import java.util.Comparator; @@ -76,26 +76,26 @@ public class AndSource extends AndPredicate } @Override - public ResultSet read() throws OrmException { + public ResultSet read() throws StorageException { try { return readImpl(); - } catch (OrmRuntimeException err) { + } catch (StorageRuntimeException err) { if (err.getCause() != null) { - Throwables.throwIfInstanceOf(err.getCause(), OrmException.class); + Throwables.throwIfInstanceOf(err.getCause(), StorageException.class); } - throw new OrmException(err); + throw new StorageException(err); } } @Override - public ResultSet readRaw() throws OrmException { + public ResultSet readRaw() throws StorageException { // TOOD(hiesel): Implement throw new UnsupportedOperationException("not implemented"); } - private ResultSet readImpl() throws OrmException { + private ResultSet readImpl() throws StorageException { if (source == null) { - throw new OrmException("No DataSource: " + this); + throw new StorageException("No DataSource: " + this); } List r = new ArrayList<>(); T last = null; @@ -147,7 +147,7 @@ public class AndSource extends AndPredicate } @Override - public boolean match(T object) throws OrmException { + public boolean match(T object) throws StorageException { if (isVisibleToPredicate != null && !isVisibleToPredicate.match(object)) { return false; } @@ -164,7 +164,7 @@ public class AndSource extends AndPredicate .transformAndConcat(this::transformBuffer); } - protected List transformBuffer(List buffer) throws OrmRuntimeException { + protected List transformBuffer(List buffer) throws StorageRuntimeException { return buffer; } diff --git a/java/com/google/gerrit/index/query/DataSource.java b/java/com/google/gerrit/index/query/DataSource.java index a82337f1b4..33fe5f67c7 100644 --- a/java/com/google/gerrit/index/query/DataSource.java +++ b/java/com/google/gerrit/index/query/DataSource.java @@ -14,15 +14,15 @@ package com.google.gerrit.index.query; -import com.google.gwtorm.server.OrmException; +import com.google.gerrit.exceptions.StorageException; public interface DataSource { /** @return an estimate of the number of results from {@link #read()}. */ int getCardinality(); /** @return read from the database and return the results. */ - ResultSet read() throws OrmException; + ResultSet read() throws StorageException; /** @return read from the database and return the raw results. */ - ResultSet readRaw() throws OrmException; + ResultSet readRaw() throws StorageException; } diff --git a/java/com/google/gerrit/index/query/IndexedQuery.java b/java/com/google/gerrit/index/query/IndexedQuery.java index 8df46a7b30..b3a5d65257 100644 --- a/java/com/google/gerrit/index/query/IndexedQuery.java +++ b/java/com/google/gerrit/index/query/IndexedQuery.java @@ -16,9 +16,9 @@ package com.google.gerrit.index.query; import com.google.common.base.MoreObjects; import com.google.common.collect.ImmutableList; +import com.google.gerrit.exceptions.StorageException; import com.google.gerrit.index.Index; import com.google.gerrit.index.QueryOptions; -import com.google.gwtorm.server.OrmException; import java.util.Collection; import java.util.List; @@ -77,17 +77,17 @@ public class IndexedQuery extends Predicate implements DataSource, P } @Override - public ResultSet read() throws OrmException { + public ResultSet read() throws StorageException { return source.read(); } @Override - public ResultSet readRaw() throws OrmException { + public ResultSet readRaw() throws StorageException { return source.readRaw(); } @Override - public ResultSet restart(int start) throws OrmException { + public ResultSet restart(int start) throws StorageException { opts = opts.withStart(start); try { source = index.getSource(pred, opts); @@ -95,7 +95,7 @@ public class IndexedQuery extends Predicate implements DataSource, P // Don't need to show this exception to the user; the only thing that // changed about pred was its start, and any other QPEs that might happen // should have already thrown from the constructor. - throw new OrmException(e); + throw new StorageException(e); } // Don't convert start to a limit, since the caller of this method (see // AndSource) has calculated the actual number to skip. diff --git a/java/com/google/gerrit/index/query/IntegerRangePredicate.java b/java/com/google/gerrit/index/query/IntegerRangePredicate.java index 66351a8f45..7475da33b9 100644 --- a/java/com/google/gerrit/index/query/IntegerRangePredicate.java +++ b/java/com/google/gerrit/index/query/IntegerRangePredicate.java @@ -14,9 +14,9 @@ package com.google.gerrit.index.query; +import com.google.gerrit.exceptions.StorageException; import com.google.gerrit.index.FieldDef; import com.google.gerrit.index.query.RangeUtil.Range; -import com.google.gwtorm.server.OrmException; public abstract class IntegerRangePredicate extends IndexPredicate { private final Range range; @@ -30,9 +30,9 @@ public abstract class IntegerRangePredicate extends IndexPredicate { } } - protected abstract Integer getValueInt(T object) throws OrmException; + protected abstract Integer getValueInt(T object) throws StorageException; - public boolean match(T object) throws OrmException { + public boolean match(T object) throws StorageException { Integer valueInt = getValueInt(object); if (valueInt == null) { return false; diff --git a/java/com/google/gerrit/index/query/InternalQuery.java b/java/com/google/gerrit/index/query/InternalQuery.java index ca5cc9b870..420c9c131f 100644 --- a/java/com/google/gerrit/index/query/InternalQuery.java +++ b/java/com/google/gerrit/index/query/InternalQuery.java @@ -20,12 +20,12 @@ import static java.util.stream.Collectors.toSet; import com.google.common.collect.ImmutableList; import com.google.common.collect.ImmutableSet; import com.google.common.collect.Lists; +import com.google.gerrit.exceptions.StorageException; import com.google.gerrit.index.FieldDef; import com.google.gerrit.index.Index; import com.google.gerrit.index.IndexCollection; import com.google.gerrit.index.IndexConfig; import com.google.gerrit.index.Schema; -import com.google.gwtorm.server.OrmException; import java.util.Arrays; import java.util.List; import java.util.function.Supplier; @@ -88,15 +88,15 @@ public class InternalQuery> { return self(); } - public final List query(Predicate p) throws OrmException { + public final List query(Predicate p) throws StorageException { return queryResults(p).entities(); } - final QueryResult queryResults(Predicate p) throws OrmException { + final QueryResult queryResults(Predicate p) throws StorageException { try { return queryProcessor.query(p); } catch (QueryParseException e) { - throw new OrmException(e); + throw new StorageException(e); } } @@ -110,11 +110,11 @@ public class InternalQuery> { * @return results of the queries, one list of results per input query, in the same order as the * input. */ - public final List> query(List> queries) throws OrmException { + public final List> query(List> queries) throws StorageException { try { return Lists.transform(queryProcessor.query(queries), QueryResult::entities); } catch (QueryParseException e) { - throw new OrmException(e); + throw new StorageException(e); } } @@ -144,11 +144,11 @@ public class InternalQuery> { * @param predicate predicate to search for. * @param result type. * @return exhaustive list of results, subject to the race condition described above. - * @throws OrmException if an error occurred. + * @throws StorageException if an error occurred. */ protected static ImmutableList queryExhaustively( Supplier> querySupplier, Predicate predicate) - throws OrmException { + throws StorageException { ImmutableList.Builder b = null; int start = 0; while (true) { diff --git a/java/com/google/gerrit/index/query/Matchable.java b/java/com/google/gerrit/index/query/Matchable.java index 3d07943874..b4e6308f07 100644 --- a/java/com/google/gerrit/index/query/Matchable.java +++ b/java/com/google/gerrit/index/query/Matchable.java @@ -14,15 +14,15 @@ package com.google.gerrit.index.query; -import com.google.gwtorm.server.OrmException; +import com.google.gerrit.exceptions.StorageException; public interface Matchable { /** * Does this predicate match this object? * - * @throws OrmException + * @throws StorageException */ - boolean match(T object) throws OrmException; + boolean match(T object) throws StorageException; /** @return a cost estimate to run this predicate, higher figures cost more. */ int getCost(); diff --git a/java/com/google/gerrit/index/query/NotPredicate.java b/java/com/google/gerrit/index/query/NotPredicate.java index 750759d24c..f198e41b1c 100644 --- a/java/com/google/gerrit/index/query/NotPredicate.java +++ b/java/com/google/gerrit/index/query/NotPredicate.java @@ -16,7 +16,7 @@ package com.google.gerrit.index.query; import static com.google.common.base.Preconditions.checkState; -import com.google.gwtorm.server.OrmException; +import com.google.gerrit.exceptions.StorageException; import java.util.Collection; import java.util.Collections; import java.util.List; @@ -64,7 +64,7 @@ public class NotPredicate extends Predicate implements Matchable { } @Override - public boolean match(T object) throws OrmException { + public boolean match(T object) throws StorageException { checkState( that.isMatchable(), "match invoked, but child predicate %s doesn't implement %s", diff --git a/java/com/google/gerrit/index/query/OrPredicate.java b/java/com/google/gerrit/index/query/OrPredicate.java index 8c3ed1c596..22dd75dc5f 100644 --- a/java/com/google/gerrit/index/query/OrPredicate.java +++ b/java/com/google/gerrit/index/query/OrPredicate.java @@ -16,7 +16,7 @@ package com.google.gerrit.index.query; import static com.google.common.base.Preconditions.checkState; -import com.google.gwtorm.server.OrmException; +import com.google.gerrit.exceptions.StorageException; import java.util.ArrayList; import java.util.Arrays; import java.util.Collection; @@ -82,7 +82,7 @@ public class OrPredicate extends Predicate implements Matchable { } @Override - public boolean match(T object) throws OrmException { + public boolean match(T object) throws StorageException { for (Predicate c : children) { checkState( c.isMatchable(), diff --git a/java/com/google/gerrit/index/query/Paginated.java b/java/com/google/gerrit/index/query/Paginated.java index c11d8c7440..1bcf613552 100644 --- a/java/com/google/gerrit/index/query/Paginated.java +++ b/java/com/google/gerrit/index/query/Paginated.java @@ -14,11 +14,11 @@ package com.google.gerrit.index.query; +import com.google.gerrit.exceptions.StorageException; import com.google.gerrit.index.QueryOptions; -import com.google.gwtorm.server.OrmException; public interface Paginated { QueryOptions getOptions(); - ResultSet restart(int start) throws OrmException; + ResultSet restart(int start) throws StorageException; } diff --git a/java/com/google/gerrit/index/query/QueryProcessor.java b/java/com/google/gerrit/index/query/QueryProcessor.java index c68f6743df..8466849fb0 100644 --- a/java/com/google/gerrit/index/query/QueryProcessor.java +++ b/java/com/google/gerrit/index/query/QueryProcessor.java @@ -26,6 +26,8 @@ import com.google.common.collect.ImmutableSet; import com.google.common.collect.Ordering; import com.google.common.flogger.FluentLogger; import com.google.gerrit.common.Nullable; +import com.google.gerrit.exceptions.StorageException; +import com.google.gerrit.exceptions.StorageRuntimeException; import com.google.gerrit.index.Index; import com.google.gerrit.index.IndexCollection; import com.google.gerrit.index.IndexConfig; @@ -37,8 +39,6 @@ import com.google.gerrit.metrics.Field; import com.google.gerrit.metrics.MetricMaker; import com.google.gerrit.metrics.Timer1; import com.google.gerrit.server.logging.CallerFinder; -import com.google.gwtorm.server.OrmException; -import com.google.gwtorm.server.OrmRuntimeException; import java.util.ArrayList; import java.util.List; import java.util.Optional; @@ -173,7 +173,7 @@ public abstract class QueryProcessor { * @param query the query. * @return results of the query. */ - public QueryResult query(Predicate query) throws OrmException, QueryParseException { + public QueryResult query(Predicate query) throws StorageException, QueryParseException { return query(ImmutableList.of(query)).get(0); } @@ -189,12 +189,12 @@ public abstract class QueryProcessor { * input. */ public List> query(List> queries) - throws OrmException, QueryParseException { + throws StorageException, QueryParseException { try { return query(null, queries); - } catch (OrmRuntimeException e) { - throw new OrmException(e.getMessage(), e); - } catch (OrmException e) { + } catch (StorageRuntimeException e) { + throw new StorageException(e.getMessage(), e); + } catch (StorageException e) { if (e.getCause() != null) { Throwables.throwIfInstanceOf(e.getCause(), QueryParseException.class); } @@ -204,7 +204,7 @@ public abstract class QueryProcessor { private List> query( @Nullable List queryStrings, List> queries) - throws OrmException, QueryParseException { + throws StorageException, QueryParseException { long startNanos = System.nanoTime(); checkState(!used.getAndSet(true), "%s has already been used", getClass().getSimpleName()); int cnt = queries.size(); @@ -287,7 +287,7 @@ public abstract class QueryProcessor { // Only measure successful queries that actually touched the index. metrics.executionTime.record( schemaDef.getName(), System.nanoTime() - startNanos, TimeUnit.NANOSECONDS); - } catch (OrmException | OrmRuntimeException e) { + } catch (StorageException | StorageRuntimeException e) { Optional qpe = findQueryParseException(e); if (qpe.isPresent()) { throw new QueryParseException(qpe.get().getMessage(), e); diff --git a/java/com/google/gerrit/lucene/AbstractLuceneIndex.java b/java/com/google/gerrit/lucene/AbstractLuceneIndex.java index ae36b4867a..4691f780ae 100644 --- a/java/com/google/gerrit/lucene/AbstractLuceneIndex.java +++ b/java/com/google/gerrit/lucene/AbstractLuceneIndex.java @@ -31,6 +31,7 @@ import com.google.common.util.concurrent.ListeningExecutorService; import com.google.common.util.concurrent.MoreExecutors; import com.google.common.util.concurrent.ThreadFactoryBuilder; import com.google.gerrit.common.Nullable; +import com.google.gerrit.exceptions.StorageException; import com.google.gerrit.index.FieldDef; import com.google.gerrit.index.FieldType; import com.google.gerrit.index.Index; @@ -45,7 +46,6 @@ import com.google.gerrit.server.config.SitePaths; import com.google.gerrit.server.index.IndexUtils; import com.google.gerrit.server.logging.LoggingContextAwareExecutorService; import com.google.gerrit.server.logging.LoggingContextAwareScheduledExecutorService; -import com.google.gwtorm.server.OrmException; import java.io.IOException; import java.sql.Timestamp; import java.util.Map; @@ -486,16 +486,16 @@ public abstract class AbstractLuceneIndex implements Index { } @Override - public ResultSet read() throws OrmException { + public ResultSet read() throws StorageException { return readImpl(AbstractLuceneIndex.this::fromDocument); } @Override - public ResultSet readRaw() throws OrmException { + public ResultSet readRaw() throws StorageException { return readImpl(AbstractLuceneIndex.this::toFieldBundle); } - private ResultSet readImpl(Function mapper) throws OrmException { + private ResultSet readImpl(Function mapper) throws StorageException { IndexSearcher searcher = null; try { searcher = acquire(); @@ -512,7 +512,7 @@ public abstract class AbstractLuceneIndex implements Index { } return new ListResultSet<>(b.build()); } catch (IOException e) { - throw new OrmException(e); + throw new StorageException(e); } finally { if (searcher != null) { try { diff --git a/java/com/google/gerrit/lucene/BUILD b/java/com/google/gerrit/lucene/BUILD index 2c84f9c739..fa4c923e1a 100644 --- a/java/com/google/gerrit/lucene/BUILD +++ b/java/com/google/gerrit/lucene/BUILD @@ -9,7 +9,6 @@ java_library( "//java/com/google/gerrit/index:query_exception", "//java/com/google/gerrit/reviewdb:server", "//java/com/google/gerrit/server", - "//java/com/google/gwtorm", "//lib:guava", "//lib/lucene:lucene-core-and-backward-codecs", ], @@ -26,6 +25,7 @@ java_library( ":query_builder", "//java/com/google/gerrit/common:annotations", "//java/com/google/gerrit/common:server", + "//java/com/google/gerrit/exceptions", "//java/com/google/gerrit/extensions:api", "//java/com/google/gerrit/index", "//java/com/google/gerrit/index:query_exception", @@ -35,7 +35,6 @@ java_library( "//java/com/google/gerrit/reviewdb:server", "//java/com/google/gerrit/server", "//java/com/google/gerrit/server/logging", - "//java/com/google/gwtorm", "//lib:guava", "//lib:protobuf", "//lib/flogger:api", diff --git a/java/com/google/gerrit/lucene/LuceneChangeIndex.java b/java/com/google/gerrit/lucene/LuceneChangeIndex.java index 0e34c935bf..77ab4d9d98 100644 --- a/java/com/google/gerrit/lucene/LuceneChangeIndex.java +++ b/java/com/google/gerrit/lucene/LuceneChangeIndex.java @@ -36,6 +36,8 @@ import com.google.common.collect.Sets; import com.google.common.flogger.FluentLogger; import com.google.common.util.concurrent.Futures; import com.google.common.util.concurrent.ListeningExecutorService; +import com.google.gerrit.exceptions.StorageException; +import com.google.gerrit.exceptions.StorageRuntimeException; import com.google.gerrit.index.QueryOptions; import com.google.gerrit.index.Schema; import com.google.gerrit.index.query.FieldBundle; @@ -62,8 +64,6 @@ import com.google.gerrit.server.index.change.ChangeIndexRewriter; import com.google.gerrit.server.project.SubmitRuleOptions; import com.google.gerrit.server.query.change.ChangeData; import com.google.gerrit.server.query.change.ChangeDataSource; -import com.google.gwtorm.server.OrmException; -import com.google.gwtorm.server.OrmRuntimeException; import com.google.inject.Inject; import com.google.inject.assistedinject.Assisted; import com.google.protobuf.MessageLite; @@ -212,7 +212,7 @@ public class LuceneChangeIndex implements ChangeIndex { } else { Futures.allAsList(openIndex.delete(id), closedIndex.replace(id, doc)).get(); } - } catch (OrmException | ExecutionException | InterruptedException e) { + } catch (StorageException | ExecutionException | InterruptedException e) { throw new IOException(e); } } @@ -303,10 +303,10 @@ public class LuceneChangeIndex implements ChangeIndex { } @Override - public ResultSet read() throws OrmException { + public ResultSet read() throws StorageException { if (Thread.interrupted()) { Thread.currentThread().interrupt(); - throw new OrmException("interrupted"); + throw new StorageException("interrupted"); } final Set fields = IndexUtils.changeFields(opts); @@ -327,12 +327,12 @@ public class LuceneChangeIndex implements ChangeIndex { } @Override - public ResultSet readRaw() throws OrmException { + public ResultSet readRaw() throws StorageException { List documents; try { documents = doRead(IndexUtils.changeFields(opts)); } catch (IOException e) { - throw new OrmException(e); + throw new StorageException(e); } ImmutableList fieldBundles = documents.stream().map(rawDocumentMapper).collect(toImmutableList()); @@ -415,10 +415,10 @@ public class LuceneChangeIndex implements ChangeIndex { return result.build(); } catch (InterruptedException e) { close(); - throw new OrmRuntimeException(e); + throw new StorageRuntimeException(e); } catch (ExecutionException e) { Throwables.throwIfUnchecked(e.getCause()); - throw new OrmRuntimeException(e.getCause()); + throw new StorageRuntimeException(e.getCause()); } } diff --git a/java/com/google/gerrit/pgm/BUILD b/java/com/google/gerrit/pgm/BUILD index b000de89f1..02c083c1f5 100644 --- a/java/com/google/gerrit/pgm/BUILD +++ b/java/com/google/gerrit/pgm/BUILD @@ -18,6 +18,7 @@ java_library( "//java/com/google/gerrit/common:annotations", "//java/com/google/gerrit/common:server", "//java/com/google/gerrit/elasticsearch", + "//java/com/google/gerrit/exceptions", "//java/com/google/gerrit/extensions:api", "//java/com/google/gerrit/gpg", "//java/com/google/gerrit/httpd", @@ -47,7 +48,6 @@ java_library( "//java/com/google/gerrit/server/util/time", "//java/com/google/gerrit/sshd", "//java/com/google/gerrit/util/http", - "//java/com/google/gwtorm", "//lib:args4j", "//lib:guava", "//lib:protobuf", diff --git a/java/com/google/gerrit/pgm/LocalUsernamesToLowerCase.java b/java/com/google/gerrit/pgm/LocalUsernamesToLowerCase.java index 14a0b5d352..e6e091c360 100644 --- a/java/com/google/gerrit/pgm/LocalUsernamesToLowerCase.java +++ b/java/com/google/gerrit/pgm/LocalUsernamesToLowerCase.java @@ -16,6 +16,7 @@ package com.google.gerrit.pgm; import static com.google.gerrit.server.account.externalids.ExternalId.SCHEME_GERRIT; +import com.google.gerrit.exceptions.DuplicateKeyException; import com.google.gerrit.extensions.config.FactoryModule; import com.google.gerrit.lifecycle.LifecycleManager; import com.google.gerrit.pgm.util.SiteProgram; @@ -29,7 +30,6 @@ import com.google.gerrit.server.git.GitRepositoryManager; import com.google.gerrit.server.git.meta.MetaDataUpdate; import com.google.gerrit.server.index.account.AccountSchemaDefinitions; import com.google.gerrit.server.schema.NoteDbSchemaVersionCheck; -import com.google.gwtorm.server.OrmDuplicateKeyException; import com.google.inject.Inject; import com.google.inject.Injector; import com.google.inject.Provider; @@ -96,7 +96,7 @@ public class LocalUsernamesToLowerCase extends SiteProgram { } private void convertLocalUserToLowerCase(ExternalIdNotes extIdNotes, ExternalId extId) - throws OrmDuplicateKeyException, IOException { + throws DuplicateKeyException, IOException { if (extId.isScheme(SCHEME_GERRIT)) { String localUser = extId.key().id(); String localUserLowerCase = localUser.toLowerCase(Locale.US); diff --git a/java/com/google/gerrit/pgm/init/BUILD b/java/com/google/gerrit/pgm/init/BUILD index 74236ceff2..b2a4d72f85 100644 --- a/java/com/google/gerrit/pgm/init/BUILD +++ b/java/com/google/gerrit/pgm/init/BUILD @@ -21,7 +21,6 @@ java_library( "//java/com/google/gerrit/server/ioutil", "//java/com/google/gerrit/server/schema", "//java/com/google/gerrit/server/util/time", - "//java/com/google/gwtorm", "//lib:guava", "//lib:h2", "//lib/commons:validator", diff --git a/java/com/google/gerrit/pgm/init/BaseInit.java b/java/com/google/gerrit/pgm/init/BaseInit.java index c1fd1dfaff..58f9c0e084 100644 --- a/java/com/google/gerrit/pgm/init/BaseInit.java +++ b/java/com/google/gerrit/pgm/init/BaseInit.java @@ -22,6 +22,7 @@ import com.google.common.base.Strings; import com.google.common.flogger.FluentLogger; import com.google.gerrit.common.Die; import com.google.gerrit.common.IoUtil; +import com.google.gerrit.exceptions.StorageException; import com.google.gerrit.metrics.DisabledMetricMaker; import com.google.gerrit.metrics.MetricMaker; import com.google.gerrit.pgm.init.api.ConsoleUI; @@ -44,7 +45,6 @@ import com.google.gerrit.server.schema.UpdateUI; import com.google.gerrit.server.securestore.SecureStore; import com.google.gerrit.server.securestore.SecureStoreClassName; import com.google.gerrit.server.securestore.SecureStoreProvider; -import com.google.gwtorm.server.OrmException; import com.google.inject.AbstractModule; import com.google.inject.CreationException; import com.google.inject.Guice; @@ -350,7 +350,7 @@ public class BaseInit extends SiteProgram { this.repositoryManager = repositoryManager; } - void upgradeSchema() throws OrmException { + void upgradeSchema() throws StorageException { noteDbSchemaUpdater.update(new UpdateUIImpl(ui)); } diff --git a/java/com/google/gerrit/pgm/init/ExternalIdsOnInit.java b/java/com/google/gerrit/pgm/init/ExternalIdsOnInit.java index 6336c939fa..dff1b85ec6 100644 --- a/java/com/google/gerrit/pgm/init/ExternalIdsOnInit.java +++ b/java/com/google/gerrit/pgm/init/ExternalIdsOnInit.java @@ -14,6 +14,7 @@ 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.InitFlags; import com.google.gerrit.server.GerritPersonIdentProvider; @@ -23,7 +24,6 @@ import com.google.gerrit.server.config.AllUsersName; import com.google.gerrit.server.config.SitePaths; import com.google.gerrit.server.extensions.events.GitReferenceUpdated; import com.google.gerrit.server.git.meta.MetaDataUpdate; -import com.google.gwtorm.server.OrmException; import com.google.inject.Inject; import java.io.File; import java.io.IOException; @@ -49,7 +49,7 @@ public class ExternalIdsOnInit { } public synchronized void insert(String commitMessage, Collection extIds) - throws OrmException, IOException, ConfigInvalidException { + throws StorageException, IOException, ConfigInvalidException { File path = getPath(); if (path != null) { try (Repository allUsersRepo = new FileRepository(path)) { diff --git a/java/com/google/gerrit/pgm/init/api/BUILD b/java/com/google/gerrit/pgm/init/api/BUILD index 004a308ad3..5b07fc6cfd 100644 --- a/java/com/google/gerrit/pgm/init/api/BUILD +++ b/java/com/google/gerrit/pgm/init/api/BUILD @@ -5,9 +5,9 @@ java_library( deps = [ "//java/com/google/gerrit/common:annotations", "//java/com/google/gerrit/common:server", + "//java/com/google/gerrit/exceptions", "//java/com/google/gerrit/reviewdb:server", "//java/com/google/gerrit/server", - "//java/com/google/gwtorm", "//lib:guava", "//lib/flogger:api", "//lib/guice", diff --git a/java/com/google/gerrit/pgm/init/api/SequencesOnInit.java b/java/com/google/gerrit/pgm/init/api/SequencesOnInit.java index aa9fca2f0d..be0fd8384e 100644 --- a/java/com/google/gerrit/pgm/init/api/SequencesOnInit.java +++ b/java/com/google/gerrit/pgm/init/api/SequencesOnInit.java @@ -14,12 +14,12 @@ package com.google.gerrit.pgm.init.api; +import com.google.gerrit.exceptions.StorageException; import com.google.gerrit.reviewdb.client.Project; import com.google.gerrit.server.extensions.events.GitReferenceUpdated; import com.google.gerrit.server.git.GitRepositoryManager; import com.google.gerrit.server.notedb.RepoSequence; import com.google.gerrit.server.notedb.Sequences; -import com.google.gwtorm.server.OrmException; import com.google.inject.Inject; import com.google.inject.Singleton; @@ -34,7 +34,7 @@ public class SequencesOnInit { this.allUsersName = allUsersName; } - public int nextAccountId() throws OrmException { + public int nextAccountId() throws StorageException { RepoSequence accountSeq = new RepoSequence( repoManager, diff --git a/java/com/google/gerrit/pgm/util/BUILD b/java/com/google/gerrit/pgm/util/BUILD index b032b7b508..ffd1cbd3c2 100644 --- a/java/com/google/gerrit/pgm/util/BUILD +++ b/java/com/google/gerrit/pgm/util/BUILD @@ -17,7 +17,6 @@ java_library( "//java/com/google/gerrit/server/restapi", "//java/com/google/gerrit/server/schema", "//java/com/google/gerrit/util/cli", - "//java/com/google/gwtorm", "//lib:args4j", "//lib:guava", "//lib/flogger:api", diff --git a/java/com/google/gerrit/server/ApprovalCopier.java b/java/com/google/gerrit/server/ApprovalCopier.java index 45588a33ae..a07fa559a6 100644 --- a/java/com/google/gerrit/server/ApprovalCopier.java +++ b/java/com/google/gerrit/server/ApprovalCopier.java @@ -22,6 +22,7 @@ import com.google.common.collect.ListMultimap; import com.google.common.collect.Table; import com.google.gerrit.common.Nullable; import com.google.gerrit.common.data.LabelType; +import com.google.gerrit.exceptions.StorageException; import com.google.gerrit.extensions.client.ChangeKind; import com.google.gerrit.reviewdb.client.Account; import com.google.gerrit.reviewdb.client.PatchSet; @@ -32,7 +33,6 @@ import com.google.gerrit.server.notedb.ChangeNotes; import com.google.gerrit.server.project.ProjectCache; import com.google.gerrit.server.project.ProjectState; import com.google.gerrit.server.query.change.ChangeData; -import com.google.gwtorm.server.OrmException; import com.google.inject.Inject; import com.google.inject.Singleton; import java.io.IOException; @@ -74,7 +74,7 @@ public class ApprovalCopier { Iterable getForPatchSet( ChangeNotes notes, PatchSet.Id psId, @Nullable RevWalk rw, @Nullable Config repoConfig) - throws OrmException { + throws StorageException { return getForPatchSet(notes, psId, rw, repoConfig, Collections.emptyList()); } @@ -84,7 +84,7 @@ public class ApprovalCopier { @Nullable RevWalk rw, @Nullable Config repoConfig, Iterable dontCopy) - throws OrmException { + throws StorageException { PatchSet ps = psUtil.get(notes, psId); if (ps == null) { return Collections.emptyList(); @@ -98,7 +98,7 @@ public class ApprovalCopier { @Nullable RevWalk rw, @Nullable Config repoConfig, Iterable dontCopy) - throws OrmException { + throws StorageException { requireNonNull(ps, "ps should not be null"); ChangeData cd = changeDataFactory.create(notes); try { @@ -153,11 +153,11 @@ public class ApprovalCopier { } return labelNormalizer.normalize(notes, byUser.values()).getNormalized(); } catch (IOException e) { - throw new OrmException(e); + throw new StorageException(e); } } - private static TreeMap getPatchSets(ChangeData cd) throws OrmException { + private static TreeMap getPatchSets(ChangeData cd) throws StorageException { Collection patchSets = cd.patchSets(); TreeMap result = new TreeMap<>(); for (PatchSet ps : patchSets) { diff --git a/java/com/google/gerrit/server/ApprovalsUtil.java b/java/com/google/gerrit/server/ApprovalsUtil.java index 1b5983a458..e85caadf53 100644 --- a/java/com/google/gerrit/server/ApprovalsUtil.java +++ b/java/com/google/gerrit/server/ApprovalsUtil.java @@ -29,6 +29,7 @@ import com.google.common.primitives.Shorts; import com.google.gerrit.common.Nullable; import com.google.gerrit.common.data.LabelType; import com.google.gerrit.common.data.LabelTypes; +import com.google.gerrit.exceptions.StorageException; import com.google.gerrit.extensions.restapi.AuthException; import com.google.gerrit.extensions.restapi.BadRequestException; import com.google.gerrit.extensions.restapi.RestApiException; @@ -47,7 +48,6 @@ import com.google.gerrit.server.permissions.PermissionBackend; import com.google.gerrit.server.permissions.PermissionBackendException; import com.google.gerrit.server.project.ProjectCache; import com.google.gerrit.server.util.LabelVote; -import com.google.gwtorm.server.OrmException; import com.google.inject.Inject; import com.google.inject.Singleton; import java.io.IOException; @@ -112,9 +112,9 @@ public class ApprovalsUtil { * * @param notes change notes. * @return reviewers for the change. - * @throws OrmException if reviewers for the change could not be read. + * @throws StorageException if reviewers for the change could not be read. */ - public ReviewerSet getReviewers(ChangeNotes notes) throws OrmException { + public ReviewerSet getReviewers(ChangeNotes notes) throws StorageException { return notes.load().getReviewers(); } @@ -123,10 +123,10 @@ public class ApprovalsUtil { * * @param allApprovals all approvals to consider; must all belong to the same change. * @return reviewers for the change. - * @throws OrmException if reviewers for the change could not be read. + * @throws StorageException if reviewers for the change could not be read. */ public ReviewerSet getReviewers(ChangeNotes notes, Iterable allApprovals) - throws OrmException { + throws StorageException { return notes.load().getReviewers(); } @@ -135,9 +135,9 @@ public class ApprovalsUtil { * * @param notes change notes. * @return reviewer updates for the change. - * @throws OrmException if reviewer updates for the change could not be read. + * @throws StorageException if reviewer updates for the change could not be read. */ - public List getReviewerUpdates(ChangeNotes notes) throws OrmException { + public List getReviewerUpdates(ChangeNotes notes) throws StorageException { return notes.load().getReviewerUpdates(); } @@ -166,7 +166,7 @@ public class ApprovalsUtil { LabelTypes labelTypes, Change change, Iterable wantReviewers) - throws OrmException { + throws StorageException { PatchSet.Id psId = change.currentPatchSetId(); Collection existingReviewers; existingReviewers = notes.load().getReviewers().byState(REVIEWER); @@ -245,10 +245,11 @@ public class ApprovalsUtil { * @param update change update. * @param wantCCs accounts to CC. * @return whether a change was made. - * @throws OrmException + * @throws StorageException */ public Collection addCcs( - ChangeNotes notes, ChangeUpdate update, Collection wantCCs) throws OrmException { + ChangeNotes notes, ChangeUpdate update, Collection wantCCs) + throws StorageException { return addCcs(update, wantCCs, notes.load().getReviewers()); } @@ -272,7 +273,7 @@ public class ApprovalsUtil { * @param user user adding approvals. * @param approvals approvals to add. * @throws RestApiException - * @throws OrmException + * @throws StorageException */ public Iterable addApprovalsForNewPatchSet( ChangeUpdate update, @@ -280,7 +281,7 @@ public class ApprovalsUtil { PatchSet ps, CurrentUser user, Map approvals) - throws RestApiException, OrmException, PermissionBackendException { + throws RestApiException, StorageException, PermissionBackendException { Account.Id accountId = user.getAccountId(); checkArgument( accountId.equals(ps.getUploader()), @@ -331,13 +332,13 @@ public class ApprovalsUtil { } public ListMultimap byChange(ChangeNotes notes) - throws OrmException { + throws StorageException { return notes.load().getApprovals(); } public Iterable byPatchSet( ChangeNotes notes, PatchSet.Id psId, @Nullable RevWalk rw, @Nullable Config repoConfig) - throws OrmException { + throws StorageException { return copier.getForPatchSet(notes, psId, rw, repoConfig); } @@ -347,7 +348,7 @@ public class ApprovalsUtil { Account.Id accountId, @Nullable RevWalk rw, @Nullable Config repoConfig) - throws OrmException { + throws StorageException { return filterApprovals(byPatchSet(notes, psId, rw, repoConfig), accountId); } @@ -358,7 +359,7 @@ public class ApprovalsUtil { try { // Submit approval is never copied, so bypass expensive byPatchSet call. return getSubmitter(c, byChange(notes).get(c)); - } catch (OrmException e) { + } catch (StorageException e) { return null; } } diff --git a/java/com/google/gerrit/server/ChangeMessagesUtil.java b/java/com/google/gerrit/server/ChangeMessagesUtil.java index 214c5d7fea..211c9b7184 100644 --- a/java/com/google/gerrit/server/ChangeMessagesUtil.java +++ b/java/com/google/gerrit/server/ChangeMessagesUtil.java @@ -18,6 +18,7 @@ import static com.google.common.base.Preconditions.checkState; import static java.util.Objects.requireNonNull; import com.google.gerrit.common.Nullable; +import com.google.gerrit.exceptions.StorageException; import com.google.gerrit.extensions.common.ChangeMessageInfo; import com.google.gerrit.reviewdb.client.Account; import com.google.gerrit.reviewdb.client.ChangeMessage; @@ -26,7 +27,6 @@ import com.google.gerrit.server.account.AccountLoader; import com.google.gerrit.server.notedb.ChangeNotes; import com.google.gerrit.server.notedb.ChangeUpdate; import com.google.gerrit.server.update.ChangeContext; -import com.google.gwtorm.server.OrmException; import com.google.inject.Singleton; import java.sql.Timestamp; import java.util.List; @@ -87,7 +87,7 @@ public class ChangeMessagesUtil { return workInProgress ? TAG_UPLOADED_WIP_PATCH_SET : TAG_UPLOADED_PATCH_SET; } - public List byChange(ChangeNotes notes) throws OrmException { + public List byChange(ChangeNotes notes) throws StorageException { return notes.load().getChangeMessages(); } diff --git a/java/com/google/gerrit/server/CommentsUtil.java b/java/com/google/gerrit/server/CommentsUtil.java index 1229df1f59..8b650fe6b2 100644 --- a/java/com/google/gerrit/server/CommentsUtil.java +++ b/java/com/google/gerrit/server/CommentsUtil.java @@ -23,6 +23,7 @@ import com.google.common.collect.FluentIterable; import com.google.common.collect.Lists; import com.google.common.collect.Ordering; import com.google.gerrit.common.Nullable; +import com.google.gerrit.exceptions.StorageException; import com.google.gerrit.extensions.client.Side; import com.google.gerrit.extensions.common.CommentInfo; import com.google.gerrit.extensions.restapi.UnprocessableEntityException; @@ -42,7 +43,6 @@ import com.google.gerrit.server.notedb.ChangeUpdate; import com.google.gerrit.server.patch.PatchListCache; import com.google.gerrit.server.patch.PatchListNotAvailableException; import com.google.gerrit.server.update.ChangeContext; -import com.google.gwtorm.server.OrmException; import com.google.inject.Inject; import com.google.inject.Singleton; import java.io.IOException; @@ -124,7 +124,7 @@ public class CommentsUtil { String message, @Nullable Boolean unresolved, @Nullable String parentUuid) - throws OrmException, UnprocessableEntityException { + throws StorageException, UnprocessableEntityException { if (unresolved == null) { if (parentUuid == null) { // Default to false if comment is not descended from another. @@ -175,28 +175,29 @@ public class CommentsUtil { return c; } - public Optional getPublished(ChangeNotes notes, Comment.Key key) throws OrmException { + public Optional getPublished(ChangeNotes notes, Comment.Key key) + throws StorageException { return publishedByChange(notes).stream().filter(c -> key.equals(c.key)).findFirst(); } public Optional getDraft(ChangeNotes notes, IdentifiedUser user, Comment.Key key) - throws OrmException { + throws StorageException { return draftByChangeAuthor(notes, user.getAccountId()).stream() .filter(c -> key.equals(c.key)) .findFirst(); } - public List publishedByChange(ChangeNotes notes) throws OrmException { + public List publishedByChange(ChangeNotes notes) throws StorageException { notes.load(); return sort(Lists.newArrayList(notes.getComments().values())); } - public List robotCommentsByChange(ChangeNotes notes) throws OrmException { + public List robotCommentsByChange(ChangeNotes notes) throws StorageException { notes.load(); return sort(Lists.newArrayList(notes.getRobotComments().values())); } - public List draftByChange(ChangeNotes notes) throws OrmException { + public List draftByChange(ChangeNotes notes) throws StorageException { List comments = new ArrayList<>(); for (Ref ref : getDraftRefs(notes.getChangeId())) { Account.Id account = Account.Id.fromRefSuffix(ref.getName()); @@ -207,7 +208,7 @@ public class CommentsUtil { return sort(comments); } - public List byPatchSet(ChangeNotes notes, PatchSet.Id psId) throws OrmException { + public List byPatchSet(ChangeNotes notes, PatchSet.Id psId) throws StorageException { List comments = new ArrayList<>(); comments.addAll(publishedByPatchSet(notes, psId)); @@ -220,18 +221,19 @@ public class CommentsUtil { return sort(comments); } - public List publishedByChangeFile(ChangeNotes notes, String file) throws OrmException { + public List publishedByChangeFile(ChangeNotes notes, String file) + throws StorageException { return commentsOnFile(notes.load().getComments().values(), file); } public List publishedByPatchSet(ChangeNotes notes, PatchSet.Id psId) - throws OrmException { + throws StorageException { return removeCommentsOnAncestorOfCommitMessage( commentsOnPatchSet(notes.load().getComments().values(), psId)); } public List robotCommentsByPatchSet(ChangeNotes notes, PatchSet.Id psId) - throws OrmException { + throws StorageException { return commentsOnPatchSet(notes.load().getRobotComments().values(), psId); } @@ -249,17 +251,17 @@ public class CommentsUtil { } public List draftByPatchSetAuthor(PatchSet.Id psId, Account.Id author, ChangeNotes notes) - throws OrmException { + throws StorageException { return commentsOnPatchSet(notes.load().getDraftComments(author).values(), psId); } public List draftByChangeFileAuthor(ChangeNotes notes, String file, Account.Id author) - throws OrmException { + throws StorageException { return commentsOnFile(notes.load().getDraftComments(author).values(), file); } public List draftByChangeAuthor(ChangeNotes notes, Account.Id author) - throws OrmException { + throws StorageException { List comments = new ArrayList<>(); comments.addAll(notes.getDraftComments(author).values()); return sort(comments); @@ -343,11 +345,11 @@ public class CommentsUtil { * @param changeId change ID. * @return raw refs from All-Users repo. */ - public Collection getDraftRefs(Change.Id changeId) throws OrmException { + public Collection getDraftRefs(Change.Id changeId) throws StorageException { try (Repository repo = repoManager.openRepository(allUsers)) { return getDraftRefs(repo, changeId); } catch (IOException e) { - throw new OrmException(e); + throw new StorageException(e); } } diff --git a/java/com/google/gerrit/server/PatchSetUtil.java b/java/com/google/gerrit/server/PatchSetUtil.java index e7f1d2a3eb..4a8de1cd31 100644 --- a/java/com/google/gerrit/server/PatchSetUtil.java +++ b/java/com/google/gerrit/server/PatchSetUtil.java @@ -22,6 +22,7 @@ import com.google.common.collect.ImmutableMap; import com.google.common.collect.Maps; import com.google.gerrit.common.data.LabelFunction; import com.google.gerrit.common.data.LabelType; +import com.google.gerrit.exceptions.StorageException; import com.google.gerrit.extensions.restapi.ResourceConflictException; import com.google.gerrit.reviewdb.client.Change; import com.google.gerrit.reviewdb.client.PatchSet; @@ -33,7 +34,6 @@ import com.google.gerrit.server.notedb.ChangeNotes; import com.google.gerrit.server.notedb.ChangeUpdate; import com.google.gerrit.server.project.ProjectCache; import com.google.gerrit.server.project.ProjectState; -import com.google.gwtorm.server.OrmException; import com.google.inject.Inject; import com.google.inject.Provider; import com.google.inject.Singleton; @@ -63,24 +63,25 @@ public class PatchSetUtil { this.repoManager = repoManager; } - public PatchSet current(ChangeNotes notes) throws OrmException { + public PatchSet current(ChangeNotes notes) throws StorageException { return get(notes, notes.getChange().currentPatchSetId()); } - public PatchSet get(ChangeNotes notes, PatchSet.Id psId) throws OrmException { + public PatchSet get(ChangeNotes notes, PatchSet.Id psId) throws StorageException { return notes.load().getPatchSets().get(psId); } - public ImmutableCollection byChange(ChangeNotes notes) throws OrmException { + public ImmutableCollection byChange(ChangeNotes notes) throws StorageException { return notes.load().getPatchSets().values(); } - public ImmutableMap byChangeAsMap(ChangeNotes notes) throws OrmException { + public ImmutableMap byChangeAsMap(ChangeNotes notes) + throws StorageException { return notes.load().getPatchSets(); } public ImmutableMap getAsMap( - ChangeNotes notes, Set patchSetIds) throws OrmException { + ChangeNotes notes, Set patchSetIds) throws StorageException { return ImmutableMap.copyOf(Maps.filterKeys(notes.load().getPatchSets(), patchSetIds::contains)); } @@ -135,7 +136,7 @@ public class PatchSetUtil { /** Check if the current patch set of the change is locked. */ public void checkPatchSetNotLocked(ChangeNotes notes) - throws OrmException, IOException, ResourceConflictException { + throws StorageException, IOException, ResourceConflictException { if (isPatchSetLocked(notes)) { throw new ResourceConflictException( String.format("The current patch set of change %s is locked", notes.getChangeId())); @@ -143,7 +144,7 @@ public class PatchSetUtil { } /** Is the current patch set locked against state changes? */ - public boolean isPatchSetLocked(ChangeNotes notes) throws OrmException, IOException { + public boolean isPatchSetLocked(ChangeNotes notes) throws StorageException, IOException { Change change = notes.getChange(); if (change.isMerged()) { return false; diff --git a/java/com/google/gerrit/server/PublishCommentUtil.java b/java/com/google/gerrit/server/PublishCommentUtil.java index 75a364ccb2..7965042c94 100644 --- a/java/com/google/gerrit/server/PublishCommentUtil.java +++ b/java/com/google/gerrit/server/PublishCommentUtil.java @@ -19,13 +19,13 @@ import static com.google.gerrit.reviewdb.client.PatchLineComment.Status.PUBLISHE import static java.util.stream.Collectors.toSet; import com.google.gerrit.common.Nullable; +import com.google.gerrit.exceptions.StorageException; import com.google.gerrit.reviewdb.client.Comment; import com.google.gerrit.reviewdb.client.PatchSet; import com.google.gerrit.server.notedb.ChangeNotes; import com.google.gerrit.server.patch.PatchListCache; import com.google.gerrit.server.patch.PatchListNotAvailableException; import com.google.gerrit.server.update.ChangeContext; -import com.google.gwtorm.server.OrmException; import com.google.inject.Inject; import com.google.inject.Singleton; import java.util.Collection; @@ -47,7 +47,7 @@ public class PublishCommentUtil { public void publish( ChangeContext ctx, PatchSet.Id psId, Collection drafts, @Nullable String tag) - throws OrmException { + throws StorageException { ChangeNotes notes = ctx.getNotes(); checkArgument(notes != null); if (drafts.isEmpty()) { @@ -59,7 +59,7 @@ public class PublishCommentUtil { for (Comment d : drafts) { PatchSet ps = patchSets.get(psId(notes, d)); if (ps == null) { - throw new OrmException("patch set " + ps + " not found"); + throw new StorageException("patch set " + ps + " not found"); } d.writtenOn = ctx.getWhen(); d.tag = tag; @@ -69,7 +69,7 @@ public class PublishCommentUtil { try { CommentsUtil.setCommentRevId(d, patchListCache, notes.getChange(), ps); } catch (PatchListNotAvailableException e) { - throw new OrmException(e); + throw new StorageException(e); } } commentsUtil.putComments(ctx.getUpdate(psId), PUBLISHED, drafts); diff --git a/java/com/google/gerrit/server/StarredChangesUtil.java b/java/com/google/gerrit/server/StarredChangesUtil.java index e6d6be1b92..e1fbc20b52 100644 --- a/java/com/google/gerrit/server/StarredChangesUtil.java +++ b/java/com/google/gerrit/server/StarredChangesUtil.java @@ -31,6 +31,7 @@ import com.google.common.collect.Sets; import com.google.common.flogger.FluentLogger; import com.google.common.primitives.Ints; 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.Change; import com.google.gerrit.reviewdb.client.Project; @@ -46,7 +47,6 @@ import com.google.gerrit.server.logging.TraceContext.TraceTimer; import com.google.gerrit.server.project.NoSuchChangeException; import com.google.gerrit.server.query.change.ChangeData; import com.google.gerrit.server.query.change.InternalChangeQuery; -import com.google.gwtorm.server.OrmException; import com.google.inject.Inject; import com.google.inject.Provider; import com.google.inject.Singleton; @@ -187,11 +187,11 @@ public class StarredChangesUtil { } public ImmutableSortedSet getLabels(Account.Id accountId, Change.Id changeId) - throws OrmException { + throws StorageException { try (Repository repo = repoManager.openRepository(allUsers)) { return readLabels(repo, RefNames.refsStarredChanges(changeId, accountId)).labels(); } catch (IOException e) { - throw new OrmException( + throw new StorageException( String.format( "Reading stars from change %d for account %d failed", changeId.get(), accountId.get()), @@ -205,7 +205,7 @@ public class StarredChangesUtil { Change.Id changeId, Set labelsToAdd, Set labelsToRemove) - throws OrmException, IllegalLabelException { + throws StorageException, IllegalLabelException { try (Repository repo = repoManager.openRepository(allUsers)) { String refName = RefNames.refsStarredChanges(changeId, accountId); StarRef old = readLabels(repo, refName); @@ -228,13 +228,13 @@ public class StarredChangesUtil { indexer.index(project, changeId); return ImmutableSortedSet.copyOf(labels); } catch (IOException e) { - throw new OrmException( + throw new StorageException( String.format("Star change %d for account %d failed", changeId.get(), accountId.get()), e); } } - public void unstarAll(Project.NameKey project, Change.Id changeId) throws OrmException { + public void unstarAll(Project.NameKey project, Change.Id changeId) throws StorageException { try (Repository repo = repoManager.openRepository(allUsers); RevWalk rw = new RevWalk(repo)) { BatchRefUpdate batchUpdate = repo.getRefDatabase().newBatchUpdate(); @@ -257,11 +257,11 @@ public class StarredChangesUtil { } indexer.index(project, changeId); } catch (IOException e) { - throw new OrmException(String.format("Unstar change %d failed", changeId.get()), e); + throw new StorageException(String.format("Unstar change %d failed", changeId.get()), e); } } - public ImmutableMap byChange(Change.Id changeId) throws OrmException { + public ImmutableMap byChange(Change.Id changeId) throws StorageException { try (Repository repo = repoManager.openRepository(allUsers)) { ImmutableMap.Builder builder = ImmutableMap.builder(); for (String refPart : getRefNames(repo, RefNames.refsStarredChangesPrefix(changeId))) { @@ -274,13 +274,13 @@ public class StarredChangesUtil { } return builder.build(); } catch (IOException e) { - throw new OrmException( + throw new StorageException( String.format("Get accounts that starred change %d failed", changeId.get()), e); } } public ImmutableListMultimap byChangeFromIndex(Change.Id changeId) - throws OrmException { + throws StorageException { List changeData = queryProvider .get() @@ -311,7 +311,7 @@ public class StarredChangesUtil { } } - public void ignore(ChangeResource rsrc) throws OrmException, IllegalLabelException { + public void ignore(ChangeResource rsrc) throws StorageException, IllegalLabelException { star( rsrc.getUser().asIdentifiedUser().getAccountId(), rsrc.getProject(), @@ -320,7 +320,7 @@ public class StarredChangesUtil { ImmutableSet.of()); } - public void unignore(ChangeResource rsrc) throws OrmException, IllegalLabelException { + public void unignore(ChangeResource rsrc) throws StorageException, IllegalLabelException { star( rsrc.getUser().asIdentifiedUser().getAccountId(), rsrc.getProject(), @@ -329,11 +329,11 @@ public class StarredChangesUtil { ImmutableSet.of(IGNORE_LABEL)); } - public boolean isIgnoredBy(Change.Id changeId, Account.Id accountId) throws OrmException { + public boolean isIgnoredBy(Change.Id changeId, Account.Id accountId) throws StorageException { return getLabels(accountId, changeId).contains(IGNORE_LABEL); } - public boolean isIgnored(ChangeResource rsrc) throws OrmException { + public boolean isIgnored(ChangeResource rsrc) throws StorageException { return isIgnoredBy(rsrc.getChange().getId(), rsrc.getUser().asIdentifiedUser().getAccountId()); } @@ -353,7 +353,7 @@ public class StarredChangesUtil { return UNREVIEWED_LABEL + "/" + ps; } - public void markAsReviewed(ChangeResource rsrc) throws OrmException, IllegalLabelException { + public void markAsReviewed(ChangeResource rsrc) throws StorageException, IllegalLabelException { star( rsrc.getUser().asIdentifiedUser().getAccountId(), rsrc.getProject(), @@ -362,7 +362,7 @@ public class StarredChangesUtil { ImmutableSet.of(getUnreviewedLabel(rsrc.getChange()))); } - public void markAsUnreviewed(ChangeResource rsrc) throws OrmException, IllegalLabelException { + public void markAsUnreviewed(ChangeResource rsrc) throws StorageException, IllegalLabelException { star( rsrc.getUser().asIdentifiedUser().getAccountId(), rsrc.getProject(), @@ -444,7 +444,7 @@ public class StarredChangesUtil { private void updateLabels( Repository repo, String refName, ObjectId oldObjectId, Collection labels) - throws IOException, OrmException, InvalidLabelsException { + throws IOException, StorageException, InvalidLabelsException { try (TraceTimer traceTimer = TraceContext.newTimer("Update star labels in %s (labels=%s)", refName, labels); RevWalk rw = new RevWalk(repo)) { @@ -471,14 +471,14 @@ public class StarredChangesUtil { case REJECTED_MISSING_OBJECT: case REJECTED_OTHER_REASON: default: - throw new OrmException( + throw new StorageException( String.format("Update star labels on ref %s failed: %s", refName, result.name())); } } } private void deleteRef(Repository repo, String refName, ObjectId oldObjectId) - throws IOException, OrmException { + throws IOException, StorageException { if (ObjectId.zeroId().equals(oldObjectId)) { // ref doesn't exist return; @@ -507,7 +507,7 @@ public class StarredChangesUtil { case REJECTED_MISSING_OBJECT: case REJECTED_OTHER_REASON: default: - throw new OrmException( + throw new StorageException( String.format("Delete star ref %s failed: %s", refName, result.name())); } } diff --git a/java/com/google/gerrit/server/account/AccountConfig.java b/java/com/google/gerrit/server/account/AccountConfig.java index d58036d97d..06f7a08002 100644 --- a/java/com/google/gerrit/server/account/AccountConfig.java +++ b/java/com/google/gerrit/server/account/AccountConfig.java @@ -21,6 +21,7 @@ import com.google.common.base.Strings; import com.google.common.collect.ImmutableList; import com.google.common.collect.ImmutableMap; import com.google.common.collect.ImmutableSet; +import com.google.gerrit.exceptions.DuplicateKeyException; import com.google.gerrit.extensions.client.DiffPreferencesInfo; import com.google.gerrit.extensions.client.EditPreferencesInfo; import com.google.gerrit.extensions.client.GeneralPreferencesInfo; @@ -34,7 +35,6 @@ import com.google.gerrit.server.git.ValidationError; import com.google.gerrit.server.git.meta.MetaDataUpdate; import com.google.gerrit.server.git.meta.VersionedMetaData; import com.google.gerrit.server.util.time.TimeUtil; -import com.google.gwtorm.server.OrmDuplicateKeyException; import java.io.IOException; import java.sql.Timestamp; import java.util.ArrayList; @@ -200,9 +200,9 @@ public class AccountConfig extends VersionedMetaData implements ValidationError. * Creates a new account. * * @return the new account - * @throws OrmDuplicateKeyException if the user branch already exists + * @throws DuplicateKeyException if the user branch already exists */ - public Account getNewAccount() throws OrmDuplicateKeyException { + public Account getNewAccount() throws DuplicateKeyException { return getNewAccount(TimeUtil.nowTs()); } @@ -210,12 +210,12 @@ public class AccountConfig extends VersionedMetaData implements ValidationError. * Creates a new account. * * @return the new account - * @throws OrmDuplicateKeyException if the user branch already exists + * @throws DuplicateKeyException if the user branch already exists */ - Account getNewAccount(Timestamp registeredOn) throws OrmDuplicateKeyException { + Account getNewAccount(Timestamp registeredOn) throws DuplicateKeyException { checkLoaded(); if (revision != null) { - throw new OrmDuplicateKeyException(String.format("account %s already exists", accountId)); + throw new DuplicateKeyException(String.format("account %s already exists", accountId)); } this.loadedAccountProperties = Optional.of(new AccountProperties(accountId, registeredOn, new Config(), null)); diff --git a/java/com/google/gerrit/server/account/AccountManager.java b/java/com/google/gerrit/server/account/AccountManager.java index 13b9bfa6a5..f135fc4057 100644 --- a/java/com/google/gerrit/server/account/AccountManager.java +++ b/java/com/google/gerrit/server/account/AccountManager.java @@ -26,6 +26,7 @@ import com.google.gerrit.common.data.AccessSection; import com.google.gerrit.common.data.GlobalCapability; import com.google.gerrit.common.data.Permission; import com.google.gerrit.exceptions.NoSuchGroupException; +import com.google.gerrit.exceptions.StorageException; import com.google.gerrit.extensions.client.AccountFieldName; import com.google.gerrit.reviewdb.client.Account; import com.google.gerrit.reviewdb.client.AccountGroup; @@ -42,7 +43,6 @@ import com.google.gerrit.server.group.db.InternalGroupUpdate; import com.google.gerrit.server.notedb.Sequences; import com.google.gerrit.server.project.ProjectCache; import com.google.gerrit.server.ssh.SshKeyCache; -import com.google.gwtorm.server.OrmException; import com.google.inject.Inject; import com.google.inject.Provider; import com.google.inject.Singleton; @@ -163,7 +163,7 @@ public class AccountManager { // return the identity to the caller. update(who, extId); return new AuthResult(extId.accountId(), who.getExternalIdKey(), false); - } catch (OrmException | ConfigInvalidException e) { + } catch (StorageException | ConfigInvalidException e) { throw new AccountException("Authentication error", e); } } @@ -214,7 +214,7 @@ public class AccountManager { } private void update(AuthRequest who, ExternalId extId) - throws OrmException, IOException, ConfigInvalidException, AccountException { + throws StorageException, IOException, ConfigInvalidException, AccountException { IdentifiedUser user = userFactory.create(extId.accountId()); List> accountUpdates = new ArrayList<>(); @@ -266,12 +266,12 @@ public class AccountManager { user.getAccountId(), AccountUpdater.joinConsumers(accountUpdates)) .orElseThrow( - () -> new OrmException("Account " + user.getAccountId() + " has been deleted")); + () -> new StorageException("Account " + user.getAccountId() + " has been deleted")); } } private AuthResult create(AuthRequest who) - throws OrmException, AccountException, IOException, ConfigInvalidException { + throws StorageException, AccountException, IOException, ConfigInvalidException { Account.Id newId = new Account.Id(sequences.nextAccountId()); 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) - throws OrmException, IOException, ConfigInvalidException, AccountException { + throws StorageException, IOException, ConfigInvalidException, AccountException { // The user initiated this request by logging in. -> Attribute all modifications to that user. GroupsUpdate groupsUpdate = groupsUpdateFactory.create(user); InternalGroupUpdate groupUpdate = @@ -400,7 +400,7 @@ public class AccountManager { * this time. */ public AuthResult link(Account.Id to, AuthRequest who) - throws AccountException, OrmException, IOException, ConfigInvalidException { + throws AccountException, StorageException, IOException, ConfigInvalidException { Optional optionalExtId = externalIds.get(who.getExternalIdKey()); if (optionalExtId.isPresent()) { ExternalId extId = optionalExtId.get(); @@ -437,12 +437,12 @@ public class AccountManager { * @param to account to link the identity onto. * @param who the additional identity. * @return the result of linking the identity to the user. - * @throws OrmException + * @throws StorageException * @throws AccountException the identity belongs to a different account, or it cannot be linked at * this time. */ public AuthResult updateLink(Account.Id to, AuthRequest who) - throws OrmException, AccountException, IOException, ConfigInvalidException { + throws StorageException, AccountException, IOException, ConfigInvalidException { accountsUpdateProvider .get() .update( @@ -474,7 +474,7 @@ public class AccountManager { * found */ public void unlink(Account.Id from, ExternalId.Key extIdKey) - throws AccountException, OrmException, IOException, ConfigInvalidException { + throws AccountException, StorageException, IOException, ConfigInvalidException { unlink(from, ImmutableList.of(extIdKey)); } @@ -487,7 +487,7 @@ public class AccountManager { * identity was not found */ public void unlink(Account.Id from, Collection extIdKeys) - throws AccountException, OrmException, IOException, ConfigInvalidException { + throws AccountException, StorageException, IOException, ConfigInvalidException { if (extIdKeys.isEmpty()) { return; } diff --git a/java/com/google/gerrit/server/account/AccountResolver.java b/java/com/google/gerrit/server/account/AccountResolver.java index 14f4a387ed..4568d6e90a 100644 --- a/java/com/google/gerrit/server/account/AccountResolver.java +++ b/java/com/google/gerrit/server/account/AccountResolver.java @@ -26,6 +26,7 @@ import com.google.common.base.Suppliers; import com.google.common.collect.ImmutableList; import com.google.common.collect.ImmutableSet; import com.google.common.collect.Streams; +import com.google.gerrit.exceptions.StorageException; import com.google.gerrit.extensions.restapi.UnprocessableEntityException; import com.google.gerrit.index.Schema; import com.google.gerrit.reviewdb.client.Account; @@ -34,7 +35,6 @@ import com.google.gerrit.server.IdentifiedUser; import com.google.gerrit.server.account.externalids.ExternalId; import com.google.gerrit.server.config.AnonymousCowardName; import com.google.gerrit.server.query.account.InternalAccountQuery; -import com.google.gwtorm.server.OrmException; import com.google.inject.Inject; import com.google.inject.Provider; import com.google.inject.Singleton; @@ -216,14 +216,15 @@ public class AccountResolver { return false; } - Optional tryParse(String input) throws IOException, OrmException; + Optional tryParse(String input) throws IOException, StorageException; - Stream search(I input) throws OrmException, IOException, ConfigInvalidException; + Stream search(I input) + throws StorageException, IOException, ConfigInvalidException; boolean shortCircuitIfNoResults(); default Optional> trySearch(String input) - throws OrmException, IOException, ConfigInvalidException { + throws StorageException, IOException, ConfigInvalidException { Optional parsed = tryParse(input); return parsed.isPresent() ? Optional.of(search(parsed.get())) : Optional.empty(); } @@ -335,7 +336,7 @@ public class AccountResolver { } @Override - public Stream search(String nameOrEmail) throws OrmException, IOException { + public Stream search(String nameOrEmail) throws StorageException, IOException { // TODO(dborowitz): This would probably work as a Searcher
int lt = nameOrEmail.indexOf('<'); int gt = nameOrEmail.indexOf('>'); @@ -368,7 +369,7 @@ public class AccountResolver { } @Override - public Stream search(String input) throws OrmException, IOException { + public Stream search(String input) throws StorageException, IOException { return toAccountStates(emails.getAccountFor(input)); } @@ -397,7 +398,7 @@ public class AccountResolver { } @Override - public Optional tryParse(String input) throws OrmException { + public Optional tryParse(String input) throws StorageException { List results = accountQueryProvider.get().enforceVisibility(true).byFullName(input); return results.size() == 1 ? Optional.of(results.get(0)) : Optional.empty(); @@ -426,7 +427,7 @@ public class AccountResolver { } @Override - public Stream search(String input) throws OrmException { + public Stream search(String input) throws StorageException { // At this point we have no clue. Just perform a whole bunch of suggestions and pray we come // up with a reasonable result list. // TODO(dborowitz): This doesn't match the documentation; consider whether it's possible to be @@ -513,11 +514,11 @@ public class AccountResolver { * * @param input input string. * @return a result describing matching accounts. Never null even if the result set is empty. - * @throws OrmException if an error occurs. + * @throws StorageException if an error occurs. * @throws ConfigInvalidException if an error occurs. * @throws IOException if an error occurs. */ - public Result resolve(String input) throws OrmException, ConfigInvalidException, IOException { + public Result resolve(String input) throws StorageException, ConfigInvalidException, IOException { return searchImpl(input, searchers, visibilitySupplier()); } @@ -539,7 +540,7 @@ public class AccountResolver { * * @param input input string. * @return a result describing matching accounts. Never null even if the result set is empty. - * @throws OrmException if an error occurs. + * @throws StorageException if an error occurs. * @throws ConfigInvalidException 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 @@ -547,7 +548,7 @@ public class AccountResolver { */ @Deprecated public Result resolveByNameOrEmail(String input) - throws OrmException, ConfigInvalidException, IOException { + throws StorageException, ConfigInvalidException, IOException { return searchImpl(input, nameOrEmailSearchers, visibilitySupplier()); } @@ -560,7 +561,7 @@ public class AccountResolver { String input, ImmutableList> searchers, Supplier> visibilitySupplier) - throws OrmException, ConfigInvalidException, IOException { + throws StorageException, ConfigInvalidException, IOException { visibilitySupplier = Suppliers.memoize(visibilitySupplier::get); List inactive = new ArrayList<>(); diff --git a/java/com/google/gerrit/server/account/AccountsUpdate.java b/java/com/google/gerrit/server/account/AccountsUpdate.java index b862793ab5..e30f817641 100644 --- a/java/com/google/gerrit/server/account/AccountsUpdate.java +++ b/java/com/google/gerrit/server/account/AccountsUpdate.java @@ -24,6 +24,8 @@ import com.google.common.base.Throwables; import com.google.common.collect.Iterables; import com.google.common.collect.Lists; import com.google.common.util.concurrent.Runnables; +import com.google.gerrit.exceptions.DuplicateKeyException; +import com.google.gerrit.exceptions.StorageException; import com.google.gerrit.git.LockFailureException; import com.google.gerrit.git.RefUpdateUtil; import com.google.gerrit.reviewdb.client.Account; @@ -41,8 +43,6 @@ import com.google.gerrit.server.notedb.Sequences; import com.google.gerrit.server.update.RetryHelper; import com.google.gerrit.server.update.RetryHelper.Action; import com.google.gerrit.server.update.RetryHelper.ActionType; -import com.google.gwtorm.server.OrmDuplicateKeyException; -import com.google.gwtorm.server.OrmException; import com.google.inject.Provider; import com.google.inject.assistedinject.Assisted; import com.google.inject.assistedinject.AssistedInject; @@ -293,14 +293,14 @@ public class AccountsUpdate { * @param accountId ID of the new account * @param init consumer to populate the new account * @return the newly created account - * @throws OrmDuplicateKeyException 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 OrmException if creating the user branch fails + * @throws StorageException if creating the user branch fails * @throws ConfigInvalidException if any of the account fields has an invalid value */ public AccountState insert( String message, Account.Id accountId, Consumer init) - throws OrmException, IOException, ConfigInvalidException { + throws StorageException, IOException, ConfigInvalidException { return insert(message, accountId, AccountUpdater.fromConsumer(init)); } @@ -311,13 +311,13 @@ public class AccountsUpdate { * @param accountId ID of the new account * @param updater updater to populate the new account * @return the newly created account - * @throws OrmDuplicateKeyException 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 OrmException if creating the user branch fails + * @throws StorageException if creating the user branch fails * @throws ConfigInvalidException if any of the account fields has an invalid value */ public AccountState insert(String message, Account.Id accountId, AccountUpdater updater) - throws OrmException, IOException, ConfigInvalidException { + throws StorageException, IOException, ConfigInvalidException { return updateAccount( r -> { AccountConfig accountConfig = read(r, accountId); @@ -351,12 +351,12 @@ public class AccountsUpdate { * @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 * after the retry timeout exceeded - * @throws OrmException if updating the user branch fails + * @throws StorageException if updating the user branch fails * @throws ConfigInvalidException if any of the account fields has an invalid value */ public Optional update( String message, Account.Id accountId, Consumer update) - throws OrmException, LockFailureException, IOException, ConfigInvalidException { + throws StorageException, LockFailureException, IOException, ConfigInvalidException { return update(message, accountId, AccountUpdater.fromConsumer(update)); } @@ -372,11 +372,11 @@ public class AccountsUpdate { * @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 * after the retry timeout exceeded - * @throws OrmException if updating the user branch fails + * @throws StorageException if updating the user branch fails * @throws ConfigInvalidException if any of the account fields has an invalid value */ public Optional update(String message, Account.Id accountId, AccountUpdater updater) - throws OrmException, LockFailureException, IOException, ConfigInvalidException { + throws StorageException, LockFailureException, IOException, ConfigInvalidException { return updateAccount( r -> { AccountConfig accountConfig = read(r, accountId); @@ -407,7 +407,7 @@ public class AccountsUpdate { } private Optional updateAccount(AccountUpdate accountUpdate) - throws IOException, ConfigInvalidException, OrmException { + throws IOException, ConfigInvalidException, StorageException { return executeAccountUpdate( () -> { try (Repository allUsersRepo = repoManager.openRepository(allUsersName)) { @@ -423,7 +423,7 @@ public class AccountsUpdate { } private Optional executeAccountUpdate(Action> action) - throws IOException, ConfigInvalidException, OrmException { + throws IOException, ConfigInvalidException, StorageException { try { return retryHelper.execute( ActionType.ACCOUNT_UPDATE, action, LockFailureException.class::isInstance); @@ -431,8 +431,8 @@ public class AccountsUpdate { Throwables.throwIfUnchecked(e); Throwables.throwIfInstanceOf(e, IOException.class); Throwables.throwIfInstanceOf(e, ConfigInvalidException.class); - Throwables.throwIfInstanceOf(e, OrmException.class); - throw new OrmException(e); + Throwables.throwIfInstanceOf(e, StorageException.class); + throw new StorageException(e); } } @@ -441,7 +441,7 @@ public class AccountsUpdate { Optional rev, Account.Id accountId, InternalAccountUpdate update) - throws IOException, ConfigInvalidException, OrmDuplicateKeyException { + throws IOException, ConfigInvalidException, DuplicateKeyException { ExternalIdNotes.checkSameAccount( Iterables.concat( update.getCreatedExternalIds(), @@ -563,7 +563,7 @@ public class AccountsUpdate { @FunctionalInterface private static interface AccountUpdate { UpdatedAccount update(Repository allUsersRepo) - throws IOException, ConfigInvalidException, OrmException; + throws IOException, ConfigInvalidException, StorageException; } private static class UpdatedAccount { diff --git a/java/com/google/gerrit/server/account/DefaultRealm.java b/java/com/google/gerrit/server/account/DefaultRealm.java index dde6e81f0c..33de2d2d0d 100644 --- a/java/com/google/gerrit/server/account/DefaultRealm.java +++ b/java/com/google/gerrit/server/account/DefaultRealm.java @@ -16,11 +16,11 @@ package com.google.gerrit.server.account; import com.google.common.annotations.VisibleForTesting; import com.google.common.base.Strings; +import com.google.gerrit.exceptions.StorageException; import com.google.gerrit.extensions.client.AccountFieldName; import com.google.gerrit.extensions.client.AuthType; import com.google.gerrit.reviewdb.client.Account; import com.google.gerrit.server.config.AuthConfig; -import com.google.gwtorm.server.OrmException; import com.google.inject.Inject; import com.google.inject.Provider; import com.google.inject.Singleton; @@ -87,7 +87,7 @@ public class DefaultRealm extends AbstractRealm { if (1 == c.size()) { return c.iterator().next(); } - } catch (OrmException e) { + } catch (StorageException e) { throw new IOException("Failed to query accounts by email", e); } } diff --git a/java/com/google/gerrit/server/account/Emails.java b/java/com/google/gerrit/server/account/Emails.java index 7c798ca7e4..9fe8b6423f 100644 --- a/java/com/google/gerrit/server/account/Emails.java +++ b/java/com/google/gerrit/server/account/Emails.java @@ -20,6 +20,7 @@ import com.google.common.base.Throwables; import com.google.common.collect.ImmutableSet; import com.google.common.collect.ImmutableSetMultimap; import com.google.common.collect.Streams; +import com.google.gerrit.exceptions.StorageException; import com.google.gerrit.reviewdb.client.Account; import com.google.gerrit.server.account.externalids.ExternalId; import com.google.gerrit.server.account.externalids.ExternalIds; @@ -27,7 +28,6 @@ import com.google.gerrit.server.query.account.InternalAccountQuery; import com.google.gerrit.server.update.RetryHelper; import com.google.gerrit.server.update.RetryHelper.Action; import com.google.gerrit.server.update.RetryHelper.ActionType; -import com.google.gwtorm.server.OrmException; import com.google.inject.Inject; import com.google.inject.Provider; import com.google.inject.Singleton; @@ -69,7 +69,7 @@ public class Emails { * * @see #getAccountsFor(String...) */ - public ImmutableSet getAccountFor(String email) throws IOException, OrmException { + public ImmutableSet getAccountFor(String email) throws IOException, StorageException { return Streams.concat( externalIds.byEmail(email).stream().map(ExternalId::accountId), executeIndexQuery(() -> queryProvider.get().byPreferredEmail(email).stream()) @@ -83,7 +83,7 @@ public class Emails { * @see #getAccountFor(String) */ public ImmutableSetMultimap getAccountsFor(String... emails) - throws IOException, OrmException { + throws IOException, StorageException { ImmutableSetMultimap.Builder builder = ImmutableSetMultimap.builder(); externalIds.byEmails(emails).entries().stream() .forEach(e -> builder.put(e.getKey(), e.getValue().accountId())); @@ -102,13 +102,14 @@ public class Emails { return externalIds.byEmail(email).stream().map(ExternalId::accountId).collect(toImmutableSet()); } - private T executeIndexQuery(Action action) throws OrmException { + private T executeIndexQuery(Action action) throws StorageException { try { - return retryHelper.execute(ActionType.INDEX_QUERY, action, OrmException.class::isInstance); + return retryHelper.execute( + ActionType.INDEX_QUERY, action, StorageException.class::isInstance); } catch (Exception e) { Throwables.throwIfUnchecked(e); - Throwables.throwIfInstanceOf(e, OrmException.class); - throw new OrmException(e); + Throwables.throwIfInstanceOf(e, StorageException.class); + throw new StorageException(e); } } } diff --git a/java/com/google/gerrit/server/account/GroupIncludeCacheImpl.java b/java/com/google/gerrit/server/account/GroupIncludeCacheImpl.java index a089d9e216..92148ab282 100644 --- a/java/com/google/gerrit/server/account/GroupIncludeCacheImpl.java +++ b/java/com/google/gerrit/server/account/GroupIncludeCacheImpl.java @@ -22,6 +22,7 @@ import com.google.common.cache.LoadingCache; import com.google.common.collect.ImmutableList; import com.google.common.collect.ImmutableSet; 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.AccountGroup; import com.google.gerrit.server.cache.CacheModule; @@ -30,7 +31,6 @@ import com.google.gerrit.server.group.db.Groups; import com.google.gerrit.server.logging.TraceContext; import com.google.gerrit.server.logging.TraceContext.TraceTimer; import com.google.gerrit.server.query.group.InternalGroupQuery; -import com.google.gwtorm.server.OrmException; import com.google.inject.Inject; import com.google.inject.Module; import com.google.inject.Provider; @@ -152,7 +152,7 @@ public class GroupIncludeCacheImpl implements GroupIncludeCache { } @Override - public ImmutableSet load(Account.Id memberId) throws OrmException { + public ImmutableSet load(Account.Id memberId) throws StorageException { try (TraceTimer timer = TraceContext.newTimer("Loading groups with member %s", memberId)) { return groupQueryProvider.get().byMember(memberId).stream() .map(InternalGroup::getGroupUUID) @@ -171,7 +171,7 @@ public class GroupIncludeCacheImpl implements GroupIncludeCache { } @Override - public ImmutableList load(AccountGroup.UUID key) throws OrmException { + public ImmutableList load(AccountGroup.UUID key) throws StorageException { try (TraceTimer timer = TraceContext.newTimer("Loading parent groups of %s", key)) { return groupQueryProvider.get().bySubgroup(key).stream() .map(InternalGroup::getGroupUUID) diff --git a/java/com/google/gerrit/server/account/SetInactiveFlag.java b/java/com/google/gerrit/server/account/SetInactiveFlag.java index a683849a81..92349002a9 100644 --- a/java/com/google/gerrit/server/account/SetInactiveFlag.java +++ b/java/com/google/gerrit/server/account/SetInactiveFlag.java @@ -14,6 +14,7 @@ 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.ResourceNotFoundException; import com.google.gerrit.extensions.restapi.Response; @@ -23,7 +24,6 @@ import com.google.gerrit.server.ServerInitiated; import com.google.gerrit.server.plugincontext.PluginSetContext; import com.google.gerrit.server.validators.AccountActivationValidationListener; import com.google.gerrit.server.validators.ValidationException; -import com.google.gwtorm.server.OrmException; import com.google.inject.Inject; import com.google.inject.Provider; import com.google.inject.Singleton; @@ -48,7 +48,7 @@ public class SetInactiveFlag { } public Response deactivate(Account.Id accountId) - throws RestApiException, IOException, ConfigInvalidException, OrmException { + throws RestApiException, IOException, ConfigInvalidException, StorageException { AtomicBoolean alreadyInactive = new AtomicBoolean(false); AtomicReference> exception = new AtomicReference<>(Optional.empty()); accountsUpdateProvider @@ -81,7 +81,7 @@ public class SetInactiveFlag { } public Response activate(Account.Id accountId) - throws RestApiException, IOException, ConfigInvalidException, OrmException { + throws RestApiException, IOException, ConfigInvalidException, StorageException { AtomicBoolean alreadyActive = new AtomicBoolean(false); AtomicReference> exception = new AtomicReference<>(Optional.empty()); accountsUpdateProvider diff --git a/java/com/google/gerrit/server/account/externalids/DuplicateExternalIdKeyException.java b/java/com/google/gerrit/server/account/externalids/DuplicateExternalIdKeyException.java index b4c82d0b94..aa092786f9 100644 --- a/java/com/google/gerrit/server/account/externalids/DuplicateExternalIdKeyException.java +++ b/java/com/google/gerrit/server/account/externalids/DuplicateExternalIdKeyException.java @@ -14,13 +14,13 @@ package com.google.gerrit.server.account.externalids; -import com.google.gwtorm.server.OrmDuplicateKeyException; +import com.google.gerrit.exceptions.DuplicateKeyException; /** * Exception that is thrown if an external ID cannot be inserted because an external ID with the * same key already exists. */ -public class DuplicateExternalIdKeyException extends OrmDuplicateKeyException { +public class DuplicateExternalIdKeyException extends DuplicateKeyException { private static final long serialVersionUID = 1L; private final ExternalId.Key duplicateKey; diff --git a/java/com/google/gerrit/server/api/BUILD b/java/com/google/gerrit/server/api/BUILD index cee1dfdd66..b9e26de154 100644 --- a/java/com/google/gerrit/server/api/BUILD +++ b/java/com/google/gerrit/server/api/BUILD @@ -7,13 +7,13 @@ java_library( deps = [ "//java/com/google/gerrit/common:annotations", "//java/com/google/gerrit/common:server", + "//java/com/google/gerrit/exceptions", "//java/com/google/gerrit/extensions:api", "//java/com/google/gerrit/lifecycle", "//java/com/google/gerrit/reviewdb:server", "//java/com/google/gerrit/server", "//java/com/google/gerrit/server/restapi", "//java/com/google/gerrit/util/cli", - "//java/com/google/gwtorm", "//lib:args4j", "//lib:guava", "//lib:servlet-api-3_1", diff --git a/java/com/google/gerrit/server/api/changes/ChangeApiImpl.java b/java/com/google/gerrit/server/api/changes/ChangeApiImpl.java index 6763f517ef..f6887182ef 100644 --- a/java/com/google/gerrit/server/api/changes/ChangeApiImpl.java +++ b/java/com/google/gerrit/server/api/changes/ChangeApiImpl.java @@ -19,6 +19,7 @@ import static com.google.gerrit.server.api.ApiUtil.asRestApiException; import com.google.common.collect.ImmutableListMultimap; import com.google.common.collect.ListMultimap; import com.google.gerrit.common.Nullable; +import com.google.gerrit.exceptions.StorageException; import com.google.gerrit.extensions.api.changes.AbandonInput; import com.google.gerrit.extensions.api.changes.AddReviewerInput; import com.google.gerrit.extensions.api.changes.AddReviewerResult; @@ -103,7 +104,6 @@ import com.google.gerrit.server.restapi.change.SubmittedTogether; import com.google.gerrit.server.restapi.change.SuggestChangeReviewers; import com.google.gerrit.server.restapi.change.Unignore; import com.google.gerrit.util.cli.CmdLineParser; -import com.google.gwtorm.server.OrmException; import com.google.inject.Inject; import com.google.inject.Injector; import com.google.inject.Provider; @@ -613,7 +613,7 @@ class ChangeApiImpl implements ChangeApi { } else { unignore.apply(change, new Input()); } - } catch (OrmException | IllegalLabelException e) { + } catch (StorageException | IllegalLabelException e) { throw asRestApiException("Cannot ignore change", e); } } @@ -622,7 +622,7 @@ class ChangeApiImpl implements ChangeApi { public boolean ignored() throws RestApiException { try { return stars.isIgnored(change); - } catch (OrmException e) { + } catch (StorageException e) { throw asRestApiException("Cannot check if ignored", e); } } @@ -637,7 +637,7 @@ class ChangeApiImpl implements ChangeApi { } else { markAsUnreviewed.apply(change, new Input()); } - } catch (OrmException | IllegalLabelException e) { + } catch (StorageException | IllegalLabelException e) { throw asRestApiException( "Cannot mark change as " + (reviewed ? "reviewed" : "unreviewed"), e); } diff --git a/java/com/google/gerrit/server/api/changes/ChangeEditApiImpl.java b/java/com/google/gerrit/server/api/changes/ChangeEditApiImpl.java index 5aa4cf13ad..b3a5d93f7a 100644 --- a/java/com/google/gerrit/server/api/changes/ChangeEditApiImpl.java +++ b/java/com/google/gerrit/server/api/changes/ChangeEditApiImpl.java @@ -16,6 +16,7 @@ package com.google.gerrit.server.api.changes; 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.PublishChangeEditInput; import com.google.gerrit.extensions.client.ChangeEditDetailOption; @@ -34,7 +35,6 @@ import com.google.gerrit.server.restapi.change.ChangeEdits; import com.google.gerrit.server.restapi.change.DeleteChangeEdit; import com.google.gerrit.server.restapi.change.PublishChangeEdit; import com.google.gerrit.server.restapi.change.RebaseChangeEdit; -import com.google.gwtorm.server.OrmException; import com.google.inject.Inject; import com.google.inject.Provider; import com.google.inject.assistedinject.Assisted; @@ -242,7 +242,7 @@ public class ChangeEditApiImpl implements ChangeEditApi { } private ChangeEditResource getChangeEditResource(String filePath) - throws ResourceNotFoundException, AuthException, IOException, OrmException { + throws ResourceNotFoundException, AuthException, IOException, StorageException { return changeEdits.parse(changeResource, IdString.fromDecoded(filePath)); } } diff --git a/java/com/google/gerrit/server/api/projects/ProjectsImpl.java b/java/com/google/gerrit/server/api/projects/ProjectsImpl.java index 721d878820..5d25d1aba0 100644 --- a/java/com/google/gerrit/server/api/projects/ProjectsImpl.java +++ b/java/com/google/gerrit/server/api/projects/ProjectsImpl.java @@ -16,6 +16,7 @@ package com.google.gerrit.server.api.projects; import static com.google.gerrit.server.api.ApiUtil.asRestApiException; +import com.google.gerrit.exceptions.StorageException; import com.google.gerrit.extensions.api.projects.ProjectApi; import com.google.gerrit.extensions.api.projects.ProjectInput; import com.google.gerrit.extensions.api.projects.Projects; @@ -28,7 +29,6 @@ import com.google.gerrit.server.restapi.project.ListProjects; import com.google.gerrit.server.restapi.project.ListProjects.FilterType; import com.google.gerrit.server.restapi.project.ProjectsCollection; import com.google.gerrit.server.restapi.project.QueryProjects; -import com.google.gwtorm.server.OrmException; import com.google.inject.Inject; import com.google.inject.Provider; import com.google.inject.Singleton; @@ -155,7 +155,7 @@ class ProjectsImpl implements Projects { .withLimit(r.getLimit()) .withStart(r.getStart()) .apply(); - } catch (OrmException e) { + } catch (StorageException e) { throw new RestApiException("Cannot query projects", e); } } diff --git a/java/com/google/gerrit/server/args4j/AccountIdHandler.java b/java/com/google/gerrit/server/args4j/AccountIdHandler.java index addb7f99da..efc1866eb2 100644 --- a/java/com/google/gerrit/server/args4j/AccountIdHandler.java +++ b/java/com/google/gerrit/server/args4j/AccountIdHandler.java @@ -16,6 +16,7 @@ package com.google.gerrit.server.args4j; import static com.google.gerrit.util.cli.Localizable.localizable; +import com.google.gerrit.exceptions.StorageException; import com.google.gerrit.extensions.client.AuthType; import com.google.gerrit.extensions.restapi.UnprocessableEntityException; import com.google.gerrit.reviewdb.client.Account; @@ -25,7 +26,6 @@ import com.google.gerrit.server.account.AccountResolver; import com.google.gerrit.server.account.AuthRequest; import com.google.gerrit.server.account.externalids.ExternalId; import com.google.gerrit.server.config.AuthConfig; -import com.google.gwtorm.server.OrmException; import com.google.inject.Inject; import com.google.inject.assistedinject.Assisted; import java.io.IOException; @@ -81,7 +81,7 @@ public class AccountIdHandler extends OptionHandler { throw new CmdLineException(owner, localizable("user \"%s\" not found"), token); } } - } catch (OrmException e) { + } catch (StorageException e) { throw new CmdLineException(owner, localizable("database is down")); } catch (IOException e) { throw new CmdLineException(owner, "Failed to load account", e); diff --git a/java/com/google/gerrit/server/args4j/ChangeIdHandler.java b/java/com/google/gerrit/server/args4j/ChangeIdHandler.java index 13832fabb0..77f0fd8cc7 100644 --- a/java/com/google/gerrit/server/args4j/ChangeIdHandler.java +++ b/java/com/google/gerrit/server/args4j/ChangeIdHandler.java @@ -17,12 +17,12 @@ package com.google.gerrit.server.args4j; import static com.google.gerrit.util.cli.Localizable.localizable; import com.google.common.base.Splitter; +import com.google.gerrit.exceptions.StorageException; import com.google.gerrit.reviewdb.client.Branch; import com.google.gerrit.reviewdb.client.Change; import com.google.gerrit.reviewdb.client.Project; import com.google.gerrit.server.query.change.ChangeData; import com.google.gerrit.server.query.change.InternalChangeQuery; -import com.google.gwtorm.server.OrmException; import com.google.inject.Inject; import com.google.inject.Provider; import com.google.inject.assistedinject.Assisted; @@ -67,7 +67,7 @@ public class ChangeIdHandler extends OptionHandler { } } catch (IllegalArgumentException e) { throw new CmdLineException(owner, localizable("Change-Id is not valid")); - } catch (OrmException e) { + } catch (StorageException e) { throw new CmdLineException(owner, localizable("Database error: %s"), e.getMessage()); } diff --git a/java/com/google/gerrit/server/audit/BUILD b/java/com/google/gerrit/server/audit/BUILD index b174f29425..fc8a3ccdc5 100644 --- a/java/com/google/gerrit/server/audit/BUILD +++ b/java/com/google/gerrit/server/audit/BUILD @@ -21,7 +21,6 @@ java_library( "//java/com/google/gerrit/server/util/time", "//java/com/google/gerrit/util/cli", "//java/com/google/gerrit/util/ssl", - "//java/com/google/gwtorm", "//java/org/apache/commons/net", "//java/org/eclipse/jgit:server", "//lib:args4j", diff --git a/java/com/google/gerrit/server/change/AbandonOp.java b/java/com/google/gerrit/server/change/AbandonOp.java index 458a680a92..dd139c333a 100644 --- a/java/com/google/gerrit/server/change/AbandonOp.java +++ b/java/com/google/gerrit/server/change/AbandonOp.java @@ -17,6 +17,7 @@ package com.google.gerrit.server.change; import com.google.common.base.Strings; import com.google.common.flogger.FluentLogger; import com.google.gerrit.common.Nullable; +import com.google.gerrit.exceptions.StorageException; import com.google.gerrit.extensions.restapi.ResourceConflictException; import com.google.gerrit.reviewdb.client.Change; import com.google.gerrit.reviewdb.client.ChangeMessage; @@ -32,7 +33,6 @@ import com.google.gerrit.server.notedb.ChangeUpdate; import com.google.gerrit.server.update.BatchUpdateOp; import com.google.gerrit.server.update.ChangeContext; import com.google.gerrit.server.update.Context; -import com.google.gwtorm.server.OrmException; import com.google.inject.Inject; import com.google.inject.assistedinject.Assisted; @@ -79,7 +79,8 @@ public class AbandonOp implements BatchUpdateOp { } @Override - public boolean updateChange(ChangeContext ctx) throws OrmException, ResourceConflictException { + public boolean updateChange(ChangeContext ctx) + throws StorageException, ResourceConflictException { change = ctx.getChange(); PatchSet.Id psId = change.currentPatchSetId(); ChangeUpdate update = ctx.getUpdate(psId); @@ -108,7 +109,7 @@ public class AbandonOp implements BatchUpdateOp { } @Override - public void postUpdate(Context ctx) throws OrmException { + public void postUpdate(Context ctx) throws StorageException { NotifyResolver.Result notify = ctx.getNotify(change.getId()); try { ReplyToChangeSender cm = abandonedSenderFactory.create(ctx.getProject(), change.getId()); diff --git a/java/com/google/gerrit/server/change/AbandonUtil.java b/java/com/google/gerrit/server/change/AbandonUtil.java index f505f6d1d2..2eb9ad25ac 100644 --- a/java/com/google/gerrit/server/change/AbandonUtil.java +++ b/java/com/google/gerrit/server/change/AbandonUtil.java @@ -17,6 +17,7 @@ package com.google.gerrit.server.change; import com.google.common.collect.ImmutableListMultimap; import com.google.common.collect.ListMultimap; import com.google.common.flogger.FluentLogger; +import com.google.gerrit.exceptions.StorageException; import com.google.gerrit.index.query.QueryParseException; import com.google.gerrit.reviewdb.client.Project; import com.google.gerrit.server.InternalUser; @@ -25,7 +26,6 @@ import com.google.gerrit.server.query.change.ChangeData; import com.google.gerrit.server.query.change.ChangeQueryBuilder; import com.google.gerrit.server.query.change.ChangeQueryProcessor; import com.google.gerrit.server.update.BatchUpdate; -import com.google.gwtorm.server.OrmException; import com.google.inject.Inject; import com.google.inject.Provider; import com.google.inject.Singleton; @@ -96,14 +96,14 @@ public class AbandonUtil { } } logger.atInfo().log("Auto-Abandoned %d of %d changes.", count, changesToAbandon.size()); - } catch (QueryParseException | OrmException e) { + } catch (QueryParseException | StorageException e) { logger.atSevere().withCause(e).log( "Failed to query inactive open changes for auto-abandoning."); } } private Collection getValidChanges(Collection changes, String query) - throws OrmException, QueryParseException { + throws StorageException, QueryParseException { Collection validChanges = new ArrayList<>(); for (ChangeData cd : changes) { String newQuery = query + " change:" + cd.getId(); diff --git a/java/com/google/gerrit/server/change/AccountPatchReviewStore.java b/java/com/google/gerrit/server/change/AccountPatchReviewStore.java index 69825eaf42..e942946854 100644 --- a/java/com/google/gerrit/server/change/AccountPatchReviewStore.java +++ b/java/com/google/gerrit/server/change/AccountPatchReviewStore.java @@ -16,9 +16,9 @@ package com.google.gerrit.server.change; import com.google.auto.value.AutoValue; 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.PatchSet; -import com.google.gwtorm.server.OrmException; import java.util.Collection; import java.util.Optional; @@ -54,9 +54,9 @@ public interface AccountPatchReviewStore { * @param path file path * @return {@code true} if the reviewed flag was updated, {@code false} if the reviewed flag was * already set - * @throws OrmException thrown if updating the reviewed flag failed + * @throws StorageException thrown if updating the reviewed flag failed */ - boolean markReviewed(PatchSet.Id psId, Account.Id accountId, String path) throws OrmException; + boolean markReviewed(PatchSet.Id psId, Account.Id accountId, String path) throws StorageException; /** * Marks the given files in the given patch set as reviewed by the given user. @@ -64,10 +64,10 @@ public interface AccountPatchReviewStore { * @param psId patch set ID * @param accountId account ID of the user * @param paths file paths - * @throws OrmException thrown if updating the reviewed flag failed + * @throws StorageException thrown if updating the reviewed flag failed */ void markReviewed(PatchSet.Id psId, Account.Id accountId, Collection paths) - throws OrmException; + throws StorageException; /** * Clears the reviewed flag for the given file in the given patch set for the given user. @@ -75,17 +75,17 @@ public interface AccountPatchReviewStore { * @param psId patch set ID * @param accountId account ID of the user * @param path file path - * @throws OrmException thrown if clearing the reviewed flag failed + * @throws StorageException thrown if clearing the reviewed flag failed */ - void clearReviewed(PatchSet.Id psId, Account.Id accountId, String path) throws OrmException; + void clearReviewed(PatchSet.Id psId, Account.Id accountId, String path) throws StorageException; /** * Clears the reviewed flags for all files in the given patch set for all users. * * @param psId patch set ID - * @throws OrmException thrown if clearing the reviewed flags failed + * @throws StorageException thrown if clearing the reviewed flags failed */ - void clearReviewed(PatchSet.Id psId) throws OrmException; + void clearReviewed(PatchSet.Id psId) throws StorageException; /** * Find the latest patch set, that is smaller or equals to the given patch set, where at least, @@ -95,8 +95,8 @@ public interface AccountPatchReviewStore { * @param accountId account ID of the user * @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 - * @throws OrmException thrown if accessing the reviewed flags failed + * @throws StorageException thrown if accessing the reviewed flags failed */ Optional findReviewed(PatchSet.Id psId, Account.Id accountId) - throws OrmException; + throws StorageException; } diff --git a/java/com/google/gerrit/server/change/ActionJson.java b/java/com/google/gerrit/server/change/ActionJson.java index 52c0451bcd..7c0304448a 100644 --- a/java/com/google/gerrit/server/change/ActionJson.java +++ b/java/com/google/gerrit/server/change/ActionJson.java @@ -20,6 +20,7 @@ import com.google.common.collect.ImmutableMap; import com.google.common.collect.Iterables; import com.google.common.collect.Lists; 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.common.ActionInfo; import com.google.gerrit.extensions.common.ChangeInfo; @@ -32,7 +33,6 @@ import com.google.gerrit.extensions.webui.UiAction; import com.google.gerrit.server.CurrentUser; import com.google.gerrit.server.extensions.webui.UiActions; import com.google.gerrit.server.notedb.ChangeNotes; -import com.google.gwtorm.server.OrmException; import com.google.inject.Inject; import com.google.inject.Provider; import com.google.inject.Singleton; @@ -70,7 +70,7 @@ public class ActionJson { this.userProvider = userProvider; } - public Map format(RevisionResource rsrc) throws OrmException { + public Map format(RevisionResource rsrc) throws StorageException { ChangeInfo changeInfo = null; RevisionInfo revisionInfo = null; List visitors = visitors(); @@ -97,7 +97,8 @@ public class ActionJson { } public RevisionInfo addRevisionActions( - @Nullable ChangeInfo changeInfo, RevisionInfo to, RevisionResource rsrc) throws OrmException { + @Nullable ChangeInfo changeInfo, RevisionInfo to, RevisionResource rsrc) + throws StorageException { List visitors = visitors(); if (!visitors.isEmpty()) { if (changeInfo != null) { diff --git a/java/com/google/gerrit/server/change/AddReviewersOp.java b/java/com/google/gerrit/server/change/AddReviewersOp.java index 46d57b54e3..2598951e69 100644 --- a/java/com/google/gerrit/server/change/AddReviewersOp.java +++ b/java/com/google/gerrit/server/change/AddReviewersOp.java @@ -27,6 +27,7 @@ import com.google.common.collect.ImmutableList; import com.google.common.collect.ImmutableSet; import com.google.common.collect.Lists; import com.google.common.collect.Streams; +import com.google.gerrit.exceptions.StorageException; import com.google.gerrit.extensions.client.ReviewerState; import com.google.gerrit.extensions.restapi.RestApiException; import com.google.gerrit.mail.Address; @@ -44,7 +45,6 @@ import com.google.gerrit.server.project.ProjectCache; import com.google.gerrit.server.update.BatchUpdateOp; import com.google.gerrit.server.update.ChangeContext; import com.google.gerrit.server.update.Context; -import com.google.gwtorm.server.OrmException; import com.google.inject.Inject; import com.google.inject.assistedinject.Assisted; import java.io.IOException; @@ -158,7 +158,7 @@ public class AddReviewersOp implements BatchUpdateOp { @Override public boolean updateChange(ChangeContext ctx) - throws RestApiException, OrmException, IOException { + throws RestApiException, StorageException, IOException { change = ctx.getChange(); if (!accountIds.isEmpty()) { if (state == CC) { diff --git a/java/com/google/gerrit/server/change/ChangeFinder.java b/java/com/google/gerrit/server/change/ChangeFinder.java index 5e7a9bf9f7..2c27e09734 100644 --- a/java/com/google/gerrit/server/change/ChangeFinder.java +++ b/java/com/google/gerrit/server/change/ChangeFinder.java @@ -20,6 +20,7 @@ import com.google.common.collect.ImmutableList; import com.google.common.collect.ImmutableSet; import com.google.common.collect.Sets; import com.google.common.primitives.Ints; +import com.google.gerrit.exceptions.StorageException; import com.google.gerrit.extensions.restapi.DeprecatedIdentifierException; import com.google.gerrit.extensions.restapi.Url; import com.google.gerrit.index.IndexConfig; @@ -37,7 +38,6 @@ import com.google.gerrit.server.notedb.ChangeNotes; import com.google.gerrit.server.project.NoSuchChangeException; import com.google.gerrit.server.query.change.ChangeData; import com.google.gerrit.server.query.change.InternalChangeQuery; -import com.google.gwtorm.server.OrmException; import com.google.inject.Inject; import com.google.inject.Module; import com.google.inject.Provider; @@ -106,7 +106,7 @@ public class ChangeFinder { this.allowedIdTypes = ImmutableSet.copyOf(configuredChangeIdTypes); } - public ChangeNotes findOne(String id) throws OrmException { + public ChangeNotes findOne(String id) throws StorageException { List ctls = find(id); if (ctls.size() != 1) { return null; @@ -119,14 +119,14 @@ public class ChangeFinder { * * @param id change identifier. * @return possibly-empty list of notes for all matching changes; may or may not be visible. - * @throws OrmException if an error occurred querying the database. + * @throws StorageException if an error occurred querying the database. */ - public List find(String id) throws OrmException { + public List find(String id) throws StorageException { try { return find(id, false); } catch (DeprecatedIdentifierException e) { // This can't happen because we don't enforce deprecation - throw new OrmException(e); + throw new StorageException(e); } } @@ -137,11 +137,11 @@ public class ChangeFinder { * @param enforceDeprecation boolean to see if we should throw {@link * DeprecatedIdentifierException} in case the identifier is deprecated * @return possibly-empty list of notes for all matching changes; may or may not be visible. - * @throws OrmException if an error occurred querying the database + * @throws StorageException if an error occurred querying the database * @throws DeprecatedIdentifierException if the identifier is deprecated. */ public List find(String id, boolean enforceDeprecation) - throws OrmException, DeprecatedIdentifierException { + throws StorageException, DeprecatedIdentifierException { if (id.isEmpty()) { return Collections.emptyList(); } @@ -195,16 +195,16 @@ public class ChangeFinder { } private List fromProjectNumber(String project, int changeNumber) - throws OrmException { + throws StorageException { Change.Id cId = new Change.Id(changeNumber); try { return ImmutableList.of( changeNotesFactory.createChecked(Project.NameKey.parse(project), cId)); } catch (NoSuchChangeException e) { return Collections.emptyList(); - } catch (OrmException e) { + } catch (StorageException e) { // Distinguish between a RepositoryNotFoundException (project argument invalid) and - // other OrmExceptions (failure in the persistence layer). + // other StorageExceptions (failure in the persistence layer). if (Throwables.getRootCause(e) instanceof RepositoryNotFoundException) { return Collections.emptyList(); } @@ -212,7 +212,7 @@ public class ChangeFinder { } } - public ChangeNotes findOne(Change.Id id) throws OrmException { + public ChangeNotes findOne(Change.Id id) throws StorageException { List notes = find(id); if (notes.size() != 1) { throw new NoSuchChangeException(id); @@ -220,7 +220,7 @@ public class ChangeFinder { return notes.get(0); } - public List find(Change.Id id) throws OrmException { + public List find(Change.Id id) throws StorageException { String project = changeIdProjectCache.getIfPresent(id); if (project != null) { return fromProjectNumber(project, id.get()); @@ -236,7 +236,7 @@ public class ChangeFinder { return asChangeNotes(r); } - private List asChangeNotes(List cds) throws OrmException { + private List asChangeNotes(List cds) throws StorageException { List notes = new ArrayList<>(cds.size()); if (!indexConfig.separateChangeSubIndexes()) { for (ChangeData cd : cds) { diff --git a/java/com/google/gerrit/server/change/ChangeInserter.java b/java/com/google/gerrit/server/change/ChangeInserter.java index 53719084e9..8d5c9ad28c 100644 --- a/java/com/google/gerrit/server/change/ChangeInserter.java +++ b/java/com/google/gerrit/server/change/ChangeInserter.java @@ -30,6 +30,7 @@ import com.google.common.flogger.FluentLogger; import com.google.gerrit.common.FooterConstants; import com.google.gerrit.common.data.LabelType; 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.client.ReviewerState; import com.google.gerrit.extensions.restapi.ResourceConflictException; @@ -68,7 +69,6 @@ import com.google.gerrit.server.update.Context; import com.google.gerrit.server.update.InsertChangeOp; import com.google.gerrit.server.update.RepoContext; import com.google.gerrit.server.util.RequestScopePropagator; -import com.google.gwtorm.server.OrmException; import com.google.inject.Inject; import com.google.inject.assistedinject.Assisted; import java.io.IOException; @@ -369,7 +369,7 @@ public class ChangeInserter implements InsertChangeOp { @Override public boolean updateChange(ChangeContext ctx) - throws RestApiException, OrmException, IOException, PermissionBackendException, + throws RestApiException, StorageException, IOException, PermissionBackendException, ConfigInvalidException { change = ctx.getChange(); // Use defensive copy created by ChangeControl. patchSetInfo = diff --git a/java/com/google/gerrit/server/change/ChangeJson.java b/java/com/google/gerrit/server/change/ChangeJson.java index fdb51c4845..52726b380a 100644 --- a/java/com/google/gerrit/server/change/ChangeJson.java +++ b/java/com/google/gerrit/server/change/ChangeJson.java @@ -48,6 +48,7 @@ import com.google.gerrit.common.data.SubmitRecord; import com.google.gerrit.common.data.SubmitRecord.Status; import com.google.gerrit.common.data.SubmitRequirement; import com.google.gerrit.common.data.SubmitTypeRecord; +import com.google.gerrit.exceptions.StorageException; import com.google.gerrit.extensions.api.changes.FixInput; import com.google.gerrit.extensions.client.ListChangesOption; import com.google.gerrit.extensions.client.ReviewerState; @@ -96,7 +97,6 @@ import com.google.gerrit.server.project.RemoveReviewerControl; import com.google.gerrit.server.project.SubmitRuleOptions; import com.google.gerrit.server.query.change.ChangeData; import com.google.gerrit.server.query.change.ChangeData.ChangedLines; -import com.google.gwtorm.server.OrmException; import com.google.inject.Inject; import com.google.inject.Provider; import com.google.inject.Singleton; @@ -268,23 +268,23 @@ public class ChangeJson { return this; } - public ChangeInfo format(ChangeResource rsrc) throws OrmException { + public ChangeInfo format(ChangeResource rsrc) throws StorageException { return format(changeDataFactory.create(rsrc.getNotes())); } - public ChangeInfo format(Change change) throws OrmException { + public ChangeInfo format(Change change) throws StorageException { return format(changeDataFactory.create(change)); } - public ChangeInfo format(Project.NameKey project, Change.Id id) throws OrmException { + public ChangeInfo format(Project.NameKey project, Change.Id id) throws StorageException { return format(project, id, ChangeInfo::new); } - public ChangeInfo format(ChangeData cd) throws OrmException { + public ChangeInfo format(ChangeData cd) throws StorageException { return format(cd, Optional.empty(), true, ChangeInfo::new); } - public ChangeInfo format(RevisionResource rsrc) throws OrmException { + public ChangeInfo format(RevisionResource rsrc) throws StorageException { ChangeData cd = changeDataFactory.create(rsrc.getNotes()); return format(cd, Optional.of(rsrc.getPatchSet().getId()), true, ChangeInfo::new); } @@ -309,7 +309,7 @@ public class ChangeJson { } public List format(Collection in) - throws OrmException, PermissionBackendException { + throws StorageException, PermissionBackendException { accountLoader = accountLoaderFactory.create(has(DETAILED_ACCOUNTS)); ensureLoaded(in); List out = new ArrayList<>(in.size()); @@ -321,11 +321,12 @@ public class ChangeJson { } public I format( - Project.NameKey project, Change.Id id, Supplier changeInfoSupplier) throws OrmException { + Project.NameKey project, Change.Id id, Supplier changeInfoSupplier) + throws StorageException { ChangeNotes notes; try { notes = notesFactory.createChecked(project, id); - } catch (OrmException e) { + } catch (StorageException e) { if (!has(CHECK)) { throw e; } @@ -367,7 +368,7 @@ public class ChangeJson { Optional limitToPsId, boolean fillAccountLoader, Supplier changeInfoSupplier) - throws OrmException { + throws StorageException { try { if (fillAccountLoader) { accountLoader = accountLoaderFactory.create(has(DETAILED_ACCOUNTS)); @@ -378,19 +379,19 @@ public class ChangeJson { return toChangeInfo(cd, limitToPsId, changeInfoSupplier); } catch (PatchListNotAvailableException | GpgException - | OrmException + | StorageException | IOException | PermissionBackendException | RuntimeException e) { if (!has(CHECK)) { - Throwables.throwIfInstanceOf(e, OrmException.class); - throw new OrmException(e); + Throwables.throwIfInstanceOf(e, StorageException.class); + throw new StorageException(e); } return checkOnly(cd, changeInfoSupplier); } } - private void ensureLoaded(Iterable all) throws OrmException { + private void ensureLoaded(Iterable all) throws StorageException { if (lazyLoad) { ChangeData.ensureChangeLoaded(all); if (has(ALL_REVISIONS)) { @@ -425,7 +426,7 @@ public class ChangeJson { try { ensureLoaded(Collections.singleton(cd)); changeInfos.add(format(cd, Optional.empty(), false, ChangeInfo::new)); - } catch (OrmException | RuntimeException e) { + } catch (StorageException | RuntimeException e) { logger.atWarning().withCause(e).log( "Omitting corrupt change %s from results", cd.getId()); } @@ -438,7 +439,7 @@ public class ChangeJson { ChangeNotes notes; try { notes = cd.notes(); - } catch (OrmException e) { + } catch (StorageException e) { String msg = "Error loading change"; logger.atWarning().withCause(e).log(msg + " %s", cd.getId()); I info = changeInfoSupplier.get(); @@ -477,8 +478,8 @@ public class ChangeJson { private I toChangeInfo( ChangeData cd, Optional limitToPsId, Supplier changeInfoSupplier) - throws PatchListNotAvailableException, GpgException, OrmException, PermissionBackendException, - IOException { + throws PatchListNotAvailableException, GpgException, StorageException, + PermissionBackendException, IOException { try (Timer0.Context ignored = metrics.toChangeInfoLatency.start()) { return toChangeInfoImpl(cd, limitToPsId, changeInfoSupplier); } @@ -486,8 +487,8 @@ public class ChangeJson { private I toChangeInfoImpl( ChangeData cd, Optional limitToPsId, Supplier changeInfoSupplier) - throws PatchListNotAvailableException, GpgException, OrmException, PermissionBackendException, - IOException { + throws PatchListNotAvailableException, GpgException, StorageException, + PermissionBackendException, IOException { I out = changeInfoSupplier.get(); CurrentUser user = userProvider.get(); @@ -638,7 +639,7 @@ public class ChangeJson { return reviewerMap; } - private Collection reviewerUpdates(ChangeData cd) throws OrmException { + private Collection reviewerUpdates(ChangeData cd) throws StorageException { List reviewerUpdates = cd.reviewerUpdates(); List result = new ArrayList<>(reviewerUpdates.size()); for (ReviewerStatusUpdate c : reviewerUpdates) { @@ -656,7 +657,7 @@ public class ChangeJson { return SubmitRecord.allRecordsOK(cd.submitRecords(SUBMIT_RULE_OPTIONS_STRICT)); } - private void setSubmitter(ChangeData cd, ChangeInfo out) throws OrmException { + private void setSubmitter(ChangeData cd, ChangeInfo out) throws StorageException { Optional s = cd.getSubmitApproval(); if (!s.isPresent()) { return; @@ -665,7 +666,7 @@ public class ChangeJson { out.submitter = accountLoader.get(s.get().getAccountId()); } - private Collection messages(ChangeData cd) throws OrmException { + private Collection messages(ChangeData cd) throws StorageException { List messages = cmUtil.byChange(cd.notes()); if (messages.isEmpty()) { return Collections.emptyList(); @@ -679,7 +680,7 @@ public class ChangeJson { } private Collection removableReviewers(ChangeData cd, ChangeInfo out) - throws PermissionBackendException, OrmException { + throws PermissionBackendException, StorageException { // Although this is called removableReviewers, this method also determines // which CCs are removable. // @@ -768,7 +769,7 @@ public class ChangeJson { } private Map loadPatchSets(ChangeData cd, Optional limitToPsId) - throws OrmException { + throws StorageException { Collection src; if (has(ALL_REVISIONS) || has(MESSAGES)) { src = cd.patchSets(); @@ -777,12 +778,12 @@ public class ChangeJson { if (limitToPsId.isPresent()) { ps = cd.patchSet(limitToPsId.get()); if (ps == null) { - throw new OrmException("missing patch set " + limitToPsId.get()); + throw new StorageException("missing patch set " + limitToPsId.get()); } } else { ps = cd.currentPatchSet(); if (ps == null) { - throw new OrmException("missing current patch set for change " + cd.getId()); + throw new StorageException("missing current patch set for change " + cd.getId()); } } src = Collections.singletonList(ps); @@ -800,7 +801,7 @@ public class ChangeJson { * lazyload}. */ private PermissionBackend.ForChange permissionBackendForChange(CurrentUser user, ChangeData cd) - throws OrmException { + throws StorageException { PermissionBackend.WithUser withUser = permissionBackend.user(user); return lazyLoad ? withUser.change(cd) diff --git a/java/com/google/gerrit/server/change/ChangeKindCacheImpl.java b/java/com/google/gerrit/server/change/ChangeKindCacheImpl.java index 170223dae4..4c68f2def0 100644 --- a/java/com/google/gerrit/server/change/ChangeKindCacheImpl.java +++ b/java/com/google/gerrit/server/change/ChangeKindCacheImpl.java @@ -23,6 +23,7 @@ import com.google.common.cache.Weigher; import com.google.common.collect.FluentIterable; import com.google.common.flogger.FluentLogger; import com.google.gerrit.common.Nullable; +import com.google.gerrit.exceptions.StorageException; import com.google.gerrit.extensions.client.ChangeKind; import com.google.gerrit.proto.Protos; import com.google.gerrit.reviewdb.client.Change; @@ -38,7 +39,6 @@ import com.google.gerrit.server.git.GitRepositoryManager; import com.google.gerrit.server.git.InMemoryInserter; import com.google.gerrit.server.git.MergeUtil; import com.google.gerrit.server.query.change.ChangeData; -import com.google.gwtorm.server.OrmException; import com.google.inject.Inject; import com.google.inject.Module; import com.google.inject.name.Named; @@ -392,7 +392,7 @@ public class ChangeKindCacheImpl implements ChangeKindCache { ObjectId.fromString(priorPs.getRevision().get()), ObjectId.fromString(patch.getRevision().get())); } - } catch (OrmException e) { + } catch (StorageException e) { // Do nothing; assume we have a complex change logger.atWarning().withCause(e).log( "Unable to get change kind for patchSet %s of change %s", diff --git a/java/com/google/gerrit/server/change/ChangeResource.java b/java/com/google/gerrit/server/change/ChangeResource.java index 3ec61efe07..98b728f167 100644 --- a/java/com/google/gerrit/server/change/ChangeResource.java +++ b/java/com/google/gerrit/server/change/ChangeResource.java @@ -21,6 +21,7 @@ import com.google.common.collect.ImmutableList; import com.google.common.flogger.FluentLogger; import com.google.common.hash.Hasher; import com.google.common.hash.Hashing; +import com.google.gerrit.exceptions.StorageException; import com.google.gerrit.extensions.restapi.RestResource; import com.google.gerrit.extensions.restapi.RestResource.HasETag; import com.google.gerrit.extensions.restapi.RestView; @@ -39,7 +40,6 @@ import com.google.gerrit.server.notedb.ChangeNotes; import com.google.gerrit.server.permissions.PermissionBackend; import com.google.gerrit.server.project.ProjectCache; import com.google.gerrit.server.project.ProjectState; -import com.google.gwtorm.server.OrmException; import com.google.inject.Inject; import com.google.inject.TypeLiteral; import com.google.inject.assistedinject.Assisted; @@ -159,7 +159,7 @@ public class ChangeResource implements RestResource, HasETag { // message is automatically added as reviewer. Hence if we include removed reviewers we can // be sure that we have all accounts that posted messages on the change. accounts.addAll(approvalUtil.getReviewers(notes).all()); - } catch (OrmException e) { + } catch (StorageException e) { // This ETag will be invalidated if it loads next time. } @@ -175,7 +175,7 @@ public class ChangeResource implements RestResource, HasETag { ObjectId noteId; try { noteId = notes.loadRevision(); - } catch (OrmException e) { + } catch (StorageException e) { noteId = null; // This ETag will be invalidated if it loads next time. } hashObjectId(h, noteId, buf); diff --git a/java/com/google/gerrit/server/change/ConsistencyChecker.java b/java/com/google/gerrit/server/change/ConsistencyChecker.java index 83c73871c9..640b093080 100644 --- a/java/com/google/gerrit/server/change/ConsistencyChecker.java +++ b/java/com/google/gerrit/server/change/ConsistencyChecker.java @@ -30,6 +30,7 @@ import com.google.common.collect.SetMultimap; import com.google.common.flogger.FluentLogger; import com.google.gerrit.common.FooterConstants; import com.google.gerrit.common.Nullable; +import com.google.gerrit.exceptions.StorageException; import com.google.gerrit.extensions.api.changes.FixInput; import com.google.gerrit.extensions.common.ProblemInfo; import com.google.gerrit.extensions.common.ProblemInfo.Status; @@ -55,7 +56,6 @@ import com.google.gerrit.server.update.RepoContext; import com.google.gerrit.server.update.RetryHelper; import com.google.gerrit.server.update.UpdateException; import com.google.gerrit.server.util.time.TimeUtil; -import com.google.gwtorm.server.OrmException; import com.google.inject.Inject; import com.google.inject.Provider; import java.io.IOException; @@ -232,7 +232,7 @@ public class ConsistencyChecker { problem( String.format("Current patch set %d not found", change().currentPatchSetId().get())); } - } catch (OrmException e) { + } catch (StorageException e) { error("Failed to look up current patch set", e); } } @@ -256,7 +256,7 @@ public class ConsistencyChecker { try { // Iterate in descending order. all = PS_ID_ORDER.sortedCopy(psUtil.byChange(notes)); - } catch (OrmException e) { + } catch (StorageException e) { return error("Failed to look up patch sets", e); } patchSetsBySha = MultimapBuilder.hashKeys(all.size()).treeSetValues(PS_ID_ORDER).build(); @@ -425,7 +425,7 @@ public class ConsistencyChecker { if (!c.getDest().equals(change().getDest())) { continue; } - } catch (OrmException e) { + } catch (StorageException e) { warn(e); // Include this patch set; should cause an error below, which is good. } @@ -556,7 +556,7 @@ public class ConsistencyChecker { notes = notesFactory.createChecked(inserter.getChange()); insertPatchSetProblem.status = Status.FIXED; insertPatchSetProblem.outcome = "Inserted as patch set " + psId.get(); - } catch (OrmException | IOException | UpdateException | RestApiException e) { + } catch (StorageException | IOException | UpdateException | RestApiException e) { warn(e); for (ProblemInfo pi : currProblems) { pi.status = Status.FIX_FAILED; @@ -574,7 +574,7 @@ public class ConsistencyChecker { } @Override - public boolean updateChange(ChangeContext ctx) throws OrmException { + public boolean updateChange(ChangeContext ctx) throws StorageException { ctx.getChange().setStatus(Change.Status.MERGED); ctx.getUpdate(ctx.getChange().currentPatchSetId()).fixStatus(Change.Status.MERGED); p.status = Status.FIXED; @@ -673,9 +673,9 @@ public class ConsistencyChecker { @Override public boolean updateChange(ChangeContext ctx) - throws OrmException, PatchSetInfoNotAvailableException { + throws StorageException, PatchSetInfoNotAvailableException { // Delete dangling key references. - accountPatchReviewStore.run(s -> s.clearReviewed(psId), OrmException.class); + accountPatchReviewStore.run(s -> s.clearReviewed(psId), StorageException.class); // For NoteDb setting the state to deleted is sufficient to filter everything out. ctx.getUpdate(psId).setPatchSetState(PatchSetState.DELETED); @@ -706,7 +706,8 @@ public class ConsistencyChecker { @Override public boolean updateChange(ChangeContext ctx) - throws OrmException, PatchSetInfoNotAvailableException, NoPatchSetsWouldRemainException { + throws StorageException, PatchSetInfoNotAvailableException, + NoPatchSetsWouldRemainException { if (!toDelete.contains(ctx.getChange().currentPatchSetId())) { return false; } diff --git a/java/com/google/gerrit/server/change/DeleteChangeOp.java b/java/com/google/gerrit/server/change/DeleteChangeOp.java index 1a579f3077..d0fa27a1ee 100644 --- a/java/com/google/gerrit/server/change/DeleteChangeOp.java +++ b/java/com/google/gerrit/server/change/DeleteChangeOp.java @@ -14,6 +14,7 @@ package com.google.gerrit.server.change; +import com.google.gerrit.exceptions.StorageException; import com.google.gerrit.extensions.restapi.MethodNotAllowedException; import com.google.gerrit.extensions.restapi.ResourceConflictException; import com.google.gerrit.extensions.restapi.RestApiException; @@ -27,7 +28,6 @@ import com.google.gerrit.server.project.NoSuchChangeException; import com.google.gerrit.server.update.BatchUpdateOp; import com.google.gerrit.server.update.ChangeContext; import com.google.gerrit.server.update.RepoContext; -import com.google.gwtorm.server.OrmException; import com.google.inject.Inject; import com.google.inject.assistedinject.Assisted; import java.io.IOException; @@ -67,7 +67,7 @@ public class DeleteChangeOp implements BatchUpdateOp { // fail gracefully if the second delete fails, but fortunately that's not what happens. @Override public boolean updateChange(ChangeContext ctx) - throws RestApiException, OrmException, IOException { + throws RestApiException, StorageException, IOException { Collection patchSets = psUtil.byChange(ctx.getNotes()); ensureDeletable(ctx, id, patchSets); @@ -107,9 +107,9 @@ public class DeleteChangeOp implements BatchUpdateOp { } private void cleanUpReferences(ChangeContext ctx, Change.Id id, Collection patchSets) - throws OrmException, NoSuchChangeException { + throws StorageException, NoSuchChangeException { for (PatchSet ps : patchSets) { - accountPatchReviewStore.run(s -> s.clearReviewed(ps.getId()), OrmException.class); + accountPatchReviewStore.run(s -> s.clearReviewed(ps.getId()), StorageException.class); } // Non-atomic operation on Accounts table; not much we can do to make it diff --git a/java/com/google/gerrit/server/change/DeleteReviewerByEmailOp.java b/java/com/google/gerrit/server/change/DeleteReviewerByEmailOp.java index d7d4c0e5c5..68530493e7 100644 --- a/java/com/google/gerrit/server/change/DeleteReviewerByEmailOp.java +++ b/java/com/google/gerrit/server/change/DeleteReviewerByEmailOp.java @@ -15,6 +15,7 @@ package com.google.gerrit.server.change; import com.google.common.flogger.FluentLogger; +import com.google.gerrit.exceptions.StorageException; import com.google.gerrit.mail.Address; import com.google.gerrit.reviewdb.client.Change; import com.google.gerrit.reviewdb.client.ChangeMessage; @@ -24,7 +25,6 @@ import com.google.gerrit.server.mail.send.DeleteReviewerSender; import com.google.gerrit.server.update.BatchUpdateOp; import com.google.gerrit.server.update.ChangeContext; import com.google.gerrit.server.update.Context; -import com.google.gwtorm.server.OrmException; import com.google.inject.Inject; import com.google.inject.assistedinject.Assisted; import java.util.Collections; @@ -50,7 +50,7 @@ public class DeleteReviewerByEmailOp implements BatchUpdateOp { } @Override - public boolean updateChange(ChangeContext ctx) throws OrmException { + public boolean updateChange(ChangeContext ctx) throws StorageException { change = ctx.getChange(); PatchSet.Id psId = ctx.getChange().currentPatchSetId(); String msg = "Removed reviewer " + reviewer; diff --git a/java/com/google/gerrit/server/change/DeleteReviewerOp.java b/java/com/google/gerrit/server/change/DeleteReviewerOp.java index 7b9c2cbe79..77a2afcd98 100644 --- a/java/com/google/gerrit/server/change/DeleteReviewerOp.java +++ b/java/com/google/gerrit/server/change/DeleteReviewerOp.java @@ -19,6 +19,7 @@ import com.google.common.flogger.FluentLogger; import com.google.gerrit.common.data.LabelType; import com.google.gerrit.common.data.LabelTypes; 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.NotifyHandling; import com.google.gerrit.extensions.restapi.AuthException; @@ -43,7 +44,6 @@ import com.google.gerrit.server.project.RemoveReviewerControl; import com.google.gerrit.server.update.BatchUpdateOp; import com.google.gerrit.server.update.ChangeContext; import com.google.gerrit.server.update.Context; -import com.google.gwtorm.server.OrmException; import com.google.inject.Inject; import com.google.inject.Provider; import com.google.inject.assistedinject.Assisted; @@ -108,7 +108,7 @@ public class DeleteReviewerOp implements BatchUpdateOp { @Override public boolean updateChange(ChangeContext ctx) - throws AuthException, ResourceNotFoundException, OrmException, PermissionBackendException, + throws AuthException, ResourceNotFoundException, StorageException, PermissionBackendException, IOException { Account.Id reviewerId = reviewer.getAccount().getId(); // Check of removing this reviewer (even if there is no vote processed by the loop below) is OK @@ -195,7 +195,7 @@ public class DeleteReviewerOp implements BatchUpdateOp { } private Iterable approvals(ChangeContext ctx, Account.Id accountId) - throws OrmException { + throws StorageException { Iterable approvals; approvals = approvalsUtil.byChange(ctx.getNotes()).values(); return Iterables.filter(approvals, psa -> accountId.equals(psa.getAccountId())); diff --git a/java/com/google/gerrit/server/change/LabelsJson.java b/java/com/google/gerrit/server/change/LabelsJson.java index 01ac37b94d..35607647d6 100644 --- a/java/com/google/gerrit/server/change/LabelsJson.java +++ b/java/com/google/gerrit/server/change/LabelsJson.java @@ -36,6 +36,7 @@ import com.google.gerrit.common.data.LabelType; import com.google.gerrit.common.data.LabelTypes; import com.google.gerrit.common.data.LabelValue; 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.common.ApprovalInfo; import com.google.gerrit.extensions.common.LabelInfo; @@ -51,7 +52,6 @@ import com.google.gerrit.server.permissions.LabelPermission; import com.google.gerrit.server.permissions.PermissionBackend; import com.google.gerrit.server.permissions.PermissionBackendException; import com.google.gerrit.server.query.change.ChangeData; -import com.google.gwtorm.server.OrmException; import com.google.inject.Inject; import com.google.inject.assistedinject.Assisted; import java.sql.Timestamp; @@ -100,7 +100,7 @@ public class LabelsJson { */ Map labelsFor( AccountLoader accountLoader, ChangeData cd, boolean standard, boolean detailed) - throws OrmException, PermissionBackendException { + throws StorageException, PermissionBackendException { if (!standard && !detailed) { return null; } @@ -115,7 +115,7 @@ public class LabelsJson { /** Returns all labels that the provided user has permission to vote on. */ Map> permittedLabels(Account.Id filterApprovalsBy, ChangeData cd) - throws OrmException, PermissionBackendException { + throws StorageException, PermissionBackendException { boolean isMerged = cd.change().isMerged(); LabelTypes labelTypes = cd.getLabelTypes(); Map toCheck = new HashMap<>(); @@ -194,7 +194,7 @@ public class LabelsJson { LabelTypes labelTypes, boolean standard, boolean detailed) - throws OrmException, PermissionBackendException { + throws StorageException, PermissionBackendException { Map labels = initLabels(accountLoader, cd, labelTypes, standard); if (detailed) { setAllApprovals(accountLoader, cd, labels); @@ -253,7 +253,7 @@ public class LabelsJson { } private Map currentLabels(Account.Id accountId, ChangeData cd) - throws OrmException { + throws StorageException { Map result = new HashMap<>(); for (PatchSetApproval psa : approvalsUtil.byPatchSetUser( @@ -273,7 +273,7 @@ public class LabelsJson { LabelTypes labelTypes, boolean standard, boolean detailed) - throws OrmException, PermissionBackendException { + throws StorageException, PermissionBackendException { Set allUsers = new HashSet<>(); if (detailed) { // Users expect to see all reviewers on closed changes, even if they @@ -431,7 +431,7 @@ public class LabelsJson { private void setAllApprovals( AccountLoader accountLoader, ChangeData cd, Map labels) - throws OrmException, PermissionBackendException { + throws StorageException, PermissionBackendException { checkState( !cd.change().isMerged(), "should not call setAllApprovals on %s change", @@ -500,7 +500,7 @@ public class LabelsJson { * lazyload}. */ private PermissionBackend.ForChange permissionBackendForChange(Account.Id user, ChangeData cd) - throws OrmException { + throws StorageException { PermissionBackend.WithUser withUser = permissionBackend.absentUser(user); return lazyLoad ? withUser.change(cd) diff --git a/java/com/google/gerrit/server/change/NotifyResolver.java b/java/com/google/gerrit/server/change/NotifyResolver.java index 65da083fce..8ff2c7a9fe 100644 --- a/java/com/google/gerrit/server/change/NotifyResolver.java +++ b/java/com/google/gerrit/server/change/NotifyResolver.java @@ -21,6 +21,7 @@ import com.google.auto.value.AutoValue; import com.google.common.collect.ImmutableList; import com.google.common.collect.ImmutableSetMultimap; 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.NotifyInfo; import com.google.gerrit.extensions.api.changes.RecipientType; @@ -28,7 +29,6 @@ import com.google.gerrit.extensions.restapi.BadRequestException; import com.google.gerrit.extensions.restapi.UnprocessableEntityException; import com.google.gerrit.reviewdb.client.Account; import com.google.gerrit.server.account.AccountResolver; -import com.google.gwtorm.server.OrmException; import com.google.inject.Inject; import com.google.inject.Singleton; import java.io.IOException; @@ -81,7 +81,7 @@ public class NotifyResolver { public Result resolve( NotifyHandling handling, @Nullable Map notifyDetails) - throws BadRequestException, OrmException, IOException, ConfigInvalidException { + throws BadRequestException, StorageException, IOException, ConfigInvalidException { requireNonNull(handling); ImmutableSetMultimap.Builder b = ImmutableSetMultimap.builder(); if (notifyDetails != null) { @@ -93,7 +93,7 @@ public class NotifyResolver { } private ImmutableList find(@Nullable List inputs) - throws OrmException, BadRequestException, IOException, ConfigInvalidException { + throws StorageException, BadRequestException, IOException, ConfigInvalidException { if (inputs == null || inputs.isEmpty()) { return ImmutableList.of(); } diff --git a/java/com/google/gerrit/server/change/PatchSetInserter.java b/java/com/google/gerrit/server/change/PatchSetInserter.java index 8f6b8f52ba..41522b2ccd 100644 --- a/java/com/google/gerrit/server/change/PatchSetInserter.java +++ b/java/com/google/gerrit/server/change/PatchSetInserter.java @@ -20,6 +20,7 @@ import static com.google.gerrit.server.notedb.ReviewerStateInternal.REVIEWER; import static java.util.Objects.requireNonNull; 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.restapi.AuthException; import com.google.gerrit.extensions.restapi.ResourceConflictException; @@ -49,7 +50,6 @@ import com.google.gerrit.server.update.BatchUpdateOp; import com.google.gerrit.server.update.ChangeContext; import com.google.gerrit.server.update.Context; import com.google.gerrit.server.update.RepoContext; -import com.google.gwtorm.server.OrmException; import com.google.inject.Inject; import com.google.inject.assistedinject.Assisted; import java.io.IOException; @@ -187,7 +187,7 @@ public class PatchSetInserter implements BatchUpdateOp { @Override public void updateRepo(RepoContext ctx) - throws AuthException, ResourceConflictException, IOException, OrmException, + throws AuthException, ResourceConflictException, IOException, StorageException, PermissionBackendException { validate(ctx); ctx.addRefUpdate(ObjectId.zeroId(), commitId, getPatchSetId().toRefName()); @@ -195,7 +195,7 @@ public class PatchSetInserter implements BatchUpdateOp { @Override public boolean updateChange(ChangeContext ctx) - throws ResourceConflictException, OrmException, IOException { + throws ResourceConflictException, StorageException, IOException { change = ctx.getChange(); ChangeUpdate update = ctx.getUpdate(psId); update.setSubjectForCommit("Create patch set " + psId.get()); @@ -272,7 +272,7 @@ public class PatchSetInserter implements BatchUpdateOp { private void validate(RepoContext ctx) throws AuthException, ResourceConflictException, IOException, PermissionBackendException, - OrmException { + StorageException { // Not allowed to create a new patch set if the current patch set is locked. psUtil.checkPatchSetNotLocked(origNotes); diff --git a/java/com/google/gerrit/server/change/PureRevert.java b/java/com/google/gerrit/server/change/PureRevert.java index e7fb67aa48..1b1a4f65e2 100644 --- a/java/com/google/gerrit/server/change/PureRevert.java +++ b/java/com/google/gerrit/server/change/PureRevert.java @@ -14,12 +14,12 @@ 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.ResourceConflictException; import com.google.gerrit.reviewdb.client.PatchSet; import com.google.gerrit.server.git.PureRevertCache; import com.google.gerrit.server.notedb.ChangeNotes; -import com.google.gwtorm.server.OrmException; import com.google.inject.Inject; import com.google.inject.Singleton; import java.io.IOException; @@ -38,7 +38,7 @@ public class PureRevert { } public boolean get(ChangeNotes notes, Optional claimedOriginal) - throws OrmException, IOException, BadRequestException, ResourceConflictException { + throws StorageException, IOException, BadRequestException, ResourceConflictException { PatchSet currentPatchSet = notes.getCurrentPatchSet(); if (currentPatchSet == null) { throw new ResourceConflictException("current revision is missing"); diff --git a/java/com/google/gerrit/server/change/RebaseChangeOp.java b/java/com/google/gerrit/server/change/RebaseChangeOp.java index e4f4cc3fe5..41f7758b00 100644 --- a/java/com/google/gerrit/server/change/RebaseChangeOp.java +++ b/java/com/google/gerrit/server/change/RebaseChangeOp.java @@ -16,6 +16,7 @@ package com.google.gerrit.server.change; 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.ResourceConflictException; import com.google.gerrit.extensions.restapi.RestApiException; @@ -37,7 +38,6 @@ import com.google.gerrit.server.update.BatchUpdateOp; import com.google.gerrit.server.update.ChangeContext; import com.google.gerrit.server.update.Context; import com.google.gerrit.server.update.RepoContext; -import com.google.gwtorm.server.OrmException; import com.google.inject.Inject; import com.google.inject.assistedinject.Assisted; import java.io.IOException; @@ -149,7 +149,7 @@ public class RebaseChangeOp implements BatchUpdateOp { @Override public void updateRepo(RepoContext ctx) throws MergeConflictException, InvalidChangeOperationException, RestApiException, IOException, - OrmException, NoSuchChangeException, PermissionBackendException { + StorageException, NoSuchChangeException, PermissionBackendException { // Ok that originalPatchSet was not read in a transaction, since we just // need its revision. RevId oldRev = originalPatchSet.getRevision(); @@ -214,14 +214,14 @@ public class RebaseChangeOp implements BatchUpdateOp { @Override public boolean updateChange(ChangeContext ctx) - throws ResourceConflictException, OrmException, IOException { + throws ResourceConflictException, StorageException, IOException { boolean ret = patchSetInserter.updateChange(ctx); rebasedPatchSet = patchSetInserter.getPatchSet(); return ret; } @Override - public void postUpdate(Context ctx) throws OrmException { + public void postUpdate(Context ctx) throws StorageException { patchSetInserter.postUpdate(ctx); } diff --git a/java/com/google/gerrit/server/change/RebaseUtil.java b/java/com/google/gerrit/server/change/RebaseUtil.java index db68898d51..c7dd4c29f9 100644 --- a/java/com/google/gerrit/server/change/RebaseUtil.java +++ b/java/com/google/gerrit/server/change/RebaseUtil.java @@ -17,6 +17,7 @@ package com.google.gerrit.server.change; import com.google.auto.value.AutoValue; import com.google.common.flogger.FluentLogger; import com.google.common.primitives.Ints; +import com.google.gerrit.exceptions.StorageException; import com.google.gerrit.extensions.restapi.ResourceConflictException; import com.google.gerrit.extensions.restapi.RestApiException; import com.google.gerrit.extensions.restapi.UnprocessableEntityException; @@ -28,7 +29,6 @@ import com.google.gerrit.server.PatchSetUtil; import com.google.gerrit.server.notedb.ChangeNotes; import com.google.gerrit.server.query.change.ChangeData; import com.google.gerrit.server.query.change.InternalChangeQuery; -import com.google.gwtorm.server.OrmException; import com.google.inject.Inject; import com.google.inject.Provider; import java.io.IOException; @@ -62,7 +62,7 @@ public class RebaseUtil { return true; } catch (RestApiException e) { return false; - } catch (OrmException | IOException e) { + } catch (StorageException | IOException e) { logger.atWarning().withCause(e).log( "Error checking if patch set %s on %s can be rebased", patchSet.getId(), dest); return false; @@ -83,7 +83,7 @@ public class RebaseUtil { public abstract PatchSet patchSet(); } - public Base parseBase(RevisionResource rsrc, String base) throws OrmException { + public Base parseBase(RevisionResource rsrc, String base) throws StorageException { // Try parsing the base as a ref string. PatchSet.Id basePatchSetId = PatchSet.Id.fromRef(base); if (basePatchSetId != null) { @@ -119,7 +119,7 @@ public class RebaseUtil { return ret; } - private ChangeNotes notesFor(RevisionResource rsrc, Change.Id id) throws OrmException { + private ChangeNotes notesFor(RevisionResource rsrc, Change.Id id) throws StorageException { if (rsrc.getChange().getId().equals(id)) { return rsrc.getNotes(); } @@ -139,11 +139,11 @@ public class RebaseUtil { * @return the commit onto which the patch set should be rebased. * @throws RestApiException if rebase is not possible. * @throws IOException if accessing the repository fails. - * @throws OrmException if accessing the database fails. + * @throws StorageException if accessing the database fails. */ public ObjectId findBaseRevision( PatchSet patchSet, Branch.NameKey destBranch, Repository git, RevWalk rw) - throws RestApiException, IOException, OrmException { + throws RestApiException, IOException, StorageException { String baseRev = null; RevCommit commit = rw.parseCommit(ObjectId.fromString(patchSet.getRevision().get())); diff --git a/java/com/google/gerrit/server/change/ReviewerAdder.java b/java/com/google/gerrit/server/change/ReviewerAdder.java index 21fc03c840..005638a49b 100644 --- a/java/com/google/gerrit/server/change/ReviewerAdder.java +++ b/java/com/google/gerrit/server/change/ReviewerAdder.java @@ -31,6 +31,7 @@ import com.google.common.collect.Streams; import com.google.common.flogger.FluentLogger; import com.google.gerrit.common.Nullable; 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.AddReviewerResult; import com.google.gerrit.extensions.api.changes.NotifyHandling; @@ -68,7 +69,6 @@ import com.google.gerrit.server.project.ProjectCache; import com.google.gerrit.server.query.change.ChangeData; import com.google.gerrit.server.update.ChangeContext; import com.google.gerrit.server.update.Context; -import com.google.gwtorm.server.OrmException; import com.google.inject.Inject; import com.google.inject.Provider; import java.io.IOException; @@ -188,14 +188,14 @@ public class ReviewerAdder { * @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 * contains information about an error that occurred - * @throws OrmException + * @throws StorageException * @throws IOException * @throws PermissionBackendException * @throws ConfigInvalidException */ public ReviewerAddition prepare( ChangeNotes notes, CurrentUser user, AddReviewerInput input, boolean allowGroup) - throws OrmException, IOException, PermissionBackendException, ConfigInvalidException { + throws StorageException, IOException, PermissionBackendException, ConfigInvalidException { requireNonNull(input.reviewer); boolean confirmed = input.confirmed(); boolean allowByEmail = @@ -245,7 +245,7 @@ public class ReviewerAdder { @Nullable private ReviewerAddition addByAccountId( AddReviewerInput input, ChangeNotes notes, CurrentUser user) - throws OrmException, PermissionBackendException, IOException, ConfigInvalidException { + throws StorageException, PermissionBackendException, IOException, ConfigInvalidException { IdentifiedUser reviewerUser; boolean exactMatchFound = false; try { @@ -449,7 +449,7 @@ public class ReviewerAdder { : ImmutableSet.of(); } - public void gatherResults(ChangeData cd) throws OrmException, PermissionBackendException { + public void gatherResults(ChangeData cd) throws StorageException, PermissionBackendException { checkState(op != null, "addition did not result in an update op"); checkState(op.getResult() != null, "op did not return a result"); @@ -510,7 +510,7 @@ public class ReviewerAdder { CurrentUser user, Iterable inputs, boolean allowGroup) - throws OrmException, IOException, PermissionBackendException, ConfigInvalidException { + throws StorageException, IOException, PermissionBackendException, ConfigInvalidException { // 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 // specifies the same string twice, or less obviously if they specify multiple groups with @@ -558,7 +558,7 @@ public class ReviewerAdder { // 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) - throws OrmException, RestApiException, IOException { + throws StorageException, RestApiException, IOException { for (ReviewerAddition addition : additions()) { addition.op.setPatchSet(patchSet); addition.op.updateChange(ctx); diff --git a/java/com/google/gerrit/server/change/ReviewerJson.java b/java/com/google/gerrit/server/change/ReviewerJson.java index fd5772d249..a15cee178b 100644 --- a/java/com/google/gerrit/server/change/ReviewerJson.java +++ b/java/com/google/gerrit/server/change/ReviewerJson.java @@ -21,6 +21,7 @@ import com.google.common.collect.Lists; import com.google.gerrit.common.data.LabelType; import com.google.gerrit.common.data.LabelTypes; 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.restapi.AuthException; import com.google.gerrit.mail.Address; @@ -35,7 +36,6 @@ import com.google.gerrit.server.permissions.PermissionBackendException; import com.google.gerrit.server.project.SubmitRuleEvaluator; import com.google.gerrit.server.project.SubmitRuleOptions; import com.google.gerrit.server.query.change.ChangeData; -import com.google.gwtorm.server.OrmException; import com.google.inject.Inject; import com.google.inject.Singleton; import java.util.Collection; @@ -65,7 +65,7 @@ public class ReviewerJson { } public List format(Collection rsrcs) - throws OrmException, PermissionBackendException { + throws StorageException, PermissionBackendException { List infos = Lists.newArrayListWithCapacity(rsrcs.size()); AccountLoader loader = accountLoaderFactory.create(true); ChangeData cd = null; @@ -89,12 +89,12 @@ public class ReviewerJson { } public List format(ReviewerResource rsrc) - throws OrmException, PermissionBackendException { + throws StorageException, PermissionBackendException { return format(ImmutableList.of(rsrc)); } public ReviewerInfo format(ReviewerInfo out, Account.Id reviewerAccountId, ChangeData cd) - throws OrmException, PermissionBackendException { + throws StorageException, PermissionBackendException { PatchSet.Id psId = cd.change().currentPatchSetId(); return format( out, @@ -108,7 +108,7 @@ public class ReviewerJson { Account.Id reviewerAccountId, ChangeData cd, Iterable approvals) - throws OrmException, PermissionBackendException { + throws StorageException, PermissionBackendException { LabelTypes labelTypes = cd.getLabelTypes(); out.approvals = new TreeMap<>(labelTypes.nameComparator()); diff --git a/java/com/google/gerrit/server/change/RevisionJson.java b/java/com/google/gerrit/server/change/RevisionJson.java index 42175eb559..5415a2b460 100644 --- a/java/com/google/gerrit/server/change/RevisionJson.java +++ b/java/com/google/gerrit/server/change/RevisionJson.java @@ -32,6 +32,7 @@ import com.google.common.collect.ImmutableSet; import com.google.common.collect.Sets; import com.google.common.flogger.FluentLogger; import com.google.gerrit.common.Nullable; +import com.google.gerrit.exceptions.StorageException; import com.google.gerrit.extensions.client.ListChangesOption; import com.google.gerrit.extensions.common.ChangeInfo; import com.google.gerrit.extensions.common.CommitInfo; @@ -65,7 +66,6 @@ import com.google.gerrit.server.permissions.PermissionBackendException; import com.google.gerrit.server.project.ProjectCache; import com.google.gerrit.server.project.ProjectState; import com.google.gerrit.server.query.change.ChangeData; -import com.google.gwtorm.server.OrmException; import com.google.inject.Inject; import com.google.inject.Provider; import com.google.inject.assistedinject.Assisted; @@ -155,7 +155,7 @@ public class RevisionJson { * depending on the options provided when constructing this instance. */ public RevisionInfo getRevisionInfo(ChangeData cd, PatchSet in) - throws PatchListNotAvailableException, GpgException, OrmException, IOException, + throws PatchListNotAvailableException, GpgException, StorageException, IOException, PermissionBackendException { AccountLoader accountLoader = accountLoaderFactory.create(has(DETAILED_ACCOUNTS)); try (Repository repo = openRepoIfNecessary(cd.project()); @@ -213,7 +213,7 @@ public class RevisionJson { Map map, Optional limitToPsId, ChangeInfo changeInfo) - throws PatchListNotAvailableException, GpgException, OrmException, IOException, + throws PatchListNotAvailableException, GpgException, StorageException, IOException, PermissionBackendException { Map res = new LinkedHashMap<>(); try (Repository repo = openRepoIfNecessary(cd.project()); @@ -239,7 +239,7 @@ public class RevisionJson { } private Map makeFetchMap(ChangeData cd, PatchSet in) - throws PermissionBackendException, OrmException, IOException { + throws PermissionBackendException, StorageException, IOException { Map r = new LinkedHashMap<>(); for (Extension e : downloadSchemes) { String schemeName = e.getExportName(); @@ -275,7 +275,7 @@ public class RevisionJson { @Nullable RevWalk rw, boolean fillCommit, @Nullable ChangeInfo changeInfo) - throws PatchListNotAvailableException, GpgException, OrmException, IOException, + throws PatchListNotAvailableException, GpgException, StorageException, IOException, PermissionBackendException { Change c = cd.change(); RevisionInfo out = new RevisionInfo(); @@ -350,14 +350,14 @@ public class RevisionJson { * lazyload}. */ private PermissionBackend.ForChange permissionBackendForChange( - PermissionBackend.WithUser withUser, ChangeData cd) throws OrmException { + PermissionBackend.WithUser withUser, ChangeData cd) throws StorageException { return lazyLoad ? withUser.change(cd) : withUser.indexedChange(cd, notesFactory.createFromIndexedChange(cd.change())); } private boolean isWorldReadable(ChangeData cd) - throws OrmException, PermissionBackendException, IOException { + throws StorageException, PermissionBackendException, IOException { try { permissionBackendForChange(permissionBackend.user(anonymous), cd) .check(ChangePermission.READ); diff --git a/java/com/google/gerrit/server/change/SetAssigneeOp.java b/java/com/google/gerrit/server/change/SetAssigneeOp.java index dd24ff663a..06109aeb42 100644 --- a/java/com/google/gerrit/server/change/SetAssigneeOp.java +++ b/java/com/google/gerrit/server/change/SetAssigneeOp.java @@ -17,6 +17,7 @@ package com.google.gerrit.server.change; import static java.util.Objects.requireNonNull; 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.RestApiException; import com.google.gerrit.reviewdb.client.Change; @@ -32,7 +33,6 @@ import com.google.gerrit.server.update.ChangeContext; import com.google.gerrit.server.update.Context; import com.google.gerrit.server.validators.AssigneeValidationListener; import com.google.gerrit.server.validators.ValidationException; -import com.google.gwtorm.server.OrmException; import com.google.inject.Inject; import com.google.inject.Provider; import com.google.inject.assistedinject.Assisted; @@ -74,7 +74,7 @@ public class SetAssigneeOp implements BatchUpdateOp { } @Override - public boolean updateChange(ChangeContext ctx) throws OrmException, RestApiException { + public boolean updateChange(ChangeContext ctx) throws StorageException, RestApiException { change = ctx.getChange(); if (newAssignee.getAccountId().equals(change.getAssignee())) { return false; @@ -117,7 +117,7 @@ public class SetAssigneeOp implements BatchUpdateOp { } @Override - public void postUpdate(Context ctx) throws OrmException { + public void postUpdate(Context ctx) throws StorageException { try { SetAssigneeSender cm = setAssigneeSenderFactory.create( diff --git a/java/com/google/gerrit/server/change/SetHashtagsOp.java b/java/com/google/gerrit/server/change/SetHashtagsOp.java index 4f730538d5..0f8601cb54 100644 --- a/java/com/google/gerrit/server/change/SetHashtagsOp.java +++ b/java/com/google/gerrit/server/change/SetHashtagsOp.java @@ -21,6 +21,7 @@ import com.google.common.base.Joiner; import com.google.common.collect.ImmutableSortedSet; import com.google.common.collect.Ordering; 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.restapi.AuthException; import com.google.gerrit.extensions.restapi.BadRequestException; @@ -38,7 +39,6 @@ import com.google.gerrit.server.update.ChangeContext; import com.google.gerrit.server.update.Context; import com.google.gerrit.server.validators.HashtagValidationListener; import com.google.gerrit.server.validators.ValidationException; -import com.google.gwtorm.server.OrmException; import com.google.inject.Inject; import com.google.inject.assistedinject.Assisted; import java.io.IOException; @@ -82,7 +82,7 @@ public class SetHashtagsOp implements BatchUpdateOp { @Override public boolean updateChange(ChangeContext ctx) - throws AuthException, BadRequestException, MethodNotAllowedException, OrmException, + throws AuthException, BadRequestException, MethodNotAllowedException, StorageException, IOException { if (input == null || (input.add == null && input.remove == null)) { updatedHashtags = ImmutableSortedSet.of(); @@ -146,7 +146,7 @@ public class SetHashtagsOp implements BatchUpdateOp { } @Override - public void postUpdate(Context ctx) throws OrmException { + public void postUpdate(Context ctx) throws StorageException { if (updated() && fireEvent) { hashtagsEdited.fire( change, ctx.getAccount(), updatedHashtags, toAdd, toRemove, ctx.getWhen()); diff --git a/java/com/google/gerrit/server/change/SetPrivateOp.java b/java/com/google/gerrit/server/change/SetPrivateOp.java index 017dbecc97..d10283a087 100644 --- a/java/com/google/gerrit/server/change/SetPrivateOp.java +++ b/java/com/google/gerrit/server/change/SetPrivateOp.java @@ -16,6 +16,7 @@ package com.google.gerrit.server.change; import com.google.common.base.Strings; 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.ResourceConflictException; import com.google.gerrit.reviewdb.client.Change; @@ -30,7 +31,6 @@ import com.google.gerrit.server.notedb.ChangeUpdate; import com.google.gerrit.server.update.BatchUpdateOp; import com.google.gerrit.server.update.ChangeContext; import com.google.gerrit.server.update.Context; -import com.google.gwtorm.server.OrmException; import com.google.inject.Inject; import com.google.inject.assistedinject.Assisted; @@ -75,7 +75,7 @@ public class SetPrivateOp implements BatchUpdateOp { @Override public boolean updateChange(ChangeContext ctx) - throws ResourceConflictException, OrmException, BadRequestException { + throws ResourceConflictException, StorageException, BadRequestException { change = ctx.getChange(); if (ctx.getChange().isPrivate() == isPrivate) { // No-op diff --git a/java/com/google/gerrit/server/change/WalkSorter.java b/java/com/google/gerrit/server/change/WalkSorter.java index 916a62bb36..c52def7da7 100644 --- a/java/com/google/gerrit/server/change/WalkSorter.java +++ b/java/com/google/gerrit/server/change/WalkSorter.java @@ -24,11 +24,11 @@ import com.google.common.collect.ListMultimap; import com.google.common.collect.MultimapBuilder; import com.google.common.collect.Ordering; 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.Project; import com.google.gerrit.server.git.GitRepositoryManager; import com.google.gerrit.server.query.change.ChangeData; -import com.google.gwtorm.server.OrmException; import com.google.inject.Inject; import java.io.IOException; import java.util.ArrayDeque; @@ -73,7 +73,7 @@ public class WalkSorter { } try { return in.get(0).data().change().getProject(); - } catch (OrmException e) { + } catch (StorageException e) { throw new IllegalStateException(e); } }); @@ -98,7 +98,7 @@ public class WalkSorter { return this; } - public Iterable sort(Iterable in) throws OrmException, IOException { + public Iterable sort(Iterable in) throws StorageException, IOException { ListMultimap byProject = MultimapBuilder.hashKeys().arrayListValues().build(); for (ChangeData cd : in) { @@ -114,7 +114,7 @@ public class WalkSorter { } private List sortProject(Project.NameKey project, Collection in) - throws OrmException, IOException { + throws StorageException, IOException { try (Repository repo = repoManager.openRepository(project); RevWalk rw = new RevWalk(repo)) { rw.setRetainBody(retainBody); @@ -217,7 +217,7 @@ public class WalkSorter { } private ListMultimap byCommit(RevWalk rw, Collection in) - throws OrmException, IOException { + throws StorageException, IOException { ListMultimap byCommit = MultimapBuilder.hashKeys(in.size()).arrayListValues(1).build(); for (ChangeData cd : in) { diff --git a/java/com/google/gerrit/server/change/WorkInProgressOp.java b/java/com/google/gerrit/server/change/WorkInProgressOp.java index e5fdd8f87e..6b9ee8cae6 100644 --- a/java/com/google/gerrit/server/change/WorkInProgressOp.java +++ b/java/com/google/gerrit/server/change/WorkInProgressOp.java @@ -17,6 +17,7 @@ package com.google.gerrit.server.change; import com.google.common.base.Strings; import com.google.common.collect.ImmutableList; import com.google.gerrit.common.Nullable; +import com.google.gerrit.exceptions.StorageException; import com.google.gerrit.extensions.api.changes.NotifyHandling; import com.google.gerrit.reviewdb.client.Change; import com.google.gerrit.reviewdb.client.ChangeMessage; @@ -29,7 +30,6 @@ import com.google.gerrit.server.notedb.ChangeUpdate; import com.google.gerrit.server.update.BatchUpdateOp; import com.google.gerrit.server.update.ChangeContext; import com.google.gerrit.server.update.Context; -import com.google.gwtorm.server.OrmException; import com.google.inject.Inject; import com.google.inject.assistedinject.Assisted; @@ -85,7 +85,7 @@ public class WorkInProgressOp implements BatchUpdateOp { } @Override - public boolean updateChange(ChangeContext ctx) throws OrmException { + public boolean updateChange(ChangeContext ctx) throws StorageException { change = ctx.getChange(); notes = ctx.getNotes(); ps = psUtil.get(ctx.getNotes(), change.currentPatchSetId()); diff --git a/java/com/google/gerrit/server/edit/ChangeEditModifier.java b/java/com/google/gerrit/server/edit/ChangeEditModifier.java index 96988672d4..d63aa8b677 100644 --- a/java/com/google/gerrit/server/edit/ChangeEditModifier.java +++ b/java/com/google/gerrit/server/edit/ChangeEditModifier.java @@ -15,6 +15,7 @@ package com.google.gerrit.server.edit; 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.BadRequestException; import com.google.gerrit.extensions.restapi.MergeConflictException; @@ -43,7 +44,6 @@ import com.google.gerrit.server.project.InvalidChangeOperationException; import com.google.gerrit.server.project.ProjectCache; import com.google.gerrit.server.util.CommitMessageUtil; import com.google.gerrit.server.util.time.TimeUtil; -import com.google.gwtorm.server.OrmException; import com.google.inject.Inject; import com.google.inject.Provider; import com.google.inject.Singleton; @@ -114,7 +114,7 @@ public class ChangeEditModifier { * @throws PermissionBackendException */ public void createEdit(Repository repository, ChangeNotes notes) - throws AuthException, IOException, InvalidChangeOperationException, OrmException, + throws AuthException, IOException, InvalidChangeOperationException, StorageException, PermissionBackendException, ResourceConflictException { assertCanEdit(notes); @@ -142,7 +142,7 @@ public class ChangeEditModifier { * @throws PermissionBackendException */ public void rebaseEdit(Repository repository, ChangeNotes notes) - throws AuthException, InvalidChangeOperationException, IOException, OrmException, + throws AuthException, InvalidChangeOperationException, IOException, StorageException, MergeConflictException, PermissionBackendException, ResourceConflictException { assertCanEdit(notes); @@ -207,7 +207,7 @@ public class ChangeEditModifier { * @throws BadRequestException if the commit message is malformed */ public void modifyMessage(Repository repository, ChangeNotes notes, String newCommitMessage) - throws AuthException, IOException, UnchangedCommitMessageException, OrmException, + throws AuthException, IOException, UnchangedCommitMessageException, StorageException, PermissionBackendException, BadRequestException, ResourceConflictException { assertCanEdit(notes); newCommitMessage = CommitMessageUtil.checkAndSanitizeCommitMessage(newCommitMessage); @@ -250,7 +250,7 @@ public class ChangeEditModifier { */ public void modifyFile( Repository repository, ChangeNotes notes, String filePath, RawInput newContent) - throws AuthException, InvalidChangeOperationException, IOException, OrmException, + throws AuthException, InvalidChangeOperationException, IOException, StorageException, PermissionBackendException, ResourceConflictException { modifyTree(repository, notes, new ChangeFileContentModification(filePath, newContent)); } @@ -268,7 +268,7 @@ public class ChangeEditModifier { * @throws ResourceConflictException if the project state does not permit the operation */ public void deleteFile(Repository repository, ChangeNotes notes, String file) - throws AuthException, InvalidChangeOperationException, IOException, OrmException, + throws AuthException, InvalidChangeOperationException, IOException, StorageException, PermissionBackendException, ResourceConflictException { modifyTree(repository, notes, new DeleteFileModification(file)); } @@ -289,7 +289,7 @@ public class ChangeEditModifier { */ public void renameFile( Repository repository, ChangeNotes notes, String currentFilePath, String newFilePath) - throws AuthException, InvalidChangeOperationException, IOException, OrmException, + throws AuthException, InvalidChangeOperationException, IOException, StorageException, PermissionBackendException, ResourceConflictException { modifyTree(repository, notes, new RenameFileModification(currentFilePath, newFilePath)); } @@ -307,14 +307,14 @@ public class ChangeEditModifier { * @throws PermissionBackendException */ public void restoreFile(Repository repository, ChangeNotes notes, String file) - throws AuthException, InvalidChangeOperationException, IOException, OrmException, + throws AuthException, InvalidChangeOperationException, IOException, StorageException, PermissionBackendException, ResourceConflictException { modifyTree(repository, notes, new RestoreFileModification(file)); } private void modifyTree( Repository repository, ChangeNotes notes, TreeModification treeModification) - throws AuthException, IOException, OrmException, InvalidChangeOperationException, + throws AuthException, IOException, StorageException, InvalidChangeOperationException, PermissionBackendException, ResourceConflictException { assertCanEdit(notes); @@ -360,7 +360,7 @@ public class ChangeEditModifier { PatchSet patchSet, List treeModifications) throws AuthException, IOException, InvalidChangeOperationException, MergeConflictException, - OrmException, PermissionBackendException, ResourceConflictException { + StorageException, PermissionBackendException, ResourceConflictException { assertCanEdit(notes); Optional optionalChangeEdit = lookupChangeEdit(notes); @@ -392,7 +392,7 @@ public class ChangeEditModifier { private void assertCanEdit(ChangeNotes notes) throws AuthException, PermissionBackendException, IOException, ResourceConflictException, - OrmException { + StorageException { if (!currentUser.get().isIdentifiedUser()) { throw new AuthException("Authentication required"); } @@ -443,12 +443,12 @@ public class ChangeEditModifier { } private PatchSet getBasePatchSet(Optional optionalChangeEdit, ChangeNotes notes) - throws OrmException { + throws StorageException { Optional editBasePatchSet = optionalChangeEdit.map(ChangeEdit::getBasePatchSet); return editBasePatchSet.isPresent() ? editBasePatchSet.get() : lookupCurrentPatchSet(notes); } - private PatchSet lookupCurrentPatchSet(ChangeNotes notes) throws OrmException { + private PatchSet lookupCurrentPatchSet(ChangeNotes notes) throws StorageException { return patchSetUtil.current(notes); } diff --git a/java/com/google/gerrit/server/edit/ChangeEditUtil.java b/java/com/google/gerrit/server/edit/ChangeEditUtil.java index 898f42703c..42c163e01b 100644 --- a/java/com/google/gerrit/server/edit/ChangeEditUtil.java +++ b/java/com/google/gerrit/server/edit/ChangeEditUtil.java @@ -16,6 +16,7 @@ package com.google.gerrit.server.edit; import static com.google.common.base.Preconditions.checkArgument; +import com.google.gerrit.exceptions.StorageException; import com.google.gerrit.extensions.client.ChangeKind; import com.google.gerrit.extensions.restapi.AuthException; import com.google.gerrit.extensions.restapi.ResourceConflictException; @@ -38,7 +39,6 @@ import com.google.gerrit.server.update.BatchUpdateOp; import com.google.gerrit.server.update.RepoContext; import com.google.gerrit.server.update.UpdateException; import com.google.gerrit.server.util.time.TimeUtil; -import com.google.gwtorm.server.OrmException; import com.google.inject.Inject; import com.google.inject.Provider; import com.google.inject.Singleton; @@ -146,7 +146,7 @@ public class ChangeEditUtil { * @param notify Notify handling that defines to whom email notifications should be sent after the * change edit is published. * @throws IOException - * @throws OrmException + * @throws StorageException * @throws UpdateException * @throws RestApiException */ @@ -156,7 +156,7 @@ public class ChangeEditUtil { CurrentUser user, ChangeEdit edit, NotifyResolver.Result notify) - throws IOException, OrmException, RestApiException, UpdateException { + throws IOException, StorageException, RestApiException, UpdateException { Change change = edit.getChange(); try (Repository repo = gitManager.openRepository(change.getProject()); ObjectInserter oi = repo.newObjectInserter(); @@ -210,9 +210,9 @@ public class ChangeEditUtil { * * @param edit change edit to delete * @throws IOException - * @throws OrmException + * @throws StorageException */ - public void delete(ChangeEdit edit) throws IOException, OrmException { + public void delete(ChangeEdit edit) throws IOException, StorageException { Change change = edit.getChange(); try (Repository repo = gitManager.openRepository(change.getProject())) { deleteRef(repo, edit); @@ -226,7 +226,7 @@ public class ChangeEditUtil { checkArgument(pos > 0, "invalid edit ref: %s", ref.getName()); String psId = ref.getName().substring(pos + 1); return psUtil.get(notes, new PatchSet.Id(notes.getChange().getId(), Integer.parseInt(psId))); - } catch (OrmException | NumberFormatException e) { + } catch (StorageException | NumberFormatException e) { throw new IOException(e); } } diff --git a/java/com/google/gerrit/server/events/EventBroker.java b/java/com/google/gerrit/server/events/EventBroker.java index 03b5d5484b..8038c9488f 100644 --- a/java/com/google/gerrit/server/events/EventBroker.java +++ b/java/com/google/gerrit/server/events/EventBroker.java @@ -15,6 +15,7 @@ package com.google.gerrit.server.events; import com.google.common.flogger.FluentLogger; +import com.google.gerrit.exceptions.StorageException; import com.google.gerrit.extensions.registration.DynamicItem; import com.google.gerrit.extensions.restapi.AuthException; import com.google.gerrit.lifecycle.LifecycleModule; @@ -34,7 +35,6 @@ import com.google.gerrit.server.plugincontext.PluginSetEntryContext; import com.google.gerrit.server.project.NoSuchChangeException; import com.google.gerrit.server.project.ProjectCache; import com.google.gerrit.server.project.ProjectState; -import com.google.gwtorm.server.OrmException; import com.google.inject.Inject; import com.google.inject.Singleton; @@ -78,7 +78,7 @@ public class EventBroker implements EventDispatcher { @Override public void postEvent(Change change, ChangeEvent event) - throws OrmException, PermissionBackendException { + throws StorageException, PermissionBackendException { fireEvent(change, event); } @@ -94,7 +94,7 @@ public class EventBroker implements EventDispatcher { } @Override - public void postEvent(Event event) throws OrmException, PermissionBackendException { + public void postEvent(Event event) throws StorageException, PermissionBackendException { fireEvent(event); } @@ -103,7 +103,7 @@ public class EventBroker implements EventDispatcher { } protected void fireEvent(Change change, ChangeEvent event) - throws OrmException, PermissionBackendException { + throws StorageException, PermissionBackendException { for (PluginSetEntryContext c : listeners) { CurrentUser user = c.call(UserScopedEventListener::getUser); if (isVisibleTo(change, user)) { @@ -134,7 +134,7 @@ public class EventBroker implements EventDispatcher { fireEventForUnrestrictedListeners(event); } - protected void fireEvent(Event event) throws OrmException, PermissionBackendException { + protected void fireEvent(Event event) throws StorageException, PermissionBackendException { for (PluginSetEntryContext c : listeners) { CurrentUser user = c.call(UserScopedEventListener::getUser); if (isVisibleTo(event, user)) { @@ -159,7 +159,7 @@ public class EventBroker implements EventDispatcher { } protected boolean isVisibleTo(Change change, CurrentUser user) - throws OrmException, PermissionBackendException { + throws StorageException, PermissionBackendException { if (change == null) { return false; } @@ -194,7 +194,7 @@ public class EventBroker implements EventDispatcher { } protected boolean isVisibleTo(Event event, CurrentUser user) - throws OrmException, PermissionBackendException { + throws StorageException, PermissionBackendException { if (event instanceof RefEvent) { RefEvent refEvent = (RefEvent) event; String ref = refEvent.getRefName(); diff --git a/java/com/google/gerrit/server/events/EventDispatcher.java b/java/com/google/gerrit/server/events/EventDispatcher.java index cbf547e939..ec0b0ec917 100644 --- a/java/com/google/gerrit/server/events/EventDispatcher.java +++ b/java/com/google/gerrit/server/events/EventDispatcher.java @@ -14,11 +14,11 @@ 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.Change; import com.google.gerrit.reviewdb.client.Project; import com.google.gerrit.server.permissions.PermissionBackendException; -import com.google.gwtorm.server.OrmException; /** Interface for posting (dispatching) Events */ public interface EventDispatcher { @@ -27,10 +27,11 @@ public interface EventDispatcher { * * @param change The change that the event is related to * @param event The event to post - * @throws OrmException on failure to post the event due to DB error + * @throws StorageException on failure to post the event due to DB error * @throws PermissionBackendException on failure of permission checks */ - void postEvent(Change change, ChangeEvent event) throws OrmException, PermissionBackendException; + void postEvent(Change change, ChangeEvent event) + throws StorageException, PermissionBackendException; /** * Post a stream event that is related to a branch @@ -56,8 +57,8 @@ public interface EventDispatcher { * specific postEvent methods for those use cases. * * @param event The event to post. - * @throws OrmException on failure to post the event due to DB error + * @throws StorageException on failure to post the event due to DB error * @throws PermissionBackendException on failure of permission checks */ - void postEvent(Event event) throws OrmException, PermissionBackendException; + void postEvent(Event event) throws StorageException, PermissionBackendException; } diff --git a/java/com/google/gerrit/server/events/EventFactory.java b/java/com/google/gerrit/server/events/EventFactory.java index 7904b285b0..9412476faf 100644 --- a/java/com/google/gerrit/server/events/EventFactory.java +++ b/java/com/google/gerrit/server/events/EventFactory.java @@ -24,6 +24,7 @@ import com.google.gerrit.common.data.LabelType; import com.google.gerrit.common.data.LabelTypes; import com.google.gerrit.common.data.SubmitRecord; import com.google.gerrit.common.data.SubmitRequirement; +import com.google.gerrit.exceptions.StorageException; import com.google.gerrit.extensions.registration.DynamicItem; import com.google.gerrit.index.IndexConfig; import com.google.gerrit.reviewdb.client.Account; @@ -63,7 +64,6 @@ import com.google.gerrit.server.patch.PatchListNotAvailableException; import com.google.gerrit.server.patch.PatchListObjectTooLargeException; import com.google.gerrit.server.query.change.ChangeData; import com.google.gerrit.server.query.change.InternalChangeQuery; -import com.google.gwtorm.server.OrmException; import com.google.inject.Inject; import com.google.inject.Provider; import com.google.inject.Singleton; @@ -155,7 +155,8 @@ public class EventFactory { * @param notes * @return object suitable for serialization to JSON */ - public ChangeAttribute asChangeAttribute(Change change, ChangeNotes notes) throws OrmException { + public ChangeAttribute asChangeAttribute(Change change, ChangeNotes notes) + throws StorageException { ChangeAttribute a = asChangeAttribute(change); Set hashtags = notes.load().getHashtags(); if (!hashtags.isEmpty()) { @@ -200,7 +201,7 @@ public class EventFactory { * @param a * @param notes */ - public void addAllReviewers(ChangeAttribute a, ChangeNotes notes) throws OrmException { + public void addAllReviewers(ChangeAttribute a, ChangeNotes notes) throws StorageException { Collection reviewers = approvalsUtil.getReviewers(notes).all(); if (!reviewers.isEmpty()) { a.allReviewers = Lists.newArrayListWithCapacity(reviewers.size()); @@ -271,7 +272,7 @@ public class EventFactory { try { addDependsOn(rw, ca, change, currentPs); addNeededBy(rw, ca, change, currentPs); - } catch (OrmException | IOException e) { + } catch (StorageException | IOException e) { // Squash DB exceptions and leave dependency lists partially filled. } // Remove empty lists so a confusing label won't be displayed in the output. @@ -284,7 +285,7 @@ public class EventFactory { } private void addDependsOn(RevWalk rw, ChangeAttribute ca, Change change, PatchSet currentPs) - throws OrmException, IOException { + throws StorageException, IOException { RevCommit commit = rw.parseCommit(ObjectId.fromString(currentPs.getRevision().get())); final List parentNames = new ArrayList<>(commit.getParentCount()); for (RevCommit p : commit.getParents()) { @@ -317,7 +318,7 @@ public class EventFactory { } private void addNeededBy(RevWalk rw, ChangeAttribute ca, Change change, PatchSet currentPs) - throws OrmException, IOException { + throws StorageException, IOException { if (currentPs.getGroups().isEmpty()) { return; } @@ -494,7 +495,7 @@ public class EventFactory { } } p.kind = changeKindCache.getChangeKind(change, patchSet); - } catch (IOException | OrmException e) { + } catch (IOException | StorageException e) { logger.atSevere().withCause(e).log("Cannot load patch set data for %s", patchSet.getId()); } catch (PatchListObjectTooLargeException e) { logger.atWarning().log("Cannot get size information for %s: %s", pId, e.getMessage()); @@ -506,7 +507,7 @@ public class EventFactory { // TODO: The same method exists in PatchSetInfoFactory, find a common place // for it - private UserIdentity toUserIdentity(PersonIdent who) throws IOException, OrmException { + private UserIdentity toUserIdentity(PersonIdent who) throws IOException, StorageException { UserIdentity u = new UserIdentity(); u.setName(who.getName()); u.setEmail(who.getEmailAddress()); diff --git a/java/com/google/gerrit/server/events/StreamEventsApiListener.java b/java/com/google/gerrit/server/events/StreamEventsApiListener.java index 750b579099..bcb22dc9bd 100644 --- a/java/com/google/gerrit/server/events/StreamEventsApiListener.java +++ b/java/com/google/gerrit/server/events/StreamEventsApiListener.java @@ -20,6 +20,7 @@ import com.google.common.collect.Sets; import com.google.common.flogger.FluentLogger; import com.google.gerrit.common.data.LabelType; import com.google.gerrit.common.data.LabelTypes; +import com.google.gerrit.exceptions.StorageException; import com.google.gerrit.extensions.common.AccountInfo; import com.google.gerrit.extensions.common.ApprovalInfo; import com.google.gerrit.extensions.common.ChangeInfo; @@ -55,7 +56,6 @@ import com.google.gerrit.server.notedb.ChangeNotes; import com.google.gerrit.server.plugincontext.PluginItemContext; import com.google.gerrit.server.project.NoSuchChangeException; import com.google.gerrit.server.project.ProjectCache; -import com.google.gwtorm.server.OrmException; import com.google.inject.AbstractModule; import com.google.inject.Inject; import com.google.inject.Singleton; @@ -135,15 +135,15 @@ public class StreamEventsApiListener this.changeNotesFactory = changeNotesFactory; } - private ChangeNotes getNotes(ChangeInfo info) throws OrmException { + private ChangeNotes getNotes(ChangeInfo info) throws StorageException { try { return changeNotesFactory.createChecked(new Change.Id(info._number)); } catch (NoSuchChangeException e) { - throw new OrmException(e); + throw new StorageException(e); } } - private PatchSet getPatchSet(ChangeNotes notes, RevisionInfo info) throws OrmException { + private PatchSet getPatchSet(ChangeNotes notes, RevisionInfo info) throws StorageException { return psUtil.get(notes, PatchSet.Id.fromRef(info.ref)); } @@ -152,7 +152,7 @@ public class StreamEventsApiListener () -> { try { return eventFactory.asChangeAttribute(change, notes); - } catch (OrmException e) { + } catch (StorageException e) { throw new RuntimeException(e); } }); @@ -248,7 +248,7 @@ public class StreamEventsApiListener event.oldAssignee = accountAttributeSupplier(ev.getOldAssignee()); dispatcher.run(d -> d.postEvent(change, event)); - } catch (OrmException e) { + } catch (StorageException e) { logger.atSevere().withCause(e).log("Failed to dispatch event"); } } @@ -265,7 +265,7 @@ public class StreamEventsApiListener event.oldTopic = ev.getOldTopic(); dispatcher.run(d -> d.postEvent(change, event)); - } catch (OrmException e) { + } catch (StorageException e) { logger.atSevere().withCause(e).log("Failed to dispatch event"); } } @@ -283,7 +283,7 @@ public class StreamEventsApiListener event.uploader = accountAttributeSupplier(ev.getWho()); dispatcher.run(d -> d.postEvent(change, event)); - } catch (OrmException e) { + } catch (StorageException e) { logger.atSevere().withCause(e).log("Failed to dispatch event"); } } @@ -303,7 +303,7 @@ public class StreamEventsApiListener approvalsAttributeSupplier(change, ev.getNewApprovals(), ev.getOldApprovals()); dispatcher.run(d -> d.postEvent(change, event)); - } catch (OrmException e) { + } catch (StorageException e) { logger.atSevere().withCause(e).log("Failed to dispatch event"); } } @@ -321,7 +321,7 @@ public class StreamEventsApiListener event.reviewer = accountAttributeSupplier(reviewer); dispatcher.run(d -> d.postEvent(event)); } - } catch (OrmException e) { + } catch (StorageException e) { logger.atSevere().withCause(e).log("Failed to dispatch event"); } } @@ -349,7 +349,7 @@ public class StreamEventsApiListener event.removed = hashtagArray(ev.getRemovedHashtags()); dispatcher.run(d -> d.postEvent(change, event)); - } catch (OrmException e) { + } catch (StorageException e) { logger.atSevere().withCause(e).log("Failed to dispatch event"); } } @@ -386,7 +386,7 @@ public class StreamEventsApiListener event.approvals = approvalsAttributeSupplier(change, ev.getApprovals(), ev.getOldApprovals()); dispatcher.run(d -> d.postEvent(change, event)); - } catch (OrmException e) { + } catch (StorageException e) { logger.atSevere().withCause(e).log("Failed to dispatch event"); } } @@ -404,7 +404,7 @@ public class StreamEventsApiListener event.reason = ev.getReason(); dispatcher.run(d -> d.postEvent(change, event)); - } catch (OrmException e) { + } catch (StorageException e) { logger.atSevere().withCause(e).log("Failed to dispatch event"); } } @@ -422,7 +422,7 @@ public class StreamEventsApiListener event.newRev = ev.getNewRevisionId(); dispatcher.run(d -> d.postEvent(change, event)); - } catch (OrmException e) { + } catch (StorageException e) { logger.atSevere().withCause(e).log("Failed to dispatch event"); } } @@ -440,7 +440,7 @@ public class StreamEventsApiListener event.reason = ev.getReason(); dispatcher.run(d -> d.postEvent(change, event)); - } catch (OrmException e) { + } catch (StorageException e) { logger.atSevere().withCause(e).log("Failed to dispatch event"); } } @@ -458,7 +458,7 @@ public class StreamEventsApiListener event.patchSet = patchSetAttributeSupplier(change, patchSet); dispatcher.run(d -> d.postEvent(change, event)); - } catch (OrmException e) { + } catch (StorageException e) { logger.atSevere().withCause(e).log("Failed to dispatch event"); } } @@ -476,7 +476,7 @@ public class StreamEventsApiListener event.patchSet = patchSetAttributeSupplier(change, patchSet); dispatcher.run(d -> d.postEvent(change, event)); - } catch (OrmException e) { + } catch (StorageException e) { logger.atSevere().withCause(e).log("Failed to dispatch event"); } } @@ -496,7 +496,7 @@ public class StreamEventsApiListener event.approvals = approvalsAttributeSupplier(change, ev.getApprovals(), ev.getOldApprovals()); dispatcher.run(d -> d.postEvent(change, event)); - } catch (OrmException e) { + } catch (StorageException e) { logger.atSevere().withCause(e).log("Failed to dispatch event"); } } @@ -512,7 +512,7 @@ public class StreamEventsApiListener event.deleter = accountAttributeSupplier(ev.getWho()); dispatcher.run(d -> d.postEvent(change, event)); - } catch (OrmException e) { + } catch (StorageException e) { logger.atSevere().withCause(e).log("Failed to dispatch event"); } } diff --git a/java/com/google/gerrit/server/extensions/events/AssigneeChanged.java b/java/com/google/gerrit/server/extensions/events/AssigneeChanged.java index 513a5dee06..fdce1da8f6 100644 --- a/java/com/google/gerrit/server/extensions/events/AssigneeChanged.java +++ b/java/com/google/gerrit/server/extensions/events/AssigneeChanged.java @@ -15,6 +15,7 @@ package com.google.gerrit.server.extensions.events; 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.common.AccountInfo; import com.google.gerrit.extensions.common.ChangeInfo; @@ -22,7 +23,6 @@ import com.google.gerrit.extensions.events.AssigneeChangedListener; import com.google.gerrit.reviewdb.client.Change; import com.google.gerrit.server.account.AccountState; import com.google.gerrit.server.plugincontext.PluginSetContext; -import com.google.gwtorm.server.OrmException; import com.google.inject.Inject; import com.google.inject.Singleton; import java.sql.Timestamp; @@ -53,7 +53,7 @@ public class AssigneeChanged { util.accountInfo(oldAssignee), when); listeners.runEach(l -> l.onAssigneeChanged(event)); - } catch (OrmException e) { + } catch (StorageException e) { logger.atSevere().withCause(e).log("Couldn't fire event"); } } diff --git a/java/com/google/gerrit/server/extensions/events/ChangeAbandoned.java b/java/com/google/gerrit/server/extensions/events/ChangeAbandoned.java index 3d6700e5a1..a8c08b991f 100644 --- a/java/com/google/gerrit/server/extensions/events/ChangeAbandoned.java +++ b/java/com/google/gerrit/server/extensions/events/ChangeAbandoned.java @@ -15,6 +15,7 @@ package com.google.gerrit.server.extensions.events; 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.common.AccountInfo; import com.google.gerrit.extensions.common.ChangeInfo; @@ -28,7 +29,6 @@ import com.google.gerrit.server.patch.PatchListNotAvailableException; import com.google.gerrit.server.patch.PatchListObjectTooLargeException; import com.google.gerrit.server.permissions.PermissionBackendException; import com.google.gerrit.server.plugincontext.PluginSetContext; -import com.google.gwtorm.server.OrmException; import com.google.inject.Inject; import com.google.inject.Singleton; import java.io.IOException; @@ -72,7 +72,7 @@ public class ChangeAbandoned { } catch (PatchListNotAvailableException | GpgException | IOException - | OrmException + | StorageException | PermissionBackendException e) { logger.atSevere().withCause(e).log("Couldn't fire event"); } diff --git a/java/com/google/gerrit/server/extensions/events/ChangeDeleted.java b/java/com/google/gerrit/server/extensions/events/ChangeDeleted.java index d9eb9f98b6..9e3e979196 100644 --- a/java/com/google/gerrit/server/extensions/events/ChangeDeleted.java +++ b/java/com/google/gerrit/server/extensions/events/ChangeDeleted.java @@ -15,6 +15,7 @@ package com.google.gerrit.server.extensions.events; 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.common.AccountInfo; import com.google.gerrit.extensions.common.ChangeInfo; @@ -22,7 +23,6 @@ import com.google.gerrit.extensions.events.ChangeDeletedListener; import com.google.gerrit.reviewdb.client.Change; import com.google.gerrit.server.account.AccountState; import com.google.gerrit.server.plugincontext.PluginSetContext; -import com.google.gwtorm.server.OrmException; import com.google.inject.Inject; import com.google.inject.Singleton; import java.sql.Timestamp; @@ -47,7 +47,7 @@ public class ChangeDeleted { try { Event event = new Event(util.changeInfo(change), util.accountInfo(deleter), when); listeners.runEach(l -> l.onChangeDeleted(event)); - } catch (OrmException e) { + } catch (StorageException e) { logger.atSevere().withCause(e).log("Couldn't fire event"); } } diff --git a/java/com/google/gerrit/server/extensions/events/ChangeMerged.java b/java/com/google/gerrit/server/extensions/events/ChangeMerged.java index 7b814aed0f..756f3832ff 100644 --- a/java/com/google/gerrit/server/extensions/events/ChangeMerged.java +++ b/java/com/google/gerrit/server/extensions/events/ChangeMerged.java @@ -15,6 +15,7 @@ package com.google.gerrit.server.extensions.events; 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.common.AccountInfo; import com.google.gerrit.extensions.common.ChangeInfo; @@ -28,7 +29,6 @@ import com.google.gerrit.server.patch.PatchListNotAvailableException; import com.google.gerrit.server.patch.PatchListObjectTooLargeException; import com.google.gerrit.server.permissions.PermissionBackendException; import com.google.gerrit.server.plugincontext.PluginSetContext; -import com.google.gwtorm.server.OrmException; import com.google.inject.Inject; import com.google.inject.Singleton; import java.io.IOException; @@ -66,7 +66,7 @@ public class ChangeMerged { } catch (PatchListNotAvailableException | GpgException | IOException - | OrmException + | StorageException | PermissionBackendException e) { logger.atSevere().withCause(e).log("Couldn't fire event"); } diff --git a/java/com/google/gerrit/server/extensions/events/ChangeRestored.java b/java/com/google/gerrit/server/extensions/events/ChangeRestored.java index 81b04cdfc8..e8bed56854 100644 --- a/java/com/google/gerrit/server/extensions/events/ChangeRestored.java +++ b/java/com/google/gerrit/server/extensions/events/ChangeRestored.java @@ -15,6 +15,7 @@ package com.google.gerrit.server.extensions.events; 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.common.AccountInfo; import com.google.gerrit.extensions.common.ChangeInfo; @@ -28,7 +29,6 @@ import com.google.gerrit.server.patch.PatchListNotAvailableException; import com.google.gerrit.server.patch.PatchListObjectTooLargeException; import com.google.gerrit.server.permissions.PermissionBackendException; import com.google.gerrit.server.plugincontext.PluginSetContext; -import com.google.gwtorm.server.OrmException; import com.google.inject.Inject; import com.google.inject.Singleton; import java.io.IOException; @@ -66,7 +66,7 @@ public class ChangeRestored { } catch (PatchListNotAvailableException | GpgException | IOException - | OrmException + | StorageException | PermissionBackendException e) { logger.atSevere().withCause(e).log("Couldn't fire event"); } diff --git a/java/com/google/gerrit/server/extensions/events/ChangeReverted.java b/java/com/google/gerrit/server/extensions/events/ChangeReverted.java index ac7aac01f5..ccb17d5cfd 100644 --- a/java/com/google/gerrit/server/extensions/events/ChangeReverted.java +++ b/java/com/google/gerrit/server/extensions/events/ChangeReverted.java @@ -15,12 +15,12 @@ package com.google.gerrit.server.extensions.events; 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.common.ChangeInfo; import com.google.gerrit.extensions.events.ChangeRevertedListener; import com.google.gerrit.reviewdb.client.Change; import com.google.gerrit.server.plugincontext.PluginSetContext; -import com.google.gwtorm.server.OrmException; import com.google.inject.Inject; import com.google.inject.Singleton; import java.sql.Timestamp; @@ -45,7 +45,7 @@ public class ChangeReverted { try { Event event = new Event(util.changeInfo(change), util.changeInfo(revertChange), when); listeners.runEach(l -> l.onChangeReverted(event)); - } catch (OrmException e) { + } catch (StorageException e) { logger.atSevere().withCause(e).log("Couldn't fire event"); } } diff --git a/java/com/google/gerrit/server/extensions/events/CommentAdded.java b/java/com/google/gerrit/server/extensions/events/CommentAdded.java index e224540dab..ea9ae312a4 100644 --- a/java/com/google/gerrit/server/extensions/events/CommentAdded.java +++ b/java/com/google/gerrit/server/extensions/events/CommentAdded.java @@ -15,6 +15,7 @@ package com.google.gerrit.server.extensions.events; 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.common.AccountInfo; import com.google.gerrit.extensions.common.ApprovalInfo; @@ -29,7 +30,6 @@ import com.google.gerrit.server.patch.PatchListNotAvailableException; import com.google.gerrit.server.patch.PatchListObjectTooLargeException; import com.google.gerrit.server.permissions.PermissionBackendException; import com.google.gerrit.server.plugincontext.PluginSetContext; -import com.google.gwtorm.server.OrmException; import com.google.inject.Inject; import com.google.inject.Singleton; import java.io.IOException; @@ -76,7 +76,7 @@ public class CommentAdded { } catch (PatchListNotAvailableException | GpgException | IOException - | OrmException + | StorageException | PermissionBackendException e) { logger.atSevere().withCause(e).log("Couldn't fire event"); } diff --git a/java/com/google/gerrit/server/extensions/events/EventUtil.java b/java/com/google/gerrit/server/extensions/events/EventUtil.java index 30450dd7c3..8bcd8acd78 100644 --- a/java/com/google/gerrit/server/extensions/events/EventUtil.java +++ b/java/com/google/gerrit/server/extensions/events/EventUtil.java @@ -16,6 +16,7 @@ package com.google.gerrit.server.extensions.events; import com.google.common.collect.ImmutableSet; import com.google.common.collect.Sets; +import com.google.gerrit.exceptions.StorageException; import com.google.gerrit.extensions.client.ListChangesOption; import com.google.gerrit.extensions.common.AccountInfo; import com.google.gerrit.extensions.common.ApprovalInfo; @@ -32,7 +33,6 @@ import com.google.gerrit.server.change.RevisionJson; import com.google.gerrit.server.patch.PatchListNotAvailableException; import com.google.gerrit.server.permissions.PermissionBackendException; import com.google.gerrit.server.query.change.ChangeData; -import com.google.gwtorm.server.OrmException; import com.google.inject.Inject; import com.google.inject.Singleton; import java.io.IOException; @@ -74,18 +74,18 @@ public class EventUtil { this.revisionJsonFactory = revisionJsonFactory; } - public ChangeInfo changeInfo(Change change) throws OrmException { + public ChangeInfo changeInfo(Change change) throws StorageException { return changeJsonFactory.create(CHANGE_OPTIONS).format(change); } public RevisionInfo revisionInfo(Project project, PatchSet ps) - throws OrmException, PatchListNotAvailableException, GpgException, IOException, + throws StorageException, PatchListNotAvailableException, GpgException, IOException, PermissionBackendException { return revisionInfo(project.getNameKey(), ps); } public RevisionInfo revisionInfo(Project.NameKey project, PatchSet ps) - throws OrmException, PatchListNotAvailableException, GpgException, IOException, + throws StorageException, PatchListNotAvailableException, GpgException, IOException, PermissionBackendException { ChangeData cd = changeDataFactory.create(project, ps.getId().getParentKey()); return revisionJsonFactory.create(CHANGE_OPTIONS).getRevisionInfo(cd, ps); diff --git a/java/com/google/gerrit/server/extensions/events/HashtagsEdited.java b/java/com/google/gerrit/server/extensions/events/HashtagsEdited.java index ca0edaba9d..65f5b8bfa2 100644 --- a/java/com/google/gerrit/server/extensions/events/HashtagsEdited.java +++ b/java/com/google/gerrit/server/extensions/events/HashtagsEdited.java @@ -16,6 +16,7 @@ package com.google.gerrit.server.extensions.events; import com.google.common.collect.ImmutableSortedSet; 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.common.AccountInfo; import com.google.gerrit.extensions.common.ChangeInfo; @@ -23,7 +24,6 @@ import com.google.gerrit.extensions.events.HashtagsEditedListener; import com.google.gerrit.reviewdb.client.Change; import com.google.gerrit.server.account.AccountState; import com.google.gerrit.server.plugincontext.PluginSetContext; -import com.google.gwtorm.server.OrmException; import com.google.inject.Inject; import com.google.inject.Singleton; import java.sql.Timestamp; @@ -58,7 +58,7 @@ public class HashtagsEdited { new Event( util.changeInfo(change), util.accountInfo(editor), hashtags, added, removed, when); listeners.runEach(l -> l.onHashtagsEdited(event)); - } catch (OrmException e) { + } catch (StorageException e) { logger.atSevere().withCause(e).log("Couldn't fire event"); } } diff --git a/java/com/google/gerrit/server/extensions/events/PrivateStateChanged.java b/java/com/google/gerrit/server/extensions/events/PrivateStateChanged.java index 358667fe0b..49a609124e 100644 --- a/java/com/google/gerrit/server/extensions/events/PrivateStateChanged.java +++ b/java/com/google/gerrit/server/extensions/events/PrivateStateChanged.java @@ -15,6 +15,7 @@ package com.google.gerrit.server.extensions.events; 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.common.AccountInfo; import com.google.gerrit.extensions.common.ChangeInfo; @@ -27,7 +28,6 @@ import com.google.gerrit.server.account.AccountState; import com.google.gerrit.server.patch.PatchListNotAvailableException; import com.google.gerrit.server.permissions.PermissionBackendException; import com.google.gerrit.server.plugincontext.PluginSetContext; -import com.google.gwtorm.server.OrmException; import com.google.inject.Inject; import com.google.inject.Singleton; import java.io.IOException; @@ -58,7 +58,7 @@ public class PrivateStateChanged { util.accountInfo(account), when); listeners.runEach(l -> l.onPrivateStateChanged(event)); - } catch (OrmException + } catch (StorageException | PatchListNotAvailableException | GpgException | IOException diff --git a/java/com/google/gerrit/server/extensions/events/ReviewerAdded.java b/java/com/google/gerrit/server/extensions/events/ReviewerAdded.java index 8e5259c34e..f9f67f6c4b 100644 --- a/java/com/google/gerrit/server/extensions/events/ReviewerAdded.java +++ b/java/com/google/gerrit/server/extensions/events/ReviewerAdded.java @@ -16,6 +16,7 @@ package com.google.gerrit.server.extensions.events; import com.google.common.collect.Lists; 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.common.AccountInfo; import com.google.gerrit.extensions.common.ChangeInfo; @@ -29,7 +30,6 @@ import com.google.gerrit.server.patch.PatchListNotAvailableException; import com.google.gerrit.server.patch.PatchListObjectTooLargeException; import com.google.gerrit.server.permissions.PermissionBackendException; import com.google.gerrit.server.plugincontext.PluginSetContext; -import com.google.gwtorm.server.OrmException; import com.google.inject.Inject; import com.google.inject.Singleton; import java.io.IOException; @@ -73,7 +73,7 @@ public class ReviewerAdded { } catch (PatchListNotAvailableException | GpgException | IOException - | OrmException + | StorageException | PermissionBackendException e) { logger.atSevere().withCause(e).log("Couldn't fire event"); } diff --git a/java/com/google/gerrit/server/extensions/events/ReviewerDeleted.java b/java/com/google/gerrit/server/extensions/events/ReviewerDeleted.java index 89c8f187be..b92f3e6937 100644 --- a/java/com/google/gerrit/server/extensions/events/ReviewerDeleted.java +++ b/java/com/google/gerrit/server/extensions/events/ReviewerDeleted.java @@ -15,6 +15,7 @@ package com.google.gerrit.server.extensions.events; 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.common.AccountInfo; import com.google.gerrit.extensions.common.ApprovalInfo; @@ -29,7 +30,6 @@ import com.google.gerrit.server.patch.PatchListNotAvailableException; import com.google.gerrit.server.patch.PatchListObjectTooLargeException; import com.google.gerrit.server.permissions.PermissionBackendException; import com.google.gerrit.server.plugincontext.PluginSetContext; -import com.google.gwtorm.server.OrmException; import com.google.inject.Inject; import com.google.inject.Singleton; import java.io.IOException; @@ -80,7 +80,7 @@ public class ReviewerDeleted { } catch (PatchListNotAvailableException | GpgException | IOException - | OrmException + | StorageException | PermissionBackendException e) { logger.atSevere().withCause(e).log("Couldn't fire event"); } diff --git a/java/com/google/gerrit/server/extensions/events/RevisionCreated.java b/java/com/google/gerrit/server/extensions/events/RevisionCreated.java index 3fd69a2281..6fddcfe4ad 100644 --- a/java/com/google/gerrit/server/extensions/events/RevisionCreated.java +++ b/java/com/google/gerrit/server/extensions/events/RevisionCreated.java @@ -15,6 +15,7 @@ package com.google.gerrit.server.extensions.events; 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.common.AccountInfo; import com.google.gerrit.extensions.common.ChangeInfo; @@ -29,7 +30,6 @@ import com.google.gerrit.server.patch.PatchListNotAvailableException; import com.google.gerrit.server.patch.PatchListObjectTooLargeException; import com.google.gerrit.server.permissions.PermissionBackendException; import com.google.gerrit.server.plugincontext.PluginSetContext; -import com.google.gwtorm.server.OrmException; import com.google.inject.Inject; import com.google.inject.Singleton; import java.io.IOException; @@ -87,7 +87,7 @@ public class RevisionCreated { } catch (PatchListNotAvailableException | GpgException | IOException - | OrmException + | StorageException | PermissionBackendException e) { logger.atSevere().withCause(e).log("Couldn't fire event"); } diff --git a/java/com/google/gerrit/server/extensions/events/TopicEdited.java b/java/com/google/gerrit/server/extensions/events/TopicEdited.java index 8568c0f404..9e1ae44560 100644 --- a/java/com/google/gerrit/server/extensions/events/TopicEdited.java +++ b/java/com/google/gerrit/server/extensions/events/TopicEdited.java @@ -15,6 +15,7 @@ package com.google.gerrit.server.extensions.events; 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.common.AccountInfo; import com.google.gerrit.extensions.common.ChangeInfo; @@ -22,7 +23,6 @@ import com.google.gerrit.extensions.events.TopicEditedListener; import com.google.gerrit.reviewdb.client.Change; import com.google.gerrit.server.account.AccountState; import com.google.gerrit.server.plugincontext.PluginSetContext; -import com.google.gwtorm.server.OrmException; import com.google.inject.Inject; import com.google.inject.Singleton; import java.sql.Timestamp; @@ -48,7 +48,7 @@ public class TopicEdited { Event event = new Event(util.changeInfo(change), util.accountInfo(account), oldTopicName, when); listeners.runEach(l -> l.onTopicEdited(event)); - } catch (OrmException e) { + } catch (StorageException e) { logger.atSevere().withCause(e).log("Couldn't fire event"); } } diff --git a/java/com/google/gerrit/server/extensions/events/VoteDeleted.java b/java/com/google/gerrit/server/extensions/events/VoteDeleted.java index b750851852..bd6873a65c 100644 --- a/java/com/google/gerrit/server/extensions/events/VoteDeleted.java +++ b/java/com/google/gerrit/server/extensions/events/VoteDeleted.java @@ -15,6 +15,7 @@ package com.google.gerrit.server.extensions.events; 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.common.AccountInfo; import com.google.gerrit.extensions.common.ApprovalInfo; @@ -29,7 +30,6 @@ import com.google.gerrit.server.patch.PatchListNotAvailableException; import com.google.gerrit.server.patch.PatchListObjectTooLargeException; import com.google.gerrit.server.permissions.PermissionBackendException; import com.google.gerrit.server.plugincontext.PluginSetContext; -import com.google.gwtorm.server.OrmException; import com.google.inject.Inject; import com.google.inject.Singleton; import java.io.IOException; @@ -80,7 +80,7 @@ public class VoteDeleted { } catch (PatchListNotAvailableException | GpgException | IOException - | OrmException + | StorageException | PermissionBackendException e) { logger.atSevere().withCause(e).log("Couldn't fire event"); } diff --git a/java/com/google/gerrit/server/extensions/events/WorkInProgressStateChanged.java b/java/com/google/gerrit/server/extensions/events/WorkInProgressStateChanged.java index 6273ad6186..785d6feae8 100644 --- a/java/com/google/gerrit/server/extensions/events/WorkInProgressStateChanged.java +++ b/java/com/google/gerrit/server/extensions/events/WorkInProgressStateChanged.java @@ -15,6 +15,7 @@ package com.google.gerrit.server.extensions.events; 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.common.AccountInfo; import com.google.gerrit.extensions.common.ChangeInfo; @@ -27,7 +28,6 @@ import com.google.gerrit.server.account.AccountState; import com.google.gerrit.server.patch.PatchListNotAvailableException; import com.google.gerrit.server.permissions.PermissionBackendException; import com.google.gerrit.server.plugincontext.PluginSetContext; -import com.google.gwtorm.server.OrmException; import com.google.inject.Inject; import com.google.inject.Singleton; import java.io.IOException; @@ -59,7 +59,7 @@ public class WorkInProgressStateChanged { util.accountInfo(account), when); listeners.runEach(l -> l.onWorkInProgressStateChanged(event)); - } catch (OrmException + } catch (StorageException | PatchListNotAvailableException | GpgException | IOException diff --git a/java/com/google/gerrit/server/git/GroupCollector.java b/java/com/google/gerrit/server/git/GroupCollector.java index 3f037d237e..19c2bc7bb1 100644 --- a/java/com/google/gerrit/server/git/GroupCollector.java +++ b/java/com/google/gerrit/server/git/GroupCollector.java @@ -28,12 +28,12 @@ import com.google.common.collect.SetMultimap; import com.google.common.collect.Sets; import com.google.common.collect.SortedSetMultimap; 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.Project; import com.google.gerrit.server.PatchSetUtil; import com.google.gerrit.server.change.RevisionResource; import com.google.gerrit.server.notedb.ChangeNotes; -import com.google.gwtorm.server.OrmException; import java.util.ArrayDeque; import java.util.Collection; import java.util.Deque; @@ -89,7 +89,7 @@ public class GroupCollector { } private interface Lookup { - List lookup(PatchSet.Id psId) throws OrmException; + List lookup(PatchSet.Id psId) throws StorageException; } private final ListMultimap patchSetsBySha; @@ -198,7 +198,7 @@ public class GroupCollector { } } - public SortedSetMultimap getGroups() throws OrmException { + public SortedSetMultimap getGroups() throws StorageException { done = true; SortedSetMultimap result = MultimapBuilder.hashKeys(groups.keySet().size()).treeSetValues().build(); @@ -225,7 +225,7 @@ public class GroupCollector { } private Set resolveGroups(ObjectId forCommit, Collection candidates) - throws OrmException { + throws StorageException { Set actual = Sets.newTreeSet(); Set done = Sets.newHashSetWithExpectedSize(candidates.size()); Set seen = Sets.newHashSetWithExpectedSize(candidates.size()); @@ -260,7 +260,7 @@ public class GroupCollector { } } - private Iterable resolveGroup(ObjectId forCommit, String group) throws OrmException { + private Iterable resolveGroup(ObjectId forCommit, String group) throws StorageException { ObjectId id = parseGroup(forCommit, group); if (id != null) { PatchSet.Id psId = Iterables.getFirst(patchSetsBySha.get(id), null); diff --git a/java/com/google/gerrit/server/git/MergeUtil.java b/java/com/google/gerrit/server/git/MergeUtil.java index 5de0ce6e9f..5e2ad47a7c 100644 --- a/java/com/google/gerrit/server/git/MergeUtil.java +++ b/java/com/google/gerrit/server/git/MergeUtil.java @@ -30,6 +30,7 @@ import com.google.common.collect.Sets; import com.google.common.flogger.FluentLogger; import com.google.gerrit.common.FooterConstants; import com.google.gerrit.common.data.LabelType; +import com.google.gerrit.exceptions.StorageException; import com.google.gerrit.extensions.registration.DynamicItem; import com.google.gerrit.extensions.registration.DynamicSet; import com.google.gerrit.extensions.registration.Extension; @@ -56,7 +57,6 @@ import com.google.gerrit.server.submit.CommitMergeStatus; import com.google.gerrit.server.submit.IntegrationException; import com.google.gerrit.server.submit.MergeIdenticalTreeException; import com.google.gerrit.server.submit.MergeSorter; -import com.google.gwtorm.server.OrmException; import com.google.inject.Inject; import com.google.inject.assistedinject.Assisted; import com.google.inject.assistedinject.AssistedInject; @@ -237,7 +237,7 @@ public class MergeUtil { List result = new ArrayList<>(); try { result.addAll(mergeSorter.sort(toSort)); - } catch (IOException | OrmException e) { + } catch (IOException | StorageException e) { throw new IntegrationException("Branch head sorting failed", e); } result.sort(CodeReviewCommit.ORDER); @@ -609,7 +609,7 @@ public class MergeUtil { private Iterable safeGetApprovals(ChangeNotes notes, PatchSet.Id psId) { try { return approvalsUtil.byPatchSet(notes, psId, null, null); - } catch (OrmException e) { + } catch (StorageException e) { logger.atSevere().withCause(e).log("Can't read approval records for %s", psId); return Collections.emptyList(); } @@ -722,7 +722,7 @@ public class MergeUtil { throws IntegrationException { try { return !mergeSorter.sort(Collections.singleton(toMerge)).contains(toMerge); - } catch (IOException | OrmException e) { + } catch (IOException | StorageException e) { throw new IntegrationException("Branch head sorting failed", e); } } diff --git a/java/com/google/gerrit/server/git/MergedByPushOp.java b/java/com/google/gerrit/server/git/MergedByPushOp.java index 55bb222a1b..b89845b87a 100644 --- a/java/com/google/gerrit/server/git/MergedByPushOp.java +++ b/java/com/google/gerrit/server/git/MergedByPushOp.java @@ -17,6 +17,7 @@ package com.google.gerrit.server.git; import static java.util.Objects.requireNonNull; 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.ChangeMessage; import com.google.gerrit.reviewdb.client.LabelId; @@ -35,7 +36,6 @@ import com.google.gerrit.server.update.BatchUpdateOp; import com.google.gerrit.server.update.ChangeContext; import com.google.gerrit.server.update.Context; import com.google.gerrit.server.util.RequestScopePropagator; -import com.google.gwtorm.server.OrmException; import com.google.inject.Inject; import com.google.inject.Provider; import com.google.inject.assistedinject.Assisted; @@ -105,7 +105,7 @@ public class MergedByPushOp implements BatchUpdateOp { } @Override - public boolean updateChange(ChangeContext ctx) throws OrmException, IOException { + public boolean updateChange(ChangeContext ctx) throws StorageException, IOException { change = ctx.getChange(); correctBranch = refName.equals(change.getDest().get()); if (!correctBranch) { @@ -193,7 +193,7 @@ public class MergedByPushOp implements BatchUpdateOp { change, patchSet, ctx.getAccount(), patchSet.getRevision().get(), ctx.getWhen()); } - private PatchSetInfo getPatchSetInfo(ChangeContext ctx) throws IOException, OrmException { + private PatchSetInfo getPatchSetInfo(ChangeContext ctx) throws IOException, StorageException { RevWalk rw = ctx.getRevWalk(); RevCommit commit = rw.parseCommit(ObjectId.fromString(requireNonNull(patchSet).getRevision().get())); diff --git a/java/com/google/gerrit/server/git/PureRevertCache.java b/java/com/google/gerrit/server/git/PureRevertCache.java index 53f004f1dc..f8be8dcfd1 100644 --- a/java/com/google/gerrit/server/git/PureRevertCache.java +++ b/java/com/google/gerrit/server/git/PureRevertCache.java @@ -18,6 +18,7 @@ import com.google.common.annotations.VisibleForTesting; import com.google.common.base.Throwables; import com.google.common.cache.CacheLoader; import com.google.common.cache.LoadingCache; +import com.google.gerrit.exceptions.StorageException; import com.google.gerrit.extensions.restapi.BadRequestException; import com.google.gerrit.reviewdb.client.Change; import com.google.gerrit.reviewdb.client.Project; @@ -30,7 +31,6 @@ import com.google.gerrit.server.cache.serialize.ProtobufSerializer; import com.google.gerrit.server.logging.TraceContext; import com.google.gerrit.server.notedb.ChangeNotes; import com.google.gerrit.server.project.ProjectCache; -import com.google.gwtorm.server.OrmException; import com.google.inject.Inject; import com.google.inject.Module; import com.google.inject.Singleton; @@ -87,11 +87,11 @@ public class PureRevertCache { * * @return {@code true} if {@code claimedRevert} is a pure (clean) revert. * @throws IOException if there was a problem with the storage layer - * @throws OrmException 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} */ public boolean isPureRevert(ChangeNotes claimedRevert) - throws OrmException, IOException, BadRequestException { + throws StorageException, IOException, BadRequestException { if (claimedRevert.getChange().getRevertOf() == null) { throw new BadRequestException("revertOf not set"); } diff --git a/java/com/google/gerrit/server/git/receive/BUILD b/java/com/google/gerrit/server/git/receive/BUILD index b7b3f516bf..da21fbb245 100644 --- a/java/com/google/gerrit/server/git/receive/BUILD +++ b/java/com/google/gerrit/server/git/receive/BUILD @@ -5,6 +5,7 @@ java_library( deps = [ "//java/com/google/gerrit/common:annotations", "//java/com/google/gerrit/common:server", + "//java/com/google/gerrit/exceptions", "//java/com/google/gerrit/extensions:api", "//java/com/google/gerrit/metrics", "//java/com/google/gerrit/reviewdb:server", @@ -12,7 +13,6 @@ java_library( "//java/com/google/gerrit/server/logging", "//java/com/google/gerrit/server/util/time", "//java/com/google/gerrit/util/cli", - "//java/com/google/gwtorm", "//lib:args4j", "//lib:guava", "//lib/auto:auto-value", diff --git a/java/com/google/gerrit/server/git/receive/ReceiveCommits.java b/java/com/google/gerrit/server/git/receive/ReceiveCommits.java index 103edd8c84..7bb63ba62e 100644 --- a/java/com/google/gerrit/server/git/receive/ReceiveCommits.java +++ b/java/com/google/gerrit/server/git/receive/ReceiveCommits.java @@ -64,6 +64,7 @@ import com.google.gerrit.common.FooterConstants; import com.google.gerrit.common.Nullable; import com.google.gerrit.common.data.LabelType; import com.google.gerrit.common.data.LabelTypes; +import com.google.gerrit.exceptions.StorageException; import com.google.gerrit.extensions.api.changes.HashtagsInput; import com.google.gerrit.extensions.api.changes.NotifyHandling; import com.google.gerrit.extensions.api.changes.RecipientType; @@ -158,7 +159,6 @@ import com.google.gerrit.server.util.MagicBranch; import com.google.gerrit.server.util.RequestScopePropagator; import com.google.gerrit.server.util.time.TimeUtil; import com.google.gerrit.util.cli.CmdLineParser; -import com.google.gwtorm.server.OrmException; import com.google.inject.Inject; import com.google.inject.Provider; import com.google.inject.assistedinject.Assisted; @@ -897,7 +897,7 @@ class ReceiveCommits { addError(e.getMessage()); reject(magicBranchCmd, "conflict"); } catch (RestApiException - | OrmException + | StorageException | UpdateException | IOException | ConfigInvalidException @@ -1938,7 +1938,7 @@ class ReceiveCommits { logger.atSevere().withCause(e).log("Change not found %s", changeId); reject(cmd, "change " + changeId + " not found"); return; - } catch (OrmException e) { + } catch (StorageException e) { logger.atSevere().withCause(e).log("Cannot lookup existing change %s", changeId); reject(cmd, "database error"); return; @@ -2237,7 +2237,7 @@ class ReceiveCommits { magicBranch.cmd.setResult(REJECTED_MISSING_OBJECT); logger.atSevere().withCause(e).log("Invalid pack upload; one or more objects weren't sent"); return Collections.emptyList(); - } catch (OrmException e) { + } catch (StorageException e) { logger.atSevere().withCause(e).log("Cannot query database to locate prior changes"); reject(magicBranch.cmd, "database error"); return Collections.emptyList(); @@ -2267,14 +2267,14 @@ class ReceiveCommits { update.groups = ImmutableList.copyOf((groups.get(update.commit))); } logger.atFine().log("Finished updating groups from GroupCollector"); - } catch (OrmException e) { + } catch (StorageException e) { logger.atSevere().withCause(e).log("Error collecting groups for changes"); reject(magicBranch.cmd, "internal server error"); } return newChanges; } - private boolean foundInExistingRef(Collection existingRefs) throws OrmException { + private boolean foundInExistingRef(Collection existingRefs) throws StorageException { for (Ref ref : existingRefs) { ChangeNotes notes = notesFactory.create(project.getNameKey(), Change.Id.fromRef(ref.getName())); @@ -2394,11 +2394,11 @@ class ReceiveCommits { } } - private ChangeLookup lookupByChangeKey(RevCommit c, Change.Key key) throws OrmException { + private ChangeLookup lookupByChangeKey(RevCommit c, Change.Key key) throws StorageException { return new ChangeLookup(c, key, queryProvider.get().byBranchKey(magicBranch.dest, key)); } - private ChangeLookup lookupByCommit(RevCommit c) throws OrmException { + private ChangeLookup lookupByCommit(RevCommit c) throws StorageException { return new ChangeLookup( c, null, queryProvider.get().byBranchCommit(magicBranch.dest, c.getName())); } @@ -2525,8 +2525,8 @@ class ReceiveCommits { } private void submit(Collection create, Collection replace) - throws OrmException, RestApiException, UpdateException, IOException, ConfigInvalidException, - PermissionBackendException { + throws StorageException, RestApiException, UpdateException, IOException, + ConfigInvalidException, PermissionBackendException { Map bySha = Maps.newHashMapWithExpectedSize(create.size() + replace.size()); for (CreateRequest r : create) { requireNonNull( @@ -2558,7 +2558,7 @@ class ReceiveCommits { req.validateNewPatchSet(); } } - } catch (OrmException err) { + } catch (StorageException err) { logger.atSevere().withCause(err).log( "Cannot read database before replacement for project %s", project.getName()); rejectRemainingRequests(replaceByChange.values(), "internal server error"); @@ -2582,7 +2582,7 @@ class ReceiveCommits { } } - private void readChangesForReplace() throws OrmException { + private void readChangesForReplace() throws StorageException { Collection allNotes = notesFactory.create( replaceByChange.values().stream().map(r -> r.ontoChange).collect(toList())); @@ -2646,10 +2646,10 @@ class ReceiveCommits { * * @return whether the new commit is valid * @throws IOException - * @throws OrmException + * @throws StorageException * @throws PermissionBackendException */ - boolean validateNewPatchSet() throws IOException, OrmException, PermissionBackendException { + boolean validateNewPatchSet() throws IOException, StorageException, PermissionBackendException { if (!validateNewPatchSetNoteDb()) { return false; } @@ -2671,7 +2671,7 @@ class ReceiveCommits { } boolean validateNewPatchSetForAutoClose() - throws IOException, OrmException, PermissionBackendException { + throws IOException, StorageException, PermissionBackendException { if (!validateNewPatchSetNoteDb()) { return false; } @@ -2682,7 +2682,7 @@ class ReceiveCommits { /** Validates the new PS against permissions and notedb status. */ private boolean validateNewPatchSetNoteDb() - throws IOException, OrmException, PermissionBackendException { + throws IOException, StorageException, PermissionBackendException { if (notes == null) { reject(inputCommand, "change " + ontoChange + " not found"); return false; @@ -2845,7 +2845,7 @@ class ReceiveCommits { } /** Updates 'this' to add a new patchset. */ - private void newPatchSet() throws IOException, OrmException { + private void newPatchSet() throws IOException, StorageException { RevCommit newCommit = receivePack.getRevWalk().parseCommit(newCommitId); psId = ChangeUtil.nextPatchSetIdFromAllRefsMap(allRefs(), notes.getChange().currentPatchSetId()); @@ -2909,7 +2909,7 @@ class ReceiveCommits { psId.getParentKey(), new BatchUpdateOp() { @Override - public boolean updateChange(ChangeContext ctx) throws OrmException { + public boolean updateChange(ChangeContext ctx) throws StorageException { PatchSet ps = psUtil.get(ctx.getNotes(), psId); List oldGroups = ps.getGroups(); if (oldGroups == null) { @@ -3217,7 +3217,7 @@ class ReceiveCommits { "Auto-closing %s changes with existing patch sets and %s with new patch sets", existingPatchSets, newPatchSets); bu.execute(); - } catch (IOException | OrmException | PermissionBackendException e) { + } catch (IOException | StorageException | PermissionBackendException e) { logger.atSevere().withCause(e).log("Failed to auto-close changes"); return null; } @@ -3241,7 +3241,7 @@ class ReceiveCommits { } } - private Optional getChangeNotes(Change.Id changeId) throws OrmException { + private Optional getChangeNotes(Change.Id changeId) throws StorageException { try { return Optional.of(notesFactory.createChecked(project.getNameKey(), changeId)); } catch (NoSuchChangeException e) { @@ -3249,18 +3249,19 @@ class ReceiveCommits { } } - private T executeIndexQuery(Action action) throws OrmException { + private T executeIndexQuery(Action action) throws StorageException { try { - return retryHelper.execute(ActionType.INDEX_QUERY, action, OrmException.class::isInstance); + return retryHelper.execute( + ActionType.INDEX_QUERY, action, StorageException.class::isInstance); } catch (Exception e) { Throwables.throwIfUnchecked(e); - Throwables.throwIfInstanceOf(e, OrmException.class); - throw new OrmException(e); + Throwables.throwIfInstanceOf(e, StorageException.class); + throw new StorageException(e); } } private Map openChangesByKeyByBranch(Branch.NameKey branch) - throws OrmException { + throws StorageException { Map r = new HashMap<>(); for (ChangeData cd : queryProvider.get().byBranchOpen(branch)) { try { diff --git a/java/com/google/gerrit/server/git/receive/ReceiveCommitsAdvertiseRefsHook.java b/java/com/google/gerrit/server/git/receive/ReceiveCommitsAdvertiseRefsHook.java index 8cbcc887d4..9aa21afacc 100644 --- a/java/com/google/gerrit/server/git/receive/ReceiveCommitsAdvertiseRefsHook.java +++ b/java/com/google/gerrit/server/git/receive/ReceiveCommitsAdvertiseRefsHook.java @@ -19,6 +19,7 @@ import com.google.common.annotations.VisibleForTesting; import com.google.common.collect.Maps; import com.google.common.collect.Sets; 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.Project; import com.google.gerrit.reviewdb.client.RefNames; @@ -27,7 +28,6 @@ import com.google.gerrit.server.index.change.ChangeField; import com.google.gerrit.server.query.change.ChangeData; import com.google.gerrit.server.query.change.InternalChangeQuery; import com.google.gerrit.server.util.MagicBranch; -import com.google.gwtorm.server.OrmException; import com.google.inject.Provider; import java.util.Collections; import java.util.Map; @@ -118,7 +118,7 @@ public class ReceiveCommitsAdvertiseRefsHook implements AdvertiseRefsHook { } } return r; - } catch (OrmException err) { + } catch (StorageException err) { logger.atSevere().withCause(err).log("Cannot list open changes of %s", projectName); return Collections.emptySet(); } diff --git a/java/com/google/gerrit/server/git/receive/ReplaceOp.java b/java/com/google/gerrit/server/git/receive/ReplaceOp.java index 6636b1fa94..2e50789544 100644 --- a/java/com/google/gerrit/server/git/receive/ReplaceOp.java +++ b/java/com/google/gerrit/server/git/receive/ReplaceOp.java @@ -29,6 +29,7 @@ import com.google.common.collect.Streams; import com.google.common.flogger.FluentLogger; import com.google.gerrit.common.Nullable; 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.NotifyHandling; import com.google.gerrit.extensions.client.ChangeKind; @@ -74,7 +75,6 @@ import com.google.gerrit.server.update.ChangeContext; import com.google.gerrit.server.update.Context; import com.google.gerrit.server.update.RepoContext; import com.google.gerrit.server.util.RequestScopePropagator; -import com.google.gwtorm.server.OrmException; import com.google.inject.Inject; import com.google.inject.assistedinject.Assisted; import com.google.inject.util.Providers; @@ -242,7 +242,7 @@ public class ReplaceOp implements BatchUpdateOp { @Override public boolean updateChange(ChangeContext ctx) - throws RestApiException, OrmException, IOException, PermissionBackendException, + throws RestApiException, StorageException, IOException, PermissionBackendException, ConfigInvalidException { notes = ctx.getNotes(); Change change = notes.getChange(); @@ -387,7 +387,7 @@ public class ReplaceOp implements BatchUpdateOp { } private ChangeMessage createChangeMessage(ChangeContext ctx, String reviewMessage) - throws OrmException, IOException { + throws StorageException, IOException { String approvalMessage = ApprovalsUtil.renderMessageWithApprovals( patchSetId.get(), approvals, scanLabels(ctx, approvals)); @@ -441,7 +441,7 @@ public class ReplaceOp implements BatchUpdateOp { } private Map scanLabels(ChangeContext ctx, Map approvals) - throws OrmException, IOException { + throws StorageException, IOException { Map current = new HashMap<>(); // We optimize here and only retrieve current when approvals provided if (!approvals.isEmpty()) { @@ -486,7 +486,7 @@ public class ReplaceOp implements BatchUpdateOp { } private List publishComments(ChangeContext ctx, boolean workInProgress) - throws OrmException { + throws StorageException { List comments = commentsUtil.draftByChangeAuthor(ctx.getNotes(), ctx.getUser().getAccountId()); publishCommentUtil.publish( diff --git a/java/com/google/gerrit/server/git/validators/MergeValidators.java b/java/com/google/gerrit/server/git/validators/MergeValidators.java index 1dd48f1c0d..b4359ed520 100644 --- a/java/com/google/gerrit/server/git/validators/MergeValidators.java +++ b/java/com/google/gerrit/server/git/validators/MergeValidators.java @@ -17,6 +17,7 @@ package com.google.gerrit.server.git.validators; import com.google.common.base.Joiner; import com.google.common.collect.ImmutableList; import com.google.common.flogger.FluentLogger; +import com.google.gerrit.exceptions.StorageException; import com.google.gerrit.extensions.api.projects.ProjectConfigEntryType; import com.google.gerrit.extensions.registration.DynamicMap; import com.google.gerrit.extensions.registration.Extension; @@ -43,7 +44,6 @@ import com.google.gerrit.server.project.ProjectCache; import com.google.gerrit.server.project.ProjectConfig; import com.google.gerrit.server.project.ProjectState; import com.google.gerrit.server.query.change.ChangeData; -import com.google.gwtorm.server.OrmException; import com.google.inject.Inject; import java.io.IOException; import java.util.List; @@ -301,7 +301,7 @@ public class MergeValidators { if (!cd.currentFilePaths().contains(AccountProperties.ACCOUNT_CONFIG)) { return; } - } catch (IOException | OrmException e) { + } catch (IOException | StorageException e) { logger.atSevere().withCause(e).log("Cannot validate account update"); throw new MergeValidationException("account validation unavailable"); } diff --git a/java/com/google/gerrit/server/group/db/GroupConfig.java b/java/com/google/gerrit/server/group/db/GroupConfig.java index abc8c90d88..903b9c08b0 100644 --- a/java/com/google/gerrit/server/group/db/GroupConfig.java +++ b/java/com/google/gerrit/server/group/db/GroupConfig.java @@ -24,6 +24,7 @@ import com.google.common.base.Splitter; import com.google.common.base.Strings; import com.google.common.collect.ImmutableSet; import com.google.common.collect.Streams; +import com.google.gerrit.exceptions.DuplicateKeyException; import com.google.gerrit.reviewdb.client.Account; import com.google.gerrit.reviewdb.client.AccountGroup; import com.google.gerrit.reviewdb.client.Project; @@ -32,7 +33,6 @@ import com.google.gerrit.server.git.meta.MetaDataUpdate; import com.google.gerrit.server.git.meta.VersionedMetaData; import com.google.gerrit.server.group.InternalGroup; import com.google.gerrit.server.util.time.TimeUtil; -import com.google.gwtorm.server.OrmDuplicateKeyException; import java.io.IOException; import java.sql.Timestamp; import java.util.Arrays; @@ -110,11 +110,11 @@ public class GroupConfig extends VersionedMetaData { * @throws IOException if the repository can't be accessed for some reason * @throws ConfigInvalidException if a group with the same UUID already exists but can't be read * due to an invalid format - * @throws OrmDuplicateKeyException if a group with the same UUID already exists + * @throws DuplicateKeyException if a group with the same UUID already exists */ public static GroupConfig createForNewGroup( Project.NameKey projectName, Repository repository, InternalGroupCreation groupCreation) - throws IOException, ConfigInvalidException, OrmDuplicateKeyException { + throws IOException, ConfigInvalidException, DuplicateKeyException { GroupConfig groupConfig = new GroupConfig(groupCreation.getGroupUUID()); groupConfig.load(projectName, repository); groupConfig.setGroupCreation(groupCreation); @@ -241,11 +241,10 @@ public class GroupConfig extends VersionedMetaData { this.allowSaveEmptyName = true; } - private void setGroupCreation(InternalGroupCreation groupCreation) - throws OrmDuplicateKeyException { + private void setGroupCreation(InternalGroupCreation groupCreation) throws DuplicateKeyException { checkLoaded(); if (loadedGroup.isPresent()) { - throw new OrmDuplicateKeyException(String.format("Group %s already exists", groupUuid.get())); + throw new DuplicateKeyException(String.format("Group %s already exists", groupUuid.get())); } this.groupCreation = Optional.of(groupCreation); diff --git a/java/com/google/gerrit/server/group/db/GroupNameNotes.java b/java/com/google/gerrit/server/group/db/GroupNameNotes.java index e95e91fbd2..eda7153cf2 100644 --- a/java/com/google/gerrit/server/group/db/GroupNameNotes.java +++ b/java/com/google/gerrit/server/group/db/GroupNameNotes.java @@ -29,11 +29,11 @@ import com.google.common.flogger.FluentLogger; import com.google.common.hash.Hashing; import com.google.gerrit.common.Nullable; import com.google.gerrit.common.data.GroupReference; +import com.google.gerrit.exceptions.DuplicateKeyException; import com.google.gerrit.reviewdb.client.AccountGroup; import com.google.gerrit.reviewdb.client.Project; import com.google.gerrit.reviewdb.client.RefNames; import com.google.gerrit.server.git.meta.VersionedMetaData; -import com.google.gwtorm.server.OrmDuplicateKeyException; import java.io.IOException; import java.util.Collection; import java.util.Map; @@ -114,7 +114,7 @@ public class GroupNameNotes extends VersionedMetaData { * @throws IOException if the repository can't be accessed for some reason * @throws ConfigInvalidException if the note for the specified group doesn't exist or is in an * invalid state - * @throws OrmDuplicateKeyException if a group with the new name already exists + * @throws DuplicateKeyException if a group with the new name already exists */ public static GroupNameNotes forRename( Project.NameKey projectName, @@ -122,7 +122,7 @@ public class GroupNameNotes extends VersionedMetaData { AccountGroup.UUID groupUuid, AccountGroup.NameKey oldName, AccountGroup.NameKey newName) - throws IOException, ConfigInvalidException, OrmDuplicateKeyException { + throws IOException, ConfigInvalidException, DuplicateKeyException { requireNonNull(oldName); requireNonNull(newName); @@ -146,14 +146,14 @@ public class GroupNameNotes extends VersionedMetaData { * @return an instance of {@code GroupNameNotes} configured for a specific group creation * @throws IOException if the repository can't be accessed for some reason * @throws ConfigInvalidException in no case so far - * @throws OrmDuplicateKeyException if a group with the new name already exists + * @throws DuplicateKeyException if a group with the new name already exists */ public static GroupNameNotes forNewGroup( Project.NameKey projectName, Repository repository, AccountGroup.UUID groupUuid, AccountGroup.NameKey groupName) - throws IOException, ConfigInvalidException, OrmDuplicateKeyException { + throws IOException, ConfigInvalidException, DuplicateKeyException { requireNonNull(groupName); GroupNameNotes groupNameNotes = new GroupNameNotes(groupUuid, null, groupName); @@ -363,9 +363,9 @@ public class GroupNameNotes extends VersionedMetaData { } } - private void ensureNewNameIsNotUsed() throws OrmDuplicateKeyException { + private void ensureNewNameIsNotUsed() throws DuplicateKeyException { if (newGroupName.isPresent() && nameConflicting) { - throw new OrmDuplicateKeyException( + throw new DuplicateKeyException( String.format("Name '%s' is already used", newGroupName.get().get())); } } diff --git a/java/com/google/gerrit/server/group/db/GroupsUpdate.java b/java/com/google/gerrit/server/group/db/GroupsUpdate.java index c55f37502b..710f886274 100644 --- a/java/com/google/gerrit/server/group/db/GroupsUpdate.java +++ b/java/com/google/gerrit/server/group/db/GroupsUpdate.java @@ -21,6 +21,7 @@ import com.google.common.collect.ImmutableSet; import com.google.common.collect.Sets; import com.google.common.flogger.FluentLogger; import com.google.gerrit.common.Nullable; +import com.google.gerrit.exceptions.DuplicateKeyException; import com.google.gerrit.exceptions.NoSuchGroupException; import com.google.gerrit.git.LockFailureException; import com.google.gerrit.git.RefUpdateUtil; @@ -45,7 +46,6 @@ import com.google.gerrit.server.logging.TraceContext; import com.google.gerrit.server.logging.TraceContext.TraceTimer; import com.google.gerrit.server.update.RetryHelper; import com.google.gerrit.server.util.time.TimeUtil; -import com.google.gwtorm.server.OrmDuplicateKeyException; import com.google.inject.Provider; import com.google.inject.assistedinject.Assisted; import com.google.inject.assistedinject.AssistedInject; @@ -256,13 +256,13 @@ public class GroupsUpdate { * @param groupUpdate an {@code InternalGroupUpdate} which specifies optional properties of the * group. If this {@code InternalGroupUpdate} updates a property which was already specified * by the {@code InternalGroupCreation}, the value of this {@code InternalGroupUpdate} wins. - * @throws OrmDuplicateKeyException if a group with the chosen name already exists + * @throws DuplicateKeyException if a group with the chosen name already exists * @throws IOException if indexing fails, or an error occurs while reading/writing from/to NoteDb * @return the created {@code InternalGroup} */ public InternalGroup createGroup( InternalGroupCreation groupCreation, InternalGroupUpdate groupUpdate) - throws OrmDuplicateKeyException, IOException, ConfigInvalidException { + throws DuplicateKeyException, IOException, ConfigInvalidException { try (TraceTimer timer = TraceContext.newTimer( "Creating group '%s'", groupUpdate.getName().orElseGet(groupCreation::getNameKey))) { @@ -279,12 +279,12 @@ public class GroupsUpdate { * @param groupUuid the UUID of the group to update * @param groupUpdate an {@code InternalGroupUpdate} which indicates the desired updates on the * group - * @throws OrmDuplicateKeyException if the new name of the group is used by another group + * @throws DuplicateKeyException if the new name of the group is used by another group * @throws IOException if indexing fails, or an error occurs while reading/writing from/to NoteDb * @throws NoSuchGroupException if the specified group doesn't exist */ public void updateGroup(AccountGroup.UUID groupUuid, InternalGroupUpdate groupUpdate) - throws OrmDuplicateKeyException, IOException, NoSuchGroupException, ConfigInvalidException { + throws DuplicateKeyException, IOException, NoSuchGroupException, ConfigInvalidException { try (TraceTimer timer = TraceContext.newTimer("Updating group %s", groupUuid)) { Optional updatedOn = groupUpdate.getUpdatedOn(); if (!updatedOn.isPresent()) { @@ -301,7 +301,7 @@ public class GroupsUpdate { private InternalGroup createGroupInNoteDbWithRetry( InternalGroupCreation groupCreation, InternalGroupUpdate groupUpdate) - throws IOException, ConfigInvalidException, OrmDuplicateKeyException { + throws IOException, ConfigInvalidException, DuplicateKeyException { try { return retryHelper.execute( RetryHelper.ActionType.GROUP_UPDATE, @@ -311,7 +311,7 @@ public class GroupsUpdate { Throwables.throwIfUnchecked(e); Throwables.throwIfInstanceOf(e, IOException.class); Throwables.throwIfInstanceOf(e, ConfigInvalidException.class); - Throwables.throwIfInstanceOf(e, OrmDuplicateKeyException.class); + Throwables.throwIfInstanceOf(e, DuplicateKeyException.class); throw new IOException(e); } } @@ -319,7 +319,7 @@ public class GroupsUpdate { @VisibleForTesting public InternalGroup createGroupInNoteDb( InternalGroupCreation groupCreation, InternalGroupUpdate groupUpdate) - throws IOException, ConfigInvalidException, OrmDuplicateKeyException { + throws IOException, ConfigInvalidException, DuplicateKeyException { try (Repository allUsersRepo = repoManager.openRepository(allUsersName)) { AccountGroup.NameKey groupName = groupUpdate.getName().orElseGet(groupCreation::getNameKey); GroupNameNotes groupNameNotes = @@ -341,7 +341,7 @@ public class GroupsUpdate { private UpdateResult updateGroupInNoteDbWithRetry( AccountGroup.UUID groupUuid, InternalGroupUpdate groupUpdate) - throws IOException, ConfigInvalidException, OrmDuplicateKeyException, NoSuchGroupException { + throws IOException, ConfigInvalidException, DuplicateKeyException, NoSuchGroupException { try { return retryHelper.execute( RetryHelper.ActionType.GROUP_UPDATE, @@ -351,7 +351,7 @@ public class GroupsUpdate { Throwables.throwIfUnchecked(e); Throwables.throwIfInstanceOf(e, IOException.class); Throwables.throwIfInstanceOf(e, ConfigInvalidException.class); - Throwables.throwIfInstanceOf(e, OrmDuplicateKeyException.class); + Throwables.throwIfInstanceOf(e, DuplicateKeyException.class); Throwables.throwIfInstanceOf(e, NoSuchGroupException.class); throw new IOException(e); } @@ -360,7 +360,7 @@ public class GroupsUpdate { @VisibleForTesting public UpdateResult updateGroupInNoteDb( AccountGroup.UUID groupUuid, InternalGroupUpdate groupUpdate) - throws IOException, ConfigInvalidException, OrmDuplicateKeyException, NoSuchGroupException { + throws IOException, ConfigInvalidException, DuplicateKeyException, NoSuchGroupException { try (Repository allUsersRepo = repoManager.openRepository(allUsersName)) { GroupConfig groupConfig = GroupConfig.loadForGroup(allUsersName, allUsersRepo, groupUuid); groupConfig.setGroupUpdate(groupUpdate, auditLogFormatter); diff --git a/java/com/google/gerrit/server/index/account/IndexedAccountQuery.java b/java/com/google/gerrit/server/index/account/IndexedAccountQuery.java index 18f44f08af..aa2962b150 100644 --- a/java/com/google/gerrit/server/index/account/IndexedAccountQuery.java +++ b/java/com/google/gerrit/server/index/account/IndexedAccountQuery.java @@ -16,6 +16,7 @@ package com.google.gerrit.server.index.account; 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.QueryOptions; import com.google.gerrit.index.query.DataSource; @@ -25,7 +26,6 @@ import com.google.gerrit.index.query.Predicate; import com.google.gerrit.index.query.QueryParseException; import com.google.gerrit.reviewdb.client.Account; import com.google.gerrit.server.account.AccountState; -import com.google.gwtorm.server.OrmException; public class IndexedAccountQuery extends IndexedQuery implements DataSource, Matchable { @@ -37,7 +37,7 @@ public class IndexedAccountQuery extends IndexedQuery } @Override - public boolean match(AccountState accountState) throws OrmException { + public boolean match(AccountState accountState) throws StorageException { Predicate pred = getChild(0); checkState( pred.isMatchable(), diff --git a/java/com/google/gerrit/server/index/change/ChangeField.java b/java/com/google/gerrit/server/index/change/ChangeField.java index 50b38d3ad4..a5ce3c950f 100644 --- a/java/com/google/gerrit/server/index/change/ChangeField.java +++ b/java/com/google/gerrit/server/index/change/ChangeField.java @@ -42,6 +42,7 @@ import com.google.common.io.Files; import com.google.common.primitives.Longs; import com.google.gerrit.common.data.SubmitRecord; import com.google.gerrit.common.data.SubmitRequirement; +import com.google.gerrit.exceptions.StorageException; import com.google.gerrit.index.FieldDef; import com.google.gerrit.index.RefState; import com.google.gerrit.index.SchemaUtil; @@ -72,7 +73,6 @@ import com.google.gerrit.server.query.change.ChangeData; import com.google.gerrit.server.query.change.ChangeQueryBuilder; import com.google.gerrit.server.query.change.ChangeStatusPredicate; import com.google.gson.Gson; -import com.google.gwtorm.server.OrmException; import java.io.IOException; import java.sql.Timestamp; import java.util.ArrayList; @@ -154,12 +154,12 @@ public class ChangeField { exact(ChangeQueryBuilder.FIELD_FILE) .buildRepeatable(cd -> firstNonNull(cd.currentFilePaths(), ImmutableList.of())); - public static Set getFileParts(ChangeData cd) throws OrmException { + public static Set getFileParts(ChangeData cd) throws StorageException { List paths; try { paths = cd.currentFilePaths(); } catch (IOException e) { - throw new OrmException(e); + throw new StorageException(e); } Splitter s = Splitter.on('/').omitEmptyStrings(); @@ -191,7 +191,7 @@ public class ChangeField { public static final FieldDef> EXTENSION = exact(ChangeQueryBuilder.FIELD_EXTENSION).buildRepeatable(ChangeField::getExtensions); - public static Set getExtensions(ChangeData cd) throws OrmException { + public static Set getExtensions(ChangeData cd) throws StorageException { return extensions(cd).collect(toSet()); } @@ -202,7 +202,7 @@ public class ChangeField { public static final FieldDef ONLY_EXTENSIONS = exact(ChangeQueryBuilder.FIELD_ONLY_EXTENSIONS).build(ChangeField::getAllExtensionsAsList); - public static String getAllExtensionsAsList(ChangeData cd) throws OrmException { + public static String getAllExtensionsAsList(ChangeData cd) throws StorageException { return extensions(cd).distinct().sorted().collect(joining(",")); } @@ -214,7 +214,7 @@ public class ChangeField { *

If the change contains multiple files with the same extension the extension is returned * multiple times in the stream (once per file). */ - private static Stream extensions(ChangeData cd) throws OrmException { + private static Stream extensions(ChangeData cd) throws StorageException { try { return cd.currentFilePaths().stream() // Use case-insensitive file extensions even though other file fields are case-sensitive. @@ -223,7 +223,7 @@ public class ChangeField { // predicates to be case insensitive is a separate question.) .map(f -> Files.getFileExtension(f).toLowerCase(Locale.US)); } catch (IOException e) { - throw new OrmException(e); + throw new StorageException(e); } } @@ -231,13 +231,13 @@ public class ChangeField { public static final FieldDef> FOOTER = exact(ChangeQueryBuilder.FIELD_FOOTER).buildRepeatable(ChangeField::getFooters); - public static Set getFooters(ChangeData cd) throws OrmException { + public static Set getFooters(ChangeData cd) throws StorageException { try { return cd.commitFooters().stream() .map(f -> f.toString().toLowerCase(Locale.US)) .collect(toSet()); } catch (IOException e) { - throw new OrmException(e); + throw new StorageException(e); } } @@ -245,12 +245,12 @@ public class ChangeField { public static final FieldDef> DIRECTORY = exact(ChangeQueryBuilder.FIELD_DIRECTORY).buildRepeatable(ChangeField::getDirectories); - public static Set getDirectories(ChangeData cd) throws OrmException { + public static Set getDirectories(ChangeData cd) throws StorageException { List paths; try { paths = cd.currentFilePaths(); } catch (IOException e) { - throw new OrmException(e); + throw new StorageException(e); } Splitter s = Splitter.on('/').omitEmptyStrings(); @@ -470,7 +470,7 @@ public class ChangeField { public static final FieldDef> EXACT_COMMIT = exact(ChangeQueryBuilder.FIELD_EXACTCOMMIT).buildRepeatable(ChangeField::getRevisions); - private static Set getRevisions(ChangeData cd) throws OrmException { + private static Set getRevisions(ChangeData cd) throws StorageException { Set revisions = new HashSet<>(); for (PatchSet ps : cd.patchSets()) { if (ps.getRevision() != null) { @@ -489,7 +489,7 @@ public class ChangeField { public static final FieldDef> LABEL = exact("label2").buildRepeatable(cd -> getLabels(cd, true)); - private static Iterable getLabels(ChangeData cd, boolean owners) throws OrmException { + private static Iterable getLabels(ChangeData cd, boolean owners) throws StorageException { Set allApprovals = new HashSet<>(); Set distinctApprovals = new HashSet<>(); for (PatchSetApproval a : cd.currentApprovals()) { @@ -506,20 +506,21 @@ public class ChangeField { return allApprovals; } - public static Set getAuthorParts(ChangeData cd) throws OrmException, IOException { + public static Set getAuthorParts(ChangeData cd) throws StorageException, IOException { return SchemaUtil.getPersonParts(cd.getAuthor()); } - public static Set getAuthorNameAndEmail(ChangeData cd) throws OrmException, IOException { + public static Set getAuthorNameAndEmail(ChangeData cd) + throws StorageException, IOException { return getNameAndEmail(cd.getAuthor()); } - public static Set getCommitterParts(ChangeData cd) throws OrmException, IOException { + public static Set getCommitterParts(ChangeData cd) throws StorageException, IOException { return SchemaUtil.getPersonParts(cd.getCommitter()); } public static Set getCommitterNameAndEmail(ChangeData cd) - throws OrmException, IOException { + throws StorageException, IOException { return getNameAndEmail(cd.getCommitter()); } @@ -855,7 +856,7 @@ public class ChangeField { return storedSubmitRecords(cd.submitRecords(opts)); } - public static List formatSubmitRecordValues(ChangeData cd) throws OrmException { + public static List formatSubmitRecordValues(ChangeData cd) throws StorageException { return formatSubmitRecordValues( cd.submitRecords(SUBMIT_RULE_OPTIONS_STRICT), cd.change().getOwner()); } @@ -943,7 +944,7 @@ public class ChangeField { return result; }); - private static String getTopic(ChangeData cd) throws OrmException { + private static String getTopic(ChangeData cd) throws StorageException { Change c = cd.change(); if (c == null) { return null; diff --git a/java/com/google/gerrit/server/index/change/IndexedChangeQuery.java b/java/com/google/gerrit/server/index/change/IndexedChangeQuery.java index 80888374e5..0831531098 100644 --- a/java/com/google/gerrit/server/index/change/IndexedChangeQuery.java +++ b/java/com/google/gerrit/server/index/change/IndexedChangeQuery.java @@ -22,6 +22,7 @@ import com.google.common.annotations.VisibleForTesting; import com.google.common.collect.ImmutableList; import com.google.common.collect.ImmutableSet; import com.google.common.collect.Iterables; +import com.google.gerrit.exceptions.StorageException; import com.google.gerrit.index.IndexConfig; import com.google.gerrit.index.QueryOptions; import com.google.gerrit.index.query.DataSource; @@ -34,7 +35,6 @@ import com.google.gerrit.index.query.ResultSet; import com.google.gerrit.reviewdb.client.Change; import com.google.gerrit.server.query.change.ChangeData; import com.google.gerrit.server.query.change.ChangeDataSource; -import com.google.gwtorm.server.OrmException; import java.util.HashMap; import java.util.HashSet; import java.util.Iterator; @@ -81,7 +81,7 @@ public class IndexedChangeQuery extends IndexedQuery } @Override - public ResultSet read() throws OrmException { + public ResultSet read() throws StorageException { final DataSource currSource = source; final ResultSet rs = currSource.read(); @@ -114,7 +114,7 @@ public class IndexedChangeQuery extends IndexedQuery } @Override - public boolean match(ChangeData cd) throws OrmException { + public boolean match(ChangeData cd) throws StorageException { if (source != null && fromSource.get(cd) == source) { return true; } diff --git a/java/com/google/gerrit/server/index/change/ReindexAfterRefUpdate.java b/java/com/google/gerrit/server/index/change/ReindexAfterRefUpdate.java index 669bb1ea25..d75b9164c2 100644 --- a/java/com/google/gerrit/server/index/change/ReindexAfterRefUpdate.java +++ b/java/com/google/gerrit/server/index/change/ReindexAfterRefUpdate.java @@ -21,6 +21,7 @@ import com.google.common.flogger.FluentLogger; import com.google.common.util.concurrent.FutureCallback; import com.google.common.util.concurrent.Futures; import com.google.common.util.concurrent.ListeningExecutorService; +import com.google.gerrit.exceptions.StorageException; import com.google.gerrit.extensions.events.GitReferenceUpdatedListener; import com.google.gerrit.reviewdb.client.Account; import com.google.gerrit.reviewdb.client.Branch; @@ -39,7 +40,6 @@ import com.google.gerrit.server.query.change.InternalChangeQuery; import com.google.gerrit.server.util.ManualRequestContext; import com.google.gerrit.server.util.OneOffRequestContext; import com.google.gerrit.server.util.RequestContext; -import com.google.gwtorm.server.OrmException; import com.google.inject.Inject; import com.google.inject.Provider; import java.io.IOException; @@ -152,7 +152,7 @@ public class ReindexAfterRefUpdate implements GitReferenceUpdatedListener { } @Override - protected List impl(RequestContext ctx) throws OrmException { + protected List impl(RequestContext ctx) throws StorageException { String ref = event.getRefName(); Project.NameKey project = new Project.NameKey(event.getProjectName()); if (ref.equals(RefNames.REFS_CONFIG)) { @@ -179,7 +179,7 @@ public class ReindexAfterRefUpdate implements GitReferenceUpdatedListener { } @Override - protected Void impl(RequestContext ctx) throws OrmException, IOException { + protected Void impl(RequestContext ctx) throws StorageException, IOException { // Reload change, as some time may have passed since GetChanges. try { Change c = diff --git a/java/com/google/gerrit/server/mail/MailUtil.java b/java/com/google/gerrit/server/mail/MailUtil.java index 3a5a2cf4c7..0d54b444ad 100644 --- a/java/com/google/gerrit/server/mail/MailUtil.java +++ b/java/com/google/gerrit/server/mail/MailUtil.java @@ -18,11 +18,11 @@ import static com.google.gerrit.server.notedb.ReviewerStateInternal.CC; import static com.google.gerrit.server.notedb.ReviewerStateInternal.REVIEWER; import com.google.gerrit.common.FooterConstants; +import com.google.gerrit.exceptions.StorageException; import com.google.gerrit.extensions.restapi.UnprocessableEntityException; import com.google.gerrit.reviewdb.client.Account; import com.google.gerrit.server.ReviewerSet; import com.google.gerrit.server.account.AccountResolver; -import com.google.gwtorm.server.OrmException; import java.io.IOException; import java.util.Collections; import java.util.HashSet; @@ -37,7 +37,7 @@ public class MailUtil { public static MailRecipients getRecipientsFromFooters( AccountResolver accountResolver, List footerLines) - throws OrmException, IOException, ConfigInvalidException { + throws StorageException, IOException, ConfigInvalidException { MailRecipients recipients = new MailRecipients(); for (FooterLine footerLine : footerLines) { try { @@ -62,7 +62,7 @@ public class MailUtil { @SuppressWarnings("deprecation") private static Account.Id toAccountId(AccountResolver accountResolver, String nameOrEmail) - throws OrmException, UnprocessableEntityException, IOException, ConfigInvalidException { + throws StorageException, UnprocessableEntityException, IOException, ConfigInvalidException { return accountResolver.resolveByNameOrEmail(nameOrEmail).asUnique().getAccount().getId(); } diff --git a/java/com/google/gerrit/server/mail/receive/MailProcessor.java b/java/com/google/gerrit/server/mail/receive/MailProcessor.java index 39cd9c3c53..6ed9ba334d 100644 --- a/java/com/google/gerrit/server/mail/receive/MailProcessor.java +++ b/java/com/google/gerrit/server/mail/receive/MailProcessor.java @@ -19,6 +19,7 @@ import static java.util.stream.Collectors.toList; import com.google.common.base.Strings; import com.google.common.collect.ImmutableList; import com.google.common.flogger.FluentLogger; +import com.google.gerrit.exceptions.StorageException; import com.google.gerrit.extensions.client.Side; import com.google.gerrit.extensions.registration.DynamicItem; import com.google.gerrit.extensions.registration.DynamicMap; @@ -64,7 +65,6 @@ import com.google.gerrit.server.update.UpdateException; import com.google.gerrit.server.util.ManualRequestContext; import com.google.gerrit.server.util.OneOffRequestContext; import com.google.gerrit.server.util.time.TimeUtil; -import com.google.gwtorm.server.OrmException; import com.google.inject.Inject; import com.google.inject.Provider; import com.google.inject.Singleton; @@ -147,7 +147,7 @@ public class MailProcessor { } private void processImpl(BatchUpdate.Factory buf, MailMessage message) - throws OrmException, UpdateException, RestApiException, IOException { + throws StorageException, UpdateException, RestApiException, IOException { for (Extension filter : mailFilters) { if (!filter.getProvider().get().shouldProcessMessage(message)) { logger.atWarning().log( @@ -208,7 +208,7 @@ public class MailProcessor { private void persistComments( BatchUpdate.Factory buf, MailMessage message, MailMetadata metadata, Account.Id sender) - throws OrmException, UpdateException, RestApiException { + throws StorageException, UpdateException, RestApiException { try (ManualRequestContext ctx = oneOffRequestContext.openAs(sender)) { List changeDataList = queryProvider.get().byLegacyChangeId(new Change.Id(metadata.changeNumber)); @@ -283,11 +283,11 @@ public class MailProcessor { @Override public boolean updateChange(ChangeContext ctx) - throws OrmException, UnprocessableEntityException, PatchListNotAvailableException { + throws StorageException, UnprocessableEntityException, PatchListNotAvailableException { patchSet = psUtil.get(ctx.getNotes(), psId); notes = ctx.getNotes(); if (patchSet == null) { - throw new OrmException("patch set not found: " + psId); + throw new StorageException("patch set not found: " + psId); } changeMessage = generateChangeMessage(ctx); @@ -358,7 +358,7 @@ public class MailProcessor { } private PatchSet targetPatchSetForComment( - ChangeContext ctx, MailComment mailComment, PatchSet current) throws OrmException { + ChangeContext ctx, MailComment mailComment, PatchSet current) throws StorageException { if (mailComment.getInReplyTo() != null) { return psUtil.get( ctx.getNotes(), @@ -369,7 +369,7 @@ public class MailProcessor { private Comment persistentCommentFromMailComment( ChangeContext ctx, MailComment mailComment, PatchSet patchSetForComment) - throws OrmException, UnprocessableEntityException, PatchListNotAvailableException { + throws StorageException, UnprocessableEntityException, PatchListNotAvailableException { String fileName; // 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. @@ -412,7 +412,7 @@ public class MailProcessor { return "(" + numComments + (numComments > 1 ? " comments)" : " comment)"); } - private Set existingMessageIds(ChangeData cd) throws OrmException { + private Set existingMessageIds(ChangeData cd) throws StorageException { Set existingMessageIds = new HashSet<>(); cd.messages().stream() .forEach( diff --git a/java/com/google/gerrit/server/mail/send/AbandonedSender.java b/java/com/google/gerrit/server/mail/send/AbandonedSender.java index 947eb12a7b..c0954fc72b 100644 --- a/java/com/google/gerrit/server/mail/send/AbandonedSender.java +++ b/java/com/google/gerrit/server/mail/send/AbandonedSender.java @@ -15,10 +15,10 @@ package com.google.gerrit.server.mail.send; 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.Project; import com.google.gerrit.server.account.ProjectWatches.NotifyType; -import com.google.gwtorm.server.OrmException; import com.google.inject.Inject; import com.google.inject.assistedinject.Assisted; @@ -32,7 +32,7 @@ public class AbandonedSender extends ReplyToChangeSender { @Inject public AbandonedSender( EmailArguments ea, @Assisted Project.NameKey project, @Assisted Change.Id id) - throws OrmException { + throws StorageException { super(ea, "abandon", ChangeEmail.newChangeData(ea, project, id)); } diff --git a/java/com/google/gerrit/server/mail/send/AddReviewerSender.java b/java/com/google/gerrit/server/mail/send/AddReviewerSender.java index 405c159e0e..3d0446d1b7 100644 --- a/java/com/google/gerrit/server/mail/send/AddReviewerSender.java +++ b/java/com/google/gerrit/server/mail/send/AddReviewerSender.java @@ -15,9 +15,9 @@ package com.google.gerrit.server.mail.send; 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.Project; -import com.google.gwtorm.server.OrmException; import com.google.inject.Inject; import com.google.inject.assistedinject.Assisted; @@ -30,7 +30,7 @@ public class AddReviewerSender extends NewChangeSender { @Inject public AddReviewerSender( EmailArguments ea, @Assisted Project.NameKey project, @Assisted Change.Id id) - throws OrmException { + throws StorageException { super(ea, newChangeData(ea, project, id)); } diff --git a/java/com/google/gerrit/server/mail/send/ChangeEmail.java b/java/com/google/gerrit/server/mail/send/ChangeEmail.java index c06d41b62e..238db59516 100644 --- a/java/com/google/gerrit/server/mail/send/ChangeEmail.java +++ b/java/com/google/gerrit/server/mail/send/ChangeEmail.java @@ -19,6 +19,7 @@ import com.google.common.collect.ListMultimap; import com.google.common.flogger.FluentLogger; import com.google.gerrit.common.Nullable; 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.RecipientType; import com.google.gerrit.extensions.restapi.AuthException; @@ -43,7 +44,6 @@ import com.google.gerrit.server.permissions.GlobalPermission; import com.google.gerrit.server.permissions.PermissionBackendException; import com.google.gerrit.server.project.ProjectState; import com.google.gerrit.server.query.change.ChangeData; -import com.google.gwtorm.server.OrmException; import com.google.template.soy.data.SoyListData; import com.google.template.soy.data.SoyMapData; import java.io.IOException; @@ -84,7 +84,7 @@ public abstract class ChangeEmail extends NotificationEmail { protected Set authors; protected boolean emailOnlyAuthors; - protected ChangeEmail(EmailArguments ea, String mc, ChangeData cd) throws OrmException { + protected ChangeEmail(EmailArguments ea, String mc, ChangeData cd) throws StorageException { super(ea, mc, cd.change().getDest()); changeData = cd; change = cd.change(); @@ -150,7 +150,7 @@ public abstract class ChangeEmail extends NotificationEmail { if (patchSet == null) { try { patchSet = changeData.currentPatchSet(); - } catch (OrmException err) { + } catch (StorageException err) { patchSet = null; } } @@ -160,7 +160,7 @@ public abstract class ChangeEmail extends NotificationEmail { if (patchSetInfo == null) { try { patchSetInfo = args.patchSetInfoFactory.get(changeData.notes(), patchSet.getId()); - } catch (PatchSetInfoNotAvailableException | OrmException err) { + } catch (PatchSetInfoNotAvailableException | StorageException err) { patchSetInfo = null; } } @@ -169,7 +169,7 @@ public abstract class ChangeEmail extends NotificationEmail { try { stars = changeData.stars(); - } catch (OrmException e) { + } catch (StorageException e) { throw new EmailException("Failed to load stars for change " + change.getChangeId(), e); } @@ -190,7 +190,7 @@ public abstract class ChangeEmail extends NotificationEmail { addByEmail( RecipientType.CC, changeData.reviewersByEmail().byState(ReviewerStateInternal.REVIEWER)); - } catch (OrmException e) { + } catch (StorageException e) { throw new EmailException("Failed to add unregistered CCs " + change.getChangeId(), e); } } @@ -294,7 +294,7 @@ public abstract class ChangeEmail extends NotificationEmail { } else { try { ps = args.patchSetUtil.get(changeData.notes(), new PatchSet.Id(change.getId(), patchSetId)); - } catch (OrmException e) { + } catch (StorageException e) { throw new PatchListNotAvailableException("Failed to get patchSet"); } } @@ -344,7 +344,7 @@ public abstract class ChangeEmail extends NotificationEmail { @Override protected final Watchers getWatchers(NotifyType type, boolean includeWatchersFromNotifyConfig) - throws OrmException { + throws StorageException { if (!NotifyHandling.ALL.equals(notify.handling())) { return new Watchers(); } @@ -364,7 +364,7 @@ public abstract class ChangeEmail extends NotificationEmail { for (Account.Id id : changeData.reviewers().all()) { add(RecipientType.CC, id); } - } catch (OrmException err) { + } catch (StorageException err) { logger.atWarning().withCause(err).log("Cannot CC users that reviewed updated change"); } } @@ -380,7 +380,7 @@ public abstract class ChangeEmail extends NotificationEmail { for (Account.Id id : changeData.reviewers().byState(ReviewerStateInternal.REVIEWER)) { add(RecipientType.CC, id); } - } catch (OrmException err) { + } catch (StorageException err) { logger.atWarning().withCause(err).log("Cannot CC users that commented on updated change"); } } @@ -506,7 +506,7 @@ public abstract class ChangeEmail extends NotificationEmail { for (Account.Id who : changeData.reviewers().byState(state)) { reviewers.add(getNameEmailFor(who)); } - } catch (OrmException e) { + } catch (StorageException e) { logger.atWarning().withCause(e).log("Cannot get change reviewers"); } return reviewers; diff --git a/java/com/google/gerrit/server/mail/send/CommentSender.java b/java/com/google/gerrit/server/mail/send/CommentSender.java index 532158c9cb..5e1e9d977c 100644 --- a/java/com/google/gerrit/server/mail/send/CommentSender.java +++ b/java/com/google/gerrit/server/mail/send/CommentSender.java @@ -22,6 +22,7 @@ import com.google.common.flogger.FluentLogger; import com.google.gerrit.common.data.FilenameComparator; import com.google.gerrit.exceptions.EmailException; import com.google.gerrit.exceptions.NoSuchEntityException; +import com.google.gerrit.exceptions.StorageException; import com.google.gerrit.extensions.api.changes.NotifyHandling; import com.google.gerrit.mail.MailHeader; import com.google.gerrit.mail.MailProcessingUtil; @@ -41,7 +42,6 @@ import com.google.gerrit.server.patch.PatchListNotAvailableException; import com.google.gerrit.server.patch.PatchListObjectTooLargeException; import com.google.gerrit.server.util.LabelVote; import com.google.gwtorm.client.KeyUtil; -import com.google.gwtorm.server.OrmException; import com.google.inject.Inject; import com.google.inject.assistedinject.Assisted; import java.io.IOException; @@ -120,7 +120,7 @@ public class CommentSender extends ReplyToChangeSender { @GerritServerConfig Config cfg, @Assisted Project.NameKey project, @Assisted Change.Id id) - throws OrmException { + throws StorageException { super(ea, "comment", newChangeData(ea, project, id)); this.commentsUtil = commentsUtil; this.incomingEmailEnabled = @@ -129,7 +129,7 @@ public class CommentSender extends ReplyToChangeSender { this.replyToAddress = cfg.getString("sendemail", null, "replyToAddress"); } - public void setComments(List comments) throws OrmException { + public void setComments(List comments) throws StorageException { inlineComments = comments; Set paths = new HashSet<>(); @@ -316,7 +316,7 @@ public class CommentSender extends ReplyToChangeSender { Comment.Key key = new Comment.Key(child.parentUuid, child.key.filename, child.key.patchSetId); try { return commentsUtil.getPublished(changeData.notes(), key); - } catch (OrmException e) { + } catch (StorageException e) { logger.atWarning().log("Could not find the parent of this comment: %s", child); return Optional.empty(); } diff --git a/java/com/google/gerrit/server/mail/send/CreateChangeSender.java b/java/com/google/gerrit/server/mail/send/CreateChangeSender.java index f12c8f1b14..5fb4bad375 100644 --- a/java/com/google/gerrit/server/mail/send/CreateChangeSender.java +++ b/java/com/google/gerrit/server/mail/send/CreateChangeSender.java @@ -16,6 +16,7 @@ package com.google.gerrit.server.mail.send; import com.google.common.flogger.FluentLogger; import com.google.gerrit.exceptions.EmailException; +import com.google.gerrit.exceptions.StorageException; import com.google.gerrit.extensions.api.changes.RecipientType; import com.google.gerrit.reviewdb.client.Account; import com.google.gerrit.reviewdb.client.Change; @@ -24,7 +25,6 @@ import com.google.gerrit.server.account.ProjectWatches.NotifyType; import com.google.gerrit.server.mail.send.ProjectWatch.Watchers; import com.google.gerrit.server.permissions.PermissionBackend; import com.google.gerrit.server.permissions.RefPermission; -import com.google.gwtorm.server.OrmException; import com.google.inject.Inject; import com.google.inject.assistedinject.Assisted; import java.util.stream.StreamSupport; @@ -45,7 +45,7 @@ public class CreateChangeSender extends NewChangeSender { PermissionBackend permissionBackend, @Assisted Project.NameKey project, @Assisted Change.Id id) - throws OrmException { + throws StorageException { super(ea, newChangeData(ea, project, id)); this.permissionBackend = permissionBackend; } @@ -66,7 +66,7 @@ public class CreateChangeSender extends NewChangeSender { add(RecipientType.TO, matching.to); add(RecipientType.CC, matching.cc); add(RecipientType.BCC, matching.bcc); - } catch (OrmException err) { + } catch (StorageException err) { // Just don't CC everyone. Better to send a partial message to those // we already have queued up then to fail deliver entirely to people // who have a lower interest in the change. diff --git a/java/com/google/gerrit/server/mail/send/DeleteReviewerSender.java b/java/com/google/gerrit/server/mail/send/DeleteReviewerSender.java index e1b3577b73..40141d8261 100644 --- a/java/com/google/gerrit/server/mail/send/DeleteReviewerSender.java +++ b/java/com/google/gerrit/server/mail/send/DeleteReviewerSender.java @@ -15,13 +15,13 @@ package com.google.gerrit.server.mail.send; import com.google.gerrit.exceptions.EmailException; +import com.google.gerrit.exceptions.StorageException; import com.google.gerrit.extensions.api.changes.RecipientType; import com.google.gerrit.mail.Address; import com.google.gerrit.reviewdb.client.Account; import com.google.gerrit.reviewdb.client.Change; import com.google.gerrit.reviewdb.client.Project; import com.google.gerrit.server.account.ProjectWatches.NotifyType; -import com.google.gwtorm.server.OrmException; import com.google.inject.Inject; import com.google.inject.assistedinject.Assisted; import java.util.ArrayList; @@ -43,7 +43,7 @@ public class DeleteReviewerSender extends ReplyToChangeSender { @Inject public DeleteReviewerSender( EmailArguments ea, @Assisted Project.NameKey project, @Assisted Change.Id id) - throws OrmException { + throws StorageException { super(ea, "deleteReviewer", newChangeData(ea, project, id)); } diff --git a/java/com/google/gerrit/server/mail/send/DeleteVoteSender.java b/java/com/google/gerrit/server/mail/send/DeleteVoteSender.java index 7176803a04..39aa154951 100644 --- a/java/com/google/gerrit/server/mail/send/DeleteVoteSender.java +++ b/java/com/google/gerrit/server/mail/send/DeleteVoteSender.java @@ -15,10 +15,10 @@ package com.google.gerrit.server.mail.send; 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.Project; import com.google.gerrit.server.account.ProjectWatches.NotifyType; -import com.google.gwtorm.server.OrmException; import com.google.inject.Inject; import com.google.inject.assistedinject.Assisted; @@ -32,7 +32,7 @@ public class DeleteVoteSender extends ReplyToChangeSender { @Inject protected DeleteVoteSender( EmailArguments ea, @Assisted Project.NameKey project, @Assisted Change.Id id) - throws OrmException { + throws StorageException { super(ea, "deleteVote", newChangeData(ea, project, id)); } diff --git a/java/com/google/gerrit/server/mail/send/MergedSender.java b/java/com/google/gerrit/server/mail/send/MergedSender.java index aac4005746..45ed84ee5d 100644 --- a/java/com/google/gerrit/server/mail/send/MergedSender.java +++ b/java/com/google/gerrit/server/mail/send/MergedSender.java @@ -20,12 +20,12 @@ import com.google.gerrit.common.data.LabelType; import com.google.gerrit.common.data.LabelTypes; import com.google.gerrit.common.data.LabelValue; import com.google.gerrit.exceptions.EmailException; +import com.google.gerrit.exceptions.StorageException; import com.google.gerrit.reviewdb.client.Account; import com.google.gerrit.reviewdb.client.Change; import com.google.gerrit.reviewdb.client.PatchSetApproval; import com.google.gerrit.reviewdb.client.Project; import com.google.gerrit.server.account.ProjectWatches.NotifyType; -import com.google.gwtorm.server.OrmException; import com.google.inject.Inject; import com.google.inject.assistedinject.Assisted; @@ -39,7 +39,7 @@ public class MergedSender extends ReplyToChangeSender { @Inject public MergedSender(EmailArguments ea, @Assisted Project.NameKey project, @Assisted Change.Id id) - throws OrmException { + throws StorageException { super(ea, "merged", newChangeData(ea, project, id)); labelTypes = changeData.getLabelTypes(); } @@ -82,7 +82,7 @@ public class MergedSender extends ReplyToChangeSender { } return format("Approvals", pos) + format("Objections", neg); - } catch (OrmException err) { + } catch (StorageException err) { // Don't list the approvals } return ""; diff --git a/java/com/google/gerrit/server/mail/send/NewChangeSender.java b/java/com/google/gerrit/server/mail/send/NewChangeSender.java index 3c779ec222..571db6621e 100644 --- a/java/com/google/gerrit/server/mail/send/NewChangeSender.java +++ b/java/com/google/gerrit/server/mail/send/NewChangeSender.java @@ -15,11 +15,11 @@ package com.google.gerrit.server.mail.send; import com.google.gerrit.exceptions.EmailException; +import com.google.gerrit.exceptions.StorageException; import com.google.gerrit.extensions.api.changes.RecipientType; import com.google.gerrit.mail.Address; import com.google.gerrit.reviewdb.client.Account; import com.google.gerrit.server.query.change.ChangeData; -import com.google.gwtorm.server.OrmException; import java.util.ArrayList; import java.util.Collection; import java.util.HashSet; @@ -33,7 +33,7 @@ public abstract class NewChangeSender extends ChangeEmail { private final Set extraCC = new HashSet<>(); private final Set

extraCCByEmail = new HashSet<>(); - protected NewChangeSender(EmailArguments ea, ChangeData cd) throws OrmException { + protected NewChangeSender(EmailArguments ea, ChangeData cd) throws StorageException { super(ea, "newchange", cd); } diff --git a/java/com/google/gerrit/server/mail/send/NotificationEmail.java b/java/com/google/gerrit/server/mail/send/NotificationEmail.java index 1187a420f9..1d8009bcd3 100644 --- a/java/com/google/gerrit/server/mail/send/NotificationEmail.java +++ b/java/com/google/gerrit/server/mail/send/NotificationEmail.java @@ -18,6 +18,7 @@ import com.google.common.annotations.VisibleForTesting; import com.google.common.collect.Iterables; import com.google.common.flogger.FluentLogger; import com.google.gerrit.exceptions.EmailException; +import com.google.gerrit.exceptions.StorageException; import com.google.gerrit.extensions.api.changes.RecipientType; import com.google.gerrit.mail.Address; import com.google.gerrit.mail.MailHeader; @@ -25,7 +26,6 @@ import com.google.gerrit.reviewdb.client.Account; import com.google.gerrit.reviewdb.client.Branch; import com.google.gerrit.server.account.ProjectWatches.NotifyType; import com.google.gerrit.server.mail.send.ProjectWatch.Watchers; -import com.google.gwtorm.server.OrmException; import java.util.HashMap; import java.util.Map; @@ -68,7 +68,7 @@ public abstract class NotificationEmail extends OutgoingEmail { add(RecipientType.TO, matching.to); add(RecipientType.CC, matching.cc); add(RecipientType.BCC, matching.bcc); - } catch (OrmException err) { + } catch (StorageException err) { // Just don't CC everyone. Better to send a partial message to those // we already have queued up then to fail deliver entirely to people // who have a lower interest in the change. @@ -78,7 +78,7 @@ public abstract class NotificationEmail extends OutgoingEmail { /** Returns all watchers that are relevant */ protected abstract Watchers getWatchers(NotifyType type, boolean includeWatchersFromNotifyConfig) - throws OrmException; + throws StorageException; /** Add users or email addresses to the TO, CC, or BCC list. */ protected void add(RecipientType type, Watchers.List list) { diff --git a/java/com/google/gerrit/server/mail/send/ProjectWatch.java b/java/com/google/gerrit/server/mail/send/ProjectWatch.java index 9a86fdb218..890f6fb161 100644 --- a/java/com/google/gerrit/server/mail/send/ProjectWatch.java +++ b/java/com/google/gerrit/server/mail/send/ProjectWatch.java @@ -19,6 +19,7 @@ import com.google.common.collect.ImmutableSet; import com.google.common.flogger.FluentLogger; import com.google.gerrit.common.data.GroupDescription; 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.QueryParseException; import com.google.gerrit.mail.Address; @@ -35,7 +36,6 @@ import com.google.gerrit.server.project.ProjectState; import com.google.gerrit.server.query.change.ChangeData; import com.google.gerrit.server.query.change.ChangeQueryBuilder; import com.google.gerrit.server.query.change.SingleGroupUser; -import com.google.gwtorm.server.OrmException; import java.util.ArrayList; import java.util.HashSet; import java.util.List; @@ -63,7 +63,7 @@ public class ProjectWatch { /** Returns all watchers that are relevant */ public final Watchers getWatchers(NotifyType type, boolean includeWatchersFromNotifyConfig) - throws OrmException { + throws StorageException { Watchers matching = new Watchers(); Set projectWatchers = new HashSet<>(); @@ -148,7 +148,8 @@ public class ProjectWatch { } } - private void add(Watchers matching, NotifyConfig nc) throws OrmException, QueryParseException { + private void add(Watchers matching, NotifyConfig nc) + throws StorageException, QueryParseException { for (GroupReference ref : nc.getGroups()) { CurrentUser user = new SingleGroupUser(ref.getUUID()); if (filterMatch(user, nc.getFilter())) { @@ -203,7 +204,7 @@ public class ProjectWatch { ProjectWatchKey key, Set watchedTypes, NotifyType type) - throws OrmException { + throws StorageException { IdentifiedUser user = args.identifiedUserFactory.create(accountId); try { @@ -222,7 +223,7 @@ public class ProjectWatch { } private boolean filterMatch(CurrentUser user, String filter) - throws OrmException, QueryParseException { + throws StorageException, QueryParseException { ChangeQueryBuilder qb; Predicate p = null; diff --git a/java/com/google/gerrit/server/mail/send/ReplacePatchSetSender.java b/java/com/google/gerrit/server/mail/send/ReplacePatchSetSender.java index f7b3b79dc9..f8765580b9 100644 --- a/java/com/google/gerrit/server/mail/send/ReplacePatchSetSender.java +++ b/java/com/google/gerrit/server/mail/send/ReplacePatchSetSender.java @@ -15,13 +15,13 @@ package com.google.gerrit.server.mail.send; 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.RecipientType; import com.google.gerrit.reviewdb.client.Account; import com.google.gerrit.reviewdb.client.Change; import com.google.gerrit.reviewdb.client.Project; import com.google.gerrit.server.account.ProjectWatches.NotifyType; -import com.google.gwtorm.server.OrmException; import com.google.inject.Inject; import com.google.inject.assistedinject.Assisted; import java.util.ArrayList; @@ -42,7 +42,7 @@ public class ReplacePatchSetSender extends ReplyToChangeSender { @Inject public ReplacePatchSetSender( EmailArguments ea, @Assisted Project.NameKey project, @Assisted Change.Id id) - throws OrmException { + throws StorageException { super(ea, "newpatchset", newChangeData(ea, project, id)); } diff --git a/java/com/google/gerrit/server/mail/send/ReplyToChangeSender.java b/java/com/google/gerrit/server/mail/send/ReplyToChangeSender.java index 88bc5b2b04..2af8cd76ce 100644 --- a/java/com/google/gerrit/server/mail/send/ReplyToChangeSender.java +++ b/java/com/google/gerrit/server/mail/send/ReplyToChangeSender.java @@ -15,11 +15,11 @@ package com.google.gerrit.server.mail.send; import com.google.gerrit.exceptions.EmailException; +import com.google.gerrit.exceptions.StorageException; import com.google.gerrit.extensions.api.changes.RecipientType; import com.google.gerrit.reviewdb.client.Change; import com.google.gerrit.reviewdb.client.Project; import com.google.gerrit.server.query.change.ChangeData; -import com.google.gwtorm.server.OrmException; /** Alert a user to a reply to a change, usually commentary made during review. */ public abstract class ReplyToChangeSender extends ChangeEmail { @@ -27,7 +27,8 @@ public abstract class ReplyToChangeSender extends ChangeEmail { T create(Project.NameKey project, Change.Id id); } - protected ReplyToChangeSender(EmailArguments ea, String mc, ChangeData cd) throws OrmException { + protected ReplyToChangeSender(EmailArguments ea, String mc, ChangeData cd) + throws StorageException { super(ea, mc, cd); } diff --git a/java/com/google/gerrit/server/mail/send/RestoredSender.java b/java/com/google/gerrit/server/mail/send/RestoredSender.java index f9d856db0a..2533b71da9 100644 --- a/java/com/google/gerrit/server/mail/send/RestoredSender.java +++ b/java/com/google/gerrit/server/mail/send/RestoredSender.java @@ -15,10 +15,10 @@ package com.google.gerrit.server.mail.send; 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.Project; import com.google.gerrit.server.account.ProjectWatches.NotifyType; -import com.google.gwtorm.server.OrmException; import com.google.inject.Inject; import com.google.inject.assistedinject.Assisted; @@ -32,7 +32,7 @@ public class RestoredSender extends ReplyToChangeSender { @Inject public RestoredSender( EmailArguments ea, @Assisted Project.NameKey project, @Assisted Change.Id id) - throws OrmException { + throws StorageException { super(ea, "restore", ChangeEmail.newChangeData(ea, project, id)); } diff --git a/java/com/google/gerrit/server/mail/send/RevertedSender.java b/java/com/google/gerrit/server/mail/send/RevertedSender.java index 41a5c5bc90..d7691795ba 100644 --- a/java/com/google/gerrit/server/mail/send/RevertedSender.java +++ b/java/com/google/gerrit/server/mail/send/RevertedSender.java @@ -15,10 +15,10 @@ package com.google.gerrit.server.mail.send; 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.Project; import com.google.gerrit.server.account.ProjectWatches.NotifyType; -import com.google.gwtorm.server.OrmException; import com.google.inject.Inject; import com.google.inject.assistedinject.Assisted; @@ -31,7 +31,7 @@ public class RevertedSender extends ReplyToChangeSender { @Inject public RevertedSender( EmailArguments ea, @Assisted Project.NameKey project, @Assisted Change.Id id) - throws OrmException { + throws StorageException { super(ea, "revert", ChangeEmail.newChangeData(ea, project, id)); } diff --git a/java/com/google/gerrit/server/mail/send/SetAssigneeSender.java b/java/com/google/gerrit/server/mail/send/SetAssigneeSender.java index 6c23750ac6..951ac45f2e 100644 --- a/java/com/google/gerrit/server/mail/send/SetAssigneeSender.java +++ b/java/com/google/gerrit/server/mail/send/SetAssigneeSender.java @@ -15,11 +15,11 @@ package com.google.gerrit.server.mail.send; import com.google.gerrit.exceptions.EmailException; +import com.google.gerrit.exceptions.StorageException; import com.google.gerrit.extensions.api.changes.RecipientType; import com.google.gerrit.reviewdb.client.Account; import com.google.gerrit.reviewdb.client.Change; import com.google.gerrit.reviewdb.client.Project; -import com.google.gwtorm.server.OrmException; import com.google.inject.Inject; import com.google.inject.assistedinject.Assisted; @@ -36,7 +36,7 @@ public class SetAssigneeSender extends ChangeEmail { @Assisted Project.NameKey project, @Assisted Change.Id id, @Assisted Account.Id assignee) - throws OrmException { + throws StorageException { super(ea, "setassignee", newChangeData(ea, project, id)); this.assignee = assignee; } diff --git a/java/com/google/gerrit/server/notedb/AbstractChangeNotes.java b/java/com/google/gerrit/server/notedb/AbstractChangeNotes.java index cecbbe8c44..438b7315c1 100644 --- a/java/com/google/gerrit/server/notedb/AbstractChangeNotes.java +++ b/java/com/google/gerrit/server/notedb/AbstractChangeNotes.java @@ -20,6 +20,7 @@ import static java.util.Objects.requireNonNull; import com.google.common.annotations.VisibleForTesting; import com.google.gerrit.common.Nullable; import com.google.gerrit.common.UsedAt; +import com.google.gerrit.exceptions.StorageException; import com.google.gerrit.metrics.Timer1; import com.google.gerrit.reviewdb.client.Change; import com.google.gerrit.reviewdb.client.Project; @@ -27,7 +28,6 @@ import com.google.gerrit.server.config.AllUsersName; import com.google.gerrit.server.git.GitRepositoryManager; import com.google.gerrit.server.notedb.ChangeNotesCommit.ChangeNotesRevWalk; import com.google.gerrit.server.project.NoSuchChangeException; -import com.google.gwtorm.server.OrmException; import com.google.inject.Inject; import com.google.inject.Provider; import com.google.inject.Singleton; @@ -131,13 +131,13 @@ public abstract class AbstractChangeNotes { return revision; } - public T load() throws OrmException { + public T load() throws StorageException { if (loaded) { return self(); } if (args.failOnLoadForTest.get()) { - throw new OrmException("Reading from NoteDb is disabled"); + throw new StorageException("Reading from NoteDb is disabled"); } try (Timer1.Context timer = args.metrics.readLatency.start(CHANGES); Repository repo = args.repoManager.openRepository(getProjectName()); @@ -148,7 +148,7 @@ public abstract class AbstractChangeNotes { onLoad(handle); loaded = true; } catch (ConfigInvalidException | IOException e) { - throw new OrmException(e); + throw new StorageException(e); } return self(); } @@ -176,12 +176,12 @@ public abstract class AbstractChangeNotes { return new LoadHandle(repo, id); } - public T reload() throws OrmException { + public T reload() throws StorageException { loaded = false; return load(); } - public ObjectId loadRevision() throws OrmException { + public ObjectId loadRevision() throws StorageException { if (loaded) { return getRevision(); } @@ -189,7 +189,7 @@ public abstract class AbstractChangeNotes { Ref ref = repo.getRefDatabase().exactRef(getRefName()); return ref != null ? ref.getObjectId() : null; } catch (IOException e) { - throw new OrmException(e); + throw new StorageException(e); } } diff --git a/java/com/google/gerrit/server/notedb/AbstractChangeUpdate.java b/java/com/google/gerrit/server/notedb/AbstractChangeUpdate.java index daac83f857..b190cbba4b 100644 --- a/java/com/google/gerrit/server/notedb/AbstractChangeUpdate.java +++ b/java/com/google/gerrit/server/notedb/AbstractChangeUpdate.java @@ -19,6 +19,7 @@ import static com.google.common.base.Preconditions.checkState; import com.google.common.flogger.FluentLogger; 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.Change; import com.google.gerrit.reviewdb.client.Comment; @@ -27,7 +28,6 @@ import com.google.gerrit.reviewdb.client.Project; import com.google.gerrit.server.CurrentUser; import com.google.gerrit.server.IdentifiedUser; import com.google.gerrit.server.InternalUser; -import com.google.gwtorm.server.OrmException; import java.io.IOException; import java.util.Date; import org.eclipse.jgit.lib.CommitBuilder; @@ -194,11 +194,11 @@ public abstract class AbstractChangeUpdate { * @return commit ID produced by inserting this update's commit, or null if this update is a no-op * and should be skipped. The zero ID is a valid return value, and indicates the ref should be * deleted. - * @throws OrmException if a Gerrit-level error occurred. + * @throws StorageException if a Gerrit-level error occurred. * @throws IOException if a lower-level error occurred. */ final ObjectId apply(RevWalk rw, ObjectInserter ins, ObjectId curr) - throws OrmException, IOException { + throws StorageException, IOException { if (isEmpty()) { return null; } @@ -246,11 +246,11 @@ public abstract class AbstractChangeUpdate { * indicates to the caller that it should be copied from the parent commit. To indicate that * this update is a no-op (but this could not be determined by {@link #isEmpty()}), return the * sentinel {@link #NO_OP_UPDATE}. - * @throws OrmException if a Gerrit-level error occurred. + * @throws StorageException if a Gerrit-level error occurred. * @throws IOException if a lower-level error occurred. */ protected abstract CommitBuilder applyImpl(RevWalk rw, ObjectInserter ins, ObjectId curr) - throws OrmException, IOException; + throws StorageException, IOException; protected static final CommitBuilder NO_OP_UPDATE = new CommitBuilder(); diff --git a/java/com/google/gerrit/server/notedb/ChangeDraftUpdate.java b/java/com/google/gerrit/server/notedb/ChangeDraftUpdate.java index 5a3ebd6769..2ff27eb28a 100644 --- a/java/com/google/gerrit/server/notedb/ChangeDraftUpdate.java +++ b/java/com/google/gerrit/server/notedb/ChangeDraftUpdate.java @@ -19,6 +19,7 @@ import static org.eclipse.jgit.lib.Constants.OBJ_BLOB; import com.google.auto.value.AutoValue; import com.google.common.collect.Sets; +import com.google.gerrit.exceptions.StorageException; import com.google.gerrit.reviewdb.client.Account; import com.google.gerrit.reviewdb.client.Change; import com.google.gerrit.reviewdb.client.Comment; @@ -28,7 +29,6 @@ import com.google.gerrit.reviewdb.client.RefNames; import com.google.gerrit.reviewdb.client.RevId; import com.google.gerrit.server.GerritPersonIdent; import com.google.gerrit.server.config.AllUsersName; -import com.google.gwtorm.server.OrmException; import com.google.inject.assistedinject.Assisted; import com.google.inject.assistedinject.AssistedInject; import java.io.IOException; @@ -132,7 +132,7 @@ public class ChangeDraftUpdate extends AbstractChangeUpdate { private CommitBuilder storeCommentsInNotes( RevWalk rw, ObjectInserter ins, ObjectId curr, CommitBuilder cb) - throws ConfigInvalidException, OrmException, IOException { + throws ConfigInvalidException, StorageException, IOException { RevisionNoteMap rnm = getRevisionNoteMap(rw, curr); Set updatedRevs = Sets.newHashSetWithExpectedSize(rnm.revisionNotes.size()); RevisionNoteBuilder.Cache cache = new RevisionNoteBuilder.Cache(rnm); @@ -184,7 +184,7 @@ public class ChangeDraftUpdate extends AbstractChangeUpdate { } private RevisionNoteMap getRevisionNoteMap(RevWalk rw, ObjectId curr) - throws ConfigInvalidException, OrmException, IOException { + throws ConfigInvalidException, StorageException, IOException { // The old DraftCommentNotes already parsed the revision notes. We can reuse them as long as // the ref hasn't advanced. ChangeNotes changeNotes = getNotes(); @@ -217,13 +217,13 @@ public class ChangeDraftUpdate extends AbstractChangeUpdate { @Override protected CommitBuilder applyImpl(RevWalk rw, ObjectInserter ins, ObjectId curr) - throws OrmException, IOException { + throws StorageException, IOException { CommitBuilder cb = new CommitBuilder(); cb.setMessage("Update draft comments"); try { return storeCommentsInNotes(rw, ins, curr, cb); } catch (ConfigInvalidException e) { - throw new OrmException(e); + throw new StorageException(e); } } diff --git a/java/com/google/gerrit/server/notedb/ChangeNotes.java b/java/com/google/gerrit/server/notedb/ChangeNotes.java index af856610ed..08cb7da396 100644 --- a/java/com/google/gerrit/server/notedb/ChangeNotes.java +++ b/java/com/google/gerrit/server/notedb/ChangeNotes.java @@ -36,6 +36,7 @@ import com.google.common.collect.Sets.SetView; import com.google.common.flogger.FluentLogger; import com.google.gerrit.common.Nullable; import com.google.gerrit.common.data.SubmitRecord; +import com.google.gerrit.exceptions.StorageException; import com.google.gerrit.reviewdb.client.Account; import com.google.gerrit.reviewdb.client.Branch; import com.google.gerrit.reviewdb.client.Change; @@ -55,7 +56,6 @@ import com.google.gerrit.server.project.NoSuchChangeException; import com.google.gerrit.server.project.ProjectCache; import com.google.gerrit.server.query.change.ChangeData; import com.google.gerrit.server.query.change.InternalChangeQuery; -import com.google.gwtorm.server.OrmException; import com.google.inject.Inject; import com.google.inject.Provider; import com.google.inject.Singleton; @@ -103,17 +103,17 @@ public class ChangeNotes extends AbstractChangeNotes { this.projectCache = projectCache; } - public ChangeNotes createChecked(Change c) throws OrmException { + public ChangeNotes createChecked(Change c) throws StorageException { return createChecked(c.getProject(), c.getId()); } public ChangeNotes createChecked(Project.NameKey project, Change.Id changeId) - throws OrmException { + throws StorageException { Change change = newChange(project, changeId); return new ChangeNotes(args, change, true, null).load(); } - public ChangeNotes createChecked(Change.Id changeId) throws OrmException { + public ChangeNotes createChecked(Change.Id changeId) throws StorageException { InternalChangeQuery query = queryProvider.get().noFields(); List changes = query.byLegacyChangeId(changeId); if (changes.isEmpty()) { @@ -131,7 +131,7 @@ public class ChangeNotes extends AbstractChangeNotes { null, changeId, null, new Branch.NameKey(project, "INVALID_NOTE_DB_ONLY"), null); } - public ChangeNotes create(Project.NameKey project, Change.Id changeId) throws OrmException { + public ChangeNotes create(Project.NameKey project, Change.Id changeId) throws StorageException { checkArgument(project != null, "project is required"); return new ChangeNotes(args, newChange(project, changeId), true, null).load(); } @@ -148,15 +148,15 @@ public class ChangeNotes extends AbstractChangeNotes { } public ChangeNotes createForBatchUpdate(Change change, boolean shouldExist) - throws OrmException { + throws StorageException { return new ChangeNotes(args, change, shouldExist, null).load(); } - public ChangeNotes create(Change change, RefCache refs) throws OrmException { + public ChangeNotes create(Change change, RefCache refs) throws StorageException { return new ChangeNotes(args, change, true, refs).load(); } - public List create(Collection changeIds) throws OrmException { + public List create(Collection changeIds) throws StorageException { List notes = new ArrayList<>(); for (Change.Id changeId : changeIds) { try { @@ -170,7 +170,7 @@ public class ChangeNotes extends AbstractChangeNotes { public List create( Project.NameKey project, Collection changeIds, Predicate predicate) - throws OrmException { + throws StorageException { List notes = new ArrayList<>(); for (Change.Id cid : changeIds) { try { @@ -229,7 +229,7 @@ public class ChangeNotes extends AbstractChangeNotes { ChangeNotes n = new ChangeNotes(args, rawChangeFromNoteDb, true, null); try { n.load(); - } catch (OrmException e) { + } catch (StorageException e) { return ChangeNotesResult.error(n.getChangeId(), e); } return ChangeNotesResult.notes(n); @@ -238,7 +238,7 @@ public class ChangeNotes extends AbstractChangeNotes { /** Result of {@link #scan(Repository,Project.NameKey)}. */ @AutoValue public abstract static class ChangeNotesResult { - static ChangeNotesResult error(Change.Id id, OrmException e) { + static ChangeNotesResult error(Change.Id id, StorageException e) { return new AutoValue_ChangeNotes_Factory_ChangeNotesResult(id, Optional.of(e), null); } @@ -251,7 +251,7 @@ public class ChangeNotes extends AbstractChangeNotes { public abstract Change.Id id(); /** Error encountered while loading this change, if any. */ - public abstract Optional error(); + public abstract Optional error(); /** * Notes loaded for this change. @@ -420,12 +420,12 @@ public class ChangeNotes extends AbstractChangeNotes { } public ImmutableListMultimap getDraftComments(Account.Id author) - throws OrmException { + throws StorageException { return getDraftComments(author, null); } public ImmutableListMultimap getDraftComments( - Account.Id author, @Nullable Ref ref) throws OrmException { + Account.Id author, @Nullable Ref ref) throws StorageException { loadDraftComments(author, ref); // Filter out any zombie draft comments. These are drafts that are also in // the published map, and arise when the update to All-Users to delete them @@ -435,7 +435,7 @@ public class ChangeNotes extends AbstractChangeNotes { draftCommentNotes.getComments(), e -> !getCommentKeys().contains(e.getValue().key))); } - public ImmutableListMultimap getRobotComments() throws OrmException { + public ImmutableListMultimap getRobotComments() throws StorageException { loadRobotComments(); return robotCommentNotes.getComments(); } @@ -445,14 +445,14 @@ public class ChangeNotes extends AbstractChangeNotes { * However, this method will load the comments if no draft comments have been loaded or if the * caller would like the drafts for another author. */ - private void loadDraftComments(Account.Id author, @Nullable Ref ref) throws OrmException { + private void loadDraftComments(Account.Id author, @Nullable Ref ref) throws StorageException { if (draftCommentNotes == null || !author.equals(draftCommentNotes.getAuthor()) || ref != null) { draftCommentNotes = new DraftCommentNotes(args, getChangeId(), author, ref); draftCommentNotes.load(); } } - private void loadRobotComments() throws OrmException { + private void loadRobotComments() throws StorageException { if (robotCommentNotes == null) { robotCommentNotes = new RobotCommentNotes(args, change); robotCommentNotes.load(); @@ -468,7 +468,7 @@ public class ChangeNotes extends AbstractChangeNotes { return robotCommentNotes; } - public boolean containsComment(Comment c) throws OrmException { + public boolean containsComment(Comment c) throws StorageException { if (containsCommentPublished(c)) { return true; } diff --git a/java/com/google/gerrit/server/notedb/ChangeUpdate.java b/java/com/google/gerrit/server/notedb/ChangeUpdate.java index ad0f8ef23d..2960b7bf76 100644 --- a/java/com/google/gerrit/server/notedb/ChangeUpdate.java +++ b/java/com/google/gerrit/server/notedb/ChangeUpdate.java @@ -50,6 +50,7 @@ import com.google.common.collect.ImmutableList; import com.google.common.collect.Table; import com.google.common.collect.TreeBasedTable; import com.google.gerrit.common.data.SubmitRecord; +import com.google.gerrit.exceptions.StorageException; import com.google.gerrit.mail.Address; import com.google.gerrit.reviewdb.client.Account; import com.google.gerrit.reviewdb.client.Change; @@ -64,7 +65,6 @@ import com.google.gerrit.server.logging.RequestId; import com.google.gerrit.server.project.ProjectCache; import com.google.gerrit.server.util.LabelVote; import com.google.gwtorm.client.IntKey; -import com.google.gwtorm.server.OrmException; import com.google.inject.assistedinject.Assisted; import com.google.inject.assistedinject.AssistedInject; import java.io.IOException; @@ -196,7 +196,7 @@ public class ChangeUpdate extends AbstractChangeUpdate { this.approvals = approvals(labelNameComparator); } - public ObjectId commit() throws IOException, OrmException { + public ObjectId commit() throws IOException, StorageException { try (NoteDbUpdateManager updateManager = updateManagerFactory.create(getProjectName())) { updateManager.add(this); updateManager.execute(); @@ -429,7 +429,7 @@ public class ChangeUpdate extends AbstractChangeUpdate { /** @return the tree id for the updated tree */ private ObjectId storeRevisionNotes(RevWalk rw, ObjectInserter inserter, ObjectId curr) - throws ConfigInvalidException, OrmException, IOException { + throws ConfigInvalidException, StorageException, IOException { if (comments.isEmpty() && pushCert == null) { return null; } @@ -456,7 +456,7 @@ public class ChangeUpdate extends AbstractChangeUpdate { } private RevisionNoteMap getRevisionNoteMap(RevWalk rw, ObjectId curr) - throws ConfigInvalidException, OrmException, IOException { + throws ConfigInvalidException, StorageException, IOException { if (curr.equals(ObjectId.zeroId())) { return RevisionNoteMap.emptyMap(); } @@ -483,7 +483,7 @@ public class ChangeUpdate extends AbstractChangeUpdate { private void checkComments( Map existingNotes, Map toUpdate) - throws OrmException { + throws StorageException { // Prohibit various kinds of illegal operations on comments. Set existing = new HashSet<>(); for (ChangeRevisionNote rn : existingNotes.values()) { @@ -513,7 +513,7 @@ public class ChangeUpdate extends AbstractChangeUpdate { for (RevisionNoteBuilder b : toUpdate.values()) { for (Comment c : b.put.values()) { if (existing.contains(c.key)) { - throw new OrmException("Cannot update existing published comment: " + c); + throw new StorageException("Cannot update existing published comment: " + c); } } } @@ -526,7 +526,7 @@ public class ChangeUpdate extends AbstractChangeUpdate { @Override protected CommitBuilder applyImpl(RevWalk rw, ObjectInserter ins, ObjectId curr) - throws OrmException, IOException { + throws StorageException, IOException { checkState( deleteCommentRewriter == null && deleteChangeMessageRewriter == null, "cannot update and rewrite ref in one BatchUpdate"); @@ -681,7 +681,7 @@ public class ChangeUpdate extends AbstractChangeUpdate { cb.setTreeId(treeId); } } catch (ConfigInvalidException e) { - throw new OrmException(e); + throw new StorageException(e); } return cb; } diff --git a/java/com/google/gerrit/server/notedb/DeleteCommentRewriter.java b/java/com/google/gerrit/server/notedb/DeleteCommentRewriter.java index 4f1a5d01be..ad8304acda 100644 --- a/java/com/google/gerrit/server/notedb/DeleteCommentRewriter.java +++ b/java/com/google/gerrit/server/notedb/DeleteCommentRewriter.java @@ -21,11 +21,11 @@ import static java.util.stream.Collectors.toMap; import static org.eclipse.jgit.lib.Constants.OBJ_BLOB; import com.google.common.annotations.VisibleForTesting; +import com.google.gerrit.exceptions.StorageException; import com.google.gerrit.reviewdb.client.Change; import com.google.gerrit.reviewdb.client.Comment; import com.google.gerrit.reviewdb.client.RefNames; import com.google.gerrit.reviewdb.client.RevId; -import com.google.gwtorm.server.OrmException; import com.google.inject.Inject; import com.google.inject.assistedinject.Assisted; import java.io.IOException; @@ -86,7 +86,7 @@ public class DeleteCommentRewriter implements NoteDbRewriter { @Override public ObjectId rewriteCommitHistory(RevWalk revWalk, ObjectInserter inserter, ObjectId currTip) - throws IOException, ConfigInvalidException, OrmException { + throws IOException, ConfigInvalidException, StorageException { checkArgument(!currTip.equals(ObjectId.zeroId())); // Walk from the first commit of the branch. diff --git a/java/com/google/gerrit/server/notedb/IntBlob.java b/java/com/google/gerrit/server/notedb/IntBlob.java index f8c713c2dd..2db409227b 100644 --- a/java/com/google/gerrit/server/notedb/IntBlob.java +++ b/java/com/google/gerrit/server/notedb/IntBlob.java @@ -22,10 +22,10 @@ import com.google.common.annotations.VisibleForTesting; import com.google.common.base.CharMatcher; import com.google.common.primitives.Ints; import com.google.gerrit.common.Nullable; +import com.google.gerrit.exceptions.StorageException; import com.google.gerrit.git.RefUpdateUtil; import com.google.gerrit.reviewdb.client.Project; import com.google.gerrit.server.extensions.events.GitReferenceUpdated; -import com.google.gwtorm.server.OrmException; import java.io.IOException; import java.util.Optional; import org.eclipse.jgit.errors.IncorrectObjectTypeException; @@ -42,19 +42,19 @@ import org.eclipse.jgit.revwalk.RevWalk; @AutoValue public abstract class IntBlob { public static Optional parse(Repository repo, String refName) - throws IOException, OrmException { + throws IOException, StorageException { try (ObjectReader or = repo.newObjectReader()) { return parse(repo, refName, or); } } public static Optional parse(Repository repo, String refName, RevWalk rw) - throws IOException, OrmException { + throws IOException, StorageException { return parse(repo, refName, rw.getObjectReader()); } private static Optional parse(Repository repo, String refName, ObjectReader or) - throws IOException, OrmException { + throws IOException, StorageException { Ref ref = repo.exactRef(refName); if (ref == null) { return Optional.empty(); @@ -69,7 +69,7 @@ public abstract class IntBlob { String str = CharMatcher.whitespace().trimFrom(new String(ol.getCachedBytes(), UTF_8)); Integer value = Ints.tryParse(str); if (value == null) { - throw new OrmException("invalid value in " + refName + " blob at " + id.name()); + throw new StorageException("invalid value in " + refName + " blob at " + id.name()); } return Optional.of(IntBlob.create(id, value)); } diff --git a/java/com/google/gerrit/server/notedb/NoteDbRewriter.java b/java/com/google/gerrit/server/notedb/NoteDbRewriter.java index 3c7b0a31fa..7865a0b61b 100644 --- a/java/com/google/gerrit/server/notedb/NoteDbRewriter.java +++ b/java/com/google/gerrit/server/notedb/NoteDbRewriter.java @@ -14,7 +14,7 @@ package com.google.gerrit.server.notedb; -import com.google.gwtorm.server.OrmException; +import com.google.gerrit.exceptions.StorageException; import java.io.IOException; import org.eclipse.jgit.errors.ConfigInvalidException; import org.eclipse.jgit.lib.ObjectId; @@ -35,5 +35,5 @@ public interface NoteDbRewriter { * @return the {@code ObjectId} of the ref's new tip commit. */ ObjectId rewriteCommitHistory(RevWalk revWalk, ObjectInserter inserter, ObjectId currTip) - throws IOException, ConfigInvalidException, OrmException; + throws IOException, ConfigInvalidException, StorageException; } diff --git a/java/com/google/gerrit/server/notedb/NoteDbUpdateManager.java b/java/com/google/gerrit/server/notedb/NoteDbUpdateManager.java index 7f23f87c5b..f70eae8c1c 100644 --- a/java/com/google/gerrit/server/notedb/NoteDbUpdateManager.java +++ b/java/com/google/gerrit/server/notedb/NoteDbUpdateManager.java @@ -25,6 +25,7 @@ import com.google.common.collect.ImmutableSet; import com.google.common.collect.ListMultimap; import com.google.common.collect.MultimapBuilder; import com.google.gerrit.common.Nullable; +import com.google.gerrit.exceptions.StorageException; import com.google.gerrit.extensions.restapi.RestModifyView; import com.google.gerrit.git.RefUpdateUtil; import com.google.gerrit.metrics.Timer1; @@ -38,7 +39,6 @@ import com.google.gerrit.server.git.InMemoryInserter; import com.google.gerrit.server.git.InsertedObject; import com.google.gerrit.server.update.ChainedReceiveCommands; import com.google.gerrit.server.update.RetryingRestModifyView; -import com.google.gwtorm.server.OrmException; import com.google.inject.Inject; import com.google.inject.Provider; import com.google.inject.assistedinject.Assisted; @@ -348,10 +348,10 @@ public class NoteDbUpdateManager implements AutoCloseable { /** * Stage updates in the manager's internal list of commands. * - * @throws OrmException if a database layer error occurs. + * @throws StorageException if a database layer error occurs. * @throws IOException if a storage layer error occurs. */ - private void stage() throws OrmException, IOException { + private void stage() throws StorageException, IOException { try (Timer1.Context timer = metrics.stageUpdateLatency.start(CHANGES)) { if (isEmpty()) { return; @@ -376,12 +376,12 @@ public class NoteDbUpdateManager implements AutoCloseable { } @Nullable - public BatchRefUpdate execute() throws OrmException, IOException { + public BatchRefUpdate execute() throws StorageException, IOException { return execute(false); } @Nullable - public BatchRefUpdate execute(boolean dryrun) throws OrmException, IOException { + public BatchRefUpdate execute(boolean dryrun) throws StorageException, IOException { checkNotExecuted(); if (isEmpty()) { executed = true; @@ -476,7 +476,7 @@ public class NoteDbUpdateManager implements AutoCloseable { return -1; } - private void addCommands() throws OrmException, IOException { + private void addCommands() throws StorageException, IOException { if (isEmpty()) { return; } @@ -522,7 +522,7 @@ public class NoteDbUpdateManager implements AutoCloseable { } private static void addUpdates( - ListMultimap all, OpenRepo or) throws OrmException, IOException { + ListMultimap all, OpenRepo or) throws StorageException, IOException { for (Map.Entry> e : all.asMap().entrySet()) { String refName = e.getKey(); Collection updates = e.getValue(); @@ -537,7 +537,7 @@ public class NoteDbUpdateManager implements AutoCloseable { ObjectId curr = old; for (U u : updates) { if (u.isRootOnly() && !old.equals(ObjectId.zeroId())) { - throw new OrmException("Given ChangeUpdate is only allowed on initial commit"); + throw new StorageException("Given ChangeUpdate is only allowed on initial commit"); } ObjectId next = u.apply(or.rw, or.tempIns, curr); if (next == null) { @@ -552,13 +552,13 @@ public class NoteDbUpdateManager implements AutoCloseable { } private static void addRewrites(ListMultimap rewriters, OpenRepo openRepo) - throws OrmException, IOException { + throws StorageException, IOException { for (Map.Entry> entry : rewriters.asMap().entrySet()) { String refName = entry.getKey(); ObjectId oldTip = openRepo.cmds.get(refName).orElse(ObjectId.zeroId()); if (oldTip.equals(ObjectId.zeroId())) { - throw new OrmException(String.format("Ref %s is empty", refName)); + throw new StorageException(String.format("Ref %s is empty", refName)); } ObjectId currTip = oldTip; @@ -571,7 +571,7 @@ public class NoteDbUpdateManager implements AutoCloseable { } } } catch (ConfigInvalidException e) { - throw new OrmException("Cannot rewrite commit history", e); + throw new StorageException("Cannot rewrite commit history", e); } if (!oldTip.equals(currTip)) { diff --git a/java/com/google/gerrit/server/notedb/RepoSequence.java b/java/com/google/gerrit/server/notedb/RepoSequence.java index 56264e95c6..40ba871535 100644 --- a/java/com/google/gerrit/server/notedb/RepoSequence.java +++ b/java/com/google/gerrit/server/notedb/RepoSequence.java @@ -30,12 +30,12 @@ import com.google.common.annotations.VisibleForTesting; import com.google.common.base.Throwables; import com.google.common.collect.ImmutableList; import com.google.common.util.concurrent.Runnables; +import com.google.gerrit.exceptions.StorageException; import com.google.gerrit.git.RefUpdateUtil; import com.google.gerrit.reviewdb.client.Project; import com.google.gerrit.reviewdb.client.RefNames; import com.google.gerrit.server.extensions.events.GitReferenceUpdated; import com.google.gerrit.server.git.GitRepositoryManager; -import com.google.gwtorm.server.OrmException; import java.io.IOException; import java.util.ArrayList; import java.util.List; @@ -65,7 +65,7 @@ import org.eclipse.jgit.transport.ReceiveCommand; public class RepoSequence { @FunctionalInterface public interface Seed { - int get() throws OrmException; + int get() throws StorageException; } @VisibleForTesting @@ -184,7 +184,7 @@ public class RepoSequence { counterLock = new ReentrantLock(true); } - public int next() throws OrmException { + public int next() throws StorageException { counterLock.lock(); try { if (counter >= limit) { @@ -196,7 +196,7 @@ public class RepoSequence { } } - public ImmutableList next(int count) throws OrmException { + public ImmutableList next(int count) throws StorageException { if (count == 0) { return ImmutableList.of(); } @@ -221,7 +221,7 @@ public class RepoSequence { } @VisibleForTesting - public void set(int val) throws OrmException { + public void set(int val) throws StorageException { // Don't bother spinning. This is only for tests, and a test that calls set // concurrently with other writes is doing it wrong. counterLock.lock(); @@ -231,14 +231,14 @@ public class RepoSequence { IntBlob.store(repo, rw, projectName, refName, null, val, gitRefUpdated); counter = limit; } catch (IOException e) { - throw new OrmException(e); + throw new StorageException(e); } } finally { counterLock.unlock(); } } - public void increaseTo(int val) throws OrmException { + public void increaseTo(int val) throws StorageException { counterLock.lock(); try { try (Repository repo = repoManager.openRepository(projectName); @@ -252,18 +252,18 @@ public class RepoSequence { counter = limit; } catch (ExecutionException | RetryException e) { if (e.getCause() != null) { - Throwables.throwIfInstanceOf(e.getCause(), OrmException.class); + Throwables.throwIfInstanceOf(e.getCause(), StorageException.class); } - throw new OrmException(e); + throw new StorageException(e); } catch (IOException e) { - throw new OrmException(e); + throw new StorageException(e); } } finally { counterLock.unlock(); } } - private void acquire(int count) throws OrmException { + private void acquire(int count) throws StorageException { try (Repository repo = repoManager.openRepository(projectName); RevWalk rw = new RevWalk(repo)) { TryAcquire attempt = new TryAcquire(repo, rw, count); @@ -273,11 +273,11 @@ public class RepoSequence { acquireCount++; } catch (ExecutionException | RetryException e) { if (e.getCause() != null) { - Throwables.throwIfInstanceOf(e.getCause(), OrmException.class); + Throwables.throwIfInstanceOf(e.getCause(), StorageException.class); } - throw new OrmException(e); + throw new StorageException(e); } catch (IOException e) { - throw new OrmException(e); + throw new StorageException(e); } } diff --git a/java/com/google/gerrit/server/notedb/RobotCommentUpdate.java b/java/com/google/gerrit/server/notedb/RobotCommentUpdate.java index 9307724487..bf63782625 100644 --- a/java/com/google/gerrit/server/notedb/RobotCommentUpdate.java +++ b/java/com/google/gerrit/server/notedb/RobotCommentUpdate.java @@ -19,13 +19,13 @@ import static com.google.gerrit.reviewdb.client.RefNames.robotCommentsRef; import static org.eclipse.jgit.lib.Constants.OBJ_BLOB; import com.google.common.collect.Sets; +import com.google.gerrit.exceptions.StorageException; import com.google.gerrit.reviewdb.client.Account; import com.google.gerrit.reviewdb.client.Change; import com.google.gerrit.reviewdb.client.Project; import com.google.gerrit.reviewdb.client.RevId; import com.google.gerrit.reviewdb.client.RobotComment; import com.google.gerrit.server.GerritPersonIdent; -import com.google.gwtorm.server.OrmException; import com.google.inject.assistedinject.Assisted; import com.google.inject.assistedinject.AssistedInject; import java.io.IOException; @@ -101,7 +101,7 @@ public class RobotCommentUpdate extends AbstractChangeUpdate { private CommitBuilder storeCommentsInNotes( RevWalk rw, ObjectInserter ins, ObjectId curr, CommitBuilder cb) - throws ConfigInvalidException, OrmException, IOException { + throws ConfigInvalidException, StorageException, IOException { RevisionNoteMap rnm = getRevisionNoteMap(rw, curr); Set updatedRevs = Sets.newHashSetWithExpectedSize(rnm.revisionNotes.size()); RevisionNoteBuilder.Cache cache = new RevisionNoteBuilder.Cache(rnm); @@ -148,7 +148,7 @@ public class RobotCommentUpdate extends AbstractChangeUpdate { } private RevisionNoteMap getRevisionNoteMap(RevWalk rw, ObjectId curr) - throws ConfigInvalidException, OrmException, IOException { + throws ConfigInvalidException, StorageException, IOException { if (curr.equals(ObjectId.zeroId())) { return RevisionNoteMap.emptyMap(); } @@ -179,13 +179,13 @@ public class RobotCommentUpdate extends AbstractChangeUpdate { @Override protected CommitBuilder applyImpl(RevWalk rw, ObjectInserter ins, ObjectId curr) - throws OrmException, IOException { + throws StorageException, IOException { CommitBuilder cb = new CommitBuilder(); cb.setMessage("Update robot comments"); try { return storeCommentsInNotes(rw, ins, curr, cb); } catch (ConfigInvalidException e) { - throw new OrmException(e); + throw new StorageException(e); } } diff --git a/java/com/google/gerrit/server/notedb/Sequences.java b/java/com/google/gerrit/server/notedb/Sequences.java index 1a255f14c0..556becf63b 100644 --- a/java/com/google/gerrit/server/notedb/Sequences.java +++ b/java/com/google/gerrit/server/notedb/Sequences.java @@ -15,6 +15,7 @@ package com.google.gerrit.server.notedb; import com.google.common.collect.ImmutableList; +import com.google.gerrit.exceptions.StorageException; import com.google.gerrit.metrics.Description; import com.google.gerrit.metrics.Description.Units; import com.google.gerrit.metrics.Field; @@ -25,7 +26,6 @@ import com.google.gerrit.server.config.AllUsersName; import com.google.gerrit.server.config.GerritServerConfig; import com.google.gerrit.server.extensions.events.GitReferenceUpdated; import com.google.gerrit.server.git.GitRepositoryManager; -import com.google.gwtorm.server.OrmException; import com.google.inject.Inject; import com.google.inject.Singleton; import org.eclipse.jgit.lib.Config; @@ -100,25 +100,25 @@ public class Sequences { Field.ofBoolean("multiple")); } - public int nextAccountId() throws OrmException { + public int nextAccountId() throws StorageException { try (Timer2.Context timer = nextIdLatency.start(SequenceType.ACCOUNTS, false)) { return accountSeq.next(); } } - public int nextChangeId() throws OrmException { + public int nextChangeId() throws StorageException { try (Timer2.Context timer = nextIdLatency.start(SequenceType.CHANGES, false)) { return changeSeq.next(); } } - public ImmutableList nextChangeIds(int count) throws OrmException { + public ImmutableList nextChangeIds(int count) throws StorageException { try (Timer2.Context timer = nextIdLatency.start(SequenceType.CHANGES, count > 1)) { return changeSeq.next(count); } } - public int nextGroupId() throws OrmException { + public int nextGroupId() throws StorageException { try (Timer2.Context timer = nextIdLatency.start(SequenceType.GROUPS, false)) { return groupSeq.next(); } diff --git a/java/com/google/gerrit/server/patch/PatchScriptFactory.java b/java/com/google/gerrit/server/patch/PatchScriptFactory.java index 50d3711d01..d344871e2f 100644 --- a/java/com/google/gerrit/server/patch/PatchScriptFactory.java +++ b/java/com/google/gerrit/server/patch/PatchScriptFactory.java @@ -20,6 +20,7 @@ import com.google.common.flogger.FluentLogger; import com.google.gerrit.common.Nullable; import com.google.gerrit.common.data.CommentDetail; import com.google.gerrit.common.data.PatchScript; +import com.google.gerrit.exceptions.StorageException; import com.google.gerrit.extensions.client.DiffPreferencesInfo; import com.google.gerrit.extensions.client.DiffPreferencesInfo.Whitespace; import com.google.gerrit.extensions.restapi.AuthException; @@ -43,7 +44,6 @@ import com.google.gerrit.server.permissions.PermissionBackendException; import com.google.gerrit.server.project.InvalidChangeOperationException; import com.google.gerrit.server.project.NoSuchChangeException; import com.google.gerrit.server.project.ProjectCache; -import com.google.gwtorm.server.OrmException; import com.google.inject.Provider; import com.google.inject.assistedinject.Assisted; import com.google.inject.assistedinject.AssistedInject; @@ -187,7 +187,7 @@ public class PatchScriptFactory implements Callable { @Override public PatchScript call() - throws OrmException, LargeObjectException, AuthException, InvalidChangeOperationException, + throws StorageException, LargeObjectException, AuthException, InvalidChangeOperationException, IOException, PermissionBackendException { if (parentNum < 0) { validatePatchSetId(psa); @@ -259,7 +259,7 @@ public class PatchScriptFactory implements Callable { return b; } - private ObjectId toObjectId(PatchSet ps) throws AuthException, IOException, OrmException { + private ObjectId toObjectId(PatchSet ps) throws AuthException, IOException, StorageException { if (ps.getId().get() == 0) { return getEditRev(); } @@ -275,7 +275,7 @@ public class PatchScriptFactory implements Callable { } } - private ObjectId getEditRev() throws AuthException, IOException, OrmException { + private ObjectId getEditRev() throws AuthException, IOException, StorageException { edit = editReader.byChange(notes); if (edit.isPresent()) { return edit.get().getEditCommit(); @@ -292,7 +292,7 @@ public class PatchScriptFactory implements Callable { } private void loadCommentsAndHistory(ChangeType changeType, String oldName, String newName) - throws OrmException { + throws StorageException { Map byKey = new HashMap<>(); if (loadHistory) { @@ -384,7 +384,7 @@ public class PatchScriptFactory implements Callable { } } - private void loadPublished(Map byKey, String file) throws OrmException { + private void loadPublished(Map byKey, String file) throws StorageException { for (Comment c : commentsUtil.publishedByChangeFile(notes, file)) { comments.include(notes.getChangeId(), c); PatchSet.Id psId = new PatchSet.Id(notes.getChangeId(), c.key.patchSetId); @@ -397,7 +397,7 @@ public class PatchScriptFactory implements Callable { } private void loadDrafts(Map byKey, Account.Id me, String file) - throws OrmException { + throws StorageException { for (Comment c : commentsUtil.draftByChangeFileAuthor(notes, file, me)) { comments.include(notes.getChangeId(), c); PatchSet.Id psId = new PatchSet.Id(notes.getChangeId(), c.key.patchSetId); diff --git a/java/com/google/gerrit/server/patch/PatchSetInfoFactory.java b/java/com/google/gerrit/server/patch/PatchSetInfoFactory.java index f11f116c49..d0b80a39e6 100644 --- a/java/com/google/gerrit/server/patch/PatchSetInfoFactory.java +++ b/java/com/google/gerrit/server/patch/PatchSetInfoFactory.java @@ -14,6 +14,7 @@ package com.google.gerrit.server.patch; +import com.google.gerrit.exceptions.StorageException; import com.google.gerrit.reviewdb.client.Account; import com.google.gerrit.reviewdb.client.PatchSet; import com.google.gerrit.reviewdb.client.PatchSetInfo; @@ -24,7 +25,6 @@ import com.google.gerrit.server.PatchSetUtil; import com.google.gerrit.server.account.Emails; import com.google.gerrit.server.git.GitRepositoryManager; import com.google.gerrit.server.notedb.ChangeNotes; -import com.google.gwtorm.server.OrmException; import com.google.inject.Inject; import com.google.inject.Singleton; import java.io.IOException; @@ -54,7 +54,7 @@ public class PatchSetInfoFactory { } public PatchSetInfo get(RevWalk rw, RevCommit src, PatchSet.Id psi) - throws IOException, OrmException { + throws IOException, StorageException { rw.parseBody(src); PatchSetInfo info = new PatchSetInfo(psi); info.setSubject(src.getShortMessage()); @@ -70,7 +70,7 @@ public class PatchSetInfoFactory { try { PatchSet patchSet = psUtil.get(notes, psId); return get(notes.getProjectName(), patchSet); - } catch (OrmException e) { + } catch (StorageException e) { throw new PatchSetInfoNotAvailableException(e); } } @@ -83,13 +83,13 @@ public class PatchSetInfoFactory { PatchSetInfo info = get(rw, src, patchSet.getId()); info.setParents(toParentInfos(src.getParents(), rw)); return info; - } catch (IOException | OrmException e) { + } catch (IOException | StorageException e) { throw new PatchSetInfoNotAvailableException(e); } } // TODO: The same method exists in EventFactory, find a common place for it - private UserIdentity toUserIdentity(PersonIdent who) throws IOException, OrmException { + private UserIdentity toUserIdentity(PersonIdent who) throws IOException, StorageException { final UserIdentity u = new UserIdentity(); u.setName(who.getName()); u.setEmail(who.getEmailAddress()); diff --git a/java/com/google/gerrit/server/permissions/ChangeControl.java b/java/com/google/gerrit/server/permissions/ChangeControl.java index 309bf515ee..643010d8d6 100644 --- a/java/com/google/gerrit/server/permissions/ChangeControl.java +++ b/java/com/google/gerrit/server/permissions/ChangeControl.java @@ -22,6 +22,7 @@ import com.google.common.collect.Sets; import com.google.gerrit.common.Nullable; import com.google.gerrit.common.data.Permission; import com.google.gerrit.common.data.PermissionRange; +import com.google.gerrit.exceptions.StorageException; import com.google.gerrit.extensions.conditions.BooleanCondition; import com.google.gerrit.extensions.restapi.AuthException; import com.google.gerrit.reviewdb.client.Account; @@ -31,7 +32,6 @@ import com.google.gerrit.server.CurrentUser; import com.google.gerrit.server.notedb.ChangeNotes; import com.google.gerrit.server.permissions.PermissionBackend.ForChange; import com.google.gerrit.server.query.change.ChangeData; -import com.google.gwtorm.server.OrmException; import com.google.inject.Inject; import com.google.inject.Singleton; import java.util.Collection; @@ -53,7 +53,7 @@ class ChangeControl { } ChangeControl create(RefControl refControl, Project.NameKey project, Change.Id changeId) - throws OrmException { + throws StorageException { return create(refControl, notesFactory.create(project, changeId)); } @@ -90,7 +90,7 @@ class ChangeControl { } /** Can this user see this change? */ - private boolean isVisible(@Nullable ChangeData cd) throws OrmException { + private boolean isVisible(@Nullable ChangeData cd) throws StorageException { if (getChange().isPrivate() && !isPrivateVisible(cd)) { return false; } @@ -154,7 +154,7 @@ class ChangeControl { } /** Is this user a reviewer for the change? */ - private boolean isReviewer(@Nullable ChangeData cd) throws OrmException { + private boolean isReviewer(@Nullable ChangeData cd) throws StorageException { if (getUser().isIdentifiedUser()) { cd = cd != null ? cd : changeDataFactory.create(notes); Collection results = cd.reviewers().all(); @@ -212,7 +212,7 @@ class ChangeControl { || getProjectControl().isAdmin(); } - private boolean isPrivateVisible(ChangeData cd) throws OrmException { + private boolean isPrivateVisible(ChangeData cd) throws StorageException { return isOwner() || isReviewer(cd) || refControl.canPerform(Permission.VIEW_PRIVATE_CHANGES) @@ -314,7 +314,7 @@ class ChangeControl { case SUBMIT_AS: return refControl.canPerform(changePermissionName(perm)); } - } catch (OrmException e) { + } catch (StorageException e) { throw new PermissionBackendException("unavailable", e); } throw new PermissionBackendException(perm + " unsupported"); diff --git a/java/com/google/gerrit/server/permissions/DefaultRefFilter.java b/java/com/google/gerrit/server/permissions/DefaultRefFilter.java index 913921fc46..a5174e1bed 100644 --- a/java/com/google/gerrit/server/permissions/DefaultRefFilter.java +++ b/java/com/google/gerrit/server/permissions/DefaultRefFilter.java @@ -31,6 +31,7 @@ import com.google.common.collect.Iterables; import com.google.common.collect.Maps; import com.google.common.flogger.FluentLogger; import com.google.gerrit.common.Nullable; +import com.google.gerrit.exceptions.StorageException; import com.google.gerrit.extensions.restapi.AuthException; import com.google.gerrit.metrics.Counter0; import com.google.gerrit.metrics.Description; @@ -54,7 +55,6 @@ import com.google.gerrit.server.notedb.ChangeNotes.Factory.ChangeNotesResult; import com.google.gerrit.server.permissions.PermissionBackend.RefFilterOptions; import com.google.gerrit.server.project.ProjectState; import com.google.gerrit.server.query.change.ChangeData; -import com.google.gwtorm.server.OrmException; import com.google.inject.Inject; import com.google.inject.assistedinject.Assisted; import java.io.IOException; @@ -393,7 +393,7 @@ class DefaultRefFilter { } } return visibleChanges; - } catch (OrmException e) { + } catch (StorageException e) { logger.atSevere().withCause(e).log( "Cannot load changes for project %s, assuming no changes are visible", project); return Collections.emptyMap(); @@ -503,7 +503,7 @@ class DefaultRefFilter { ChangeNotes notes; try { notes = changeNotesFactory.create(projectState.getNameKey(), cId); - } catch (OrmException e) { + } catch (StorageException e) { throw new PermissionBackendException("can't construct change notes", e); } try { diff --git a/java/com/google/gerrit/server/permissions/PermissionBackend.java b/java/com/google/gerrit/server/permissions/PermissionBackend.java index 3ac294abb6..3d10181f48 100644 --- a/java/com/google/gerrit/server/permissions/PermissionBackend.java +++ b/java/com/google/gerrit/server/permissions/PermissionBackend.java @@ -23,6 +23,7 @@ import com.google.common.collect.ImmutableList; import com.google.common.collect.Sets; import com.google.common.flogger.FluentLogger; import com.google.gerrit.common.data.LabelType; +import com.google.gerrit.exceptions.StorageException; import com.google.gerrit.extensions.api.access.CoreOrPluginProjectPermission; import com.google.gerrit.extensions.api.access.GlobalOrPluginPermission; import com.google.gerrit.extensions.conditions.BooleanCondition; @@ -34,7 +35,6 @@ import com.google.gerrit.reviewdb.client.Project; import com.google.gerrit.server.CurrentUser; import com.google.gerrit.server.notedb.ChangeNotes; import com.google.gerrit.server.query.change.ChangeData; -import com.google.gwtorm.server.OrmException; import com.google.inject.ImplementedBy; import java.util.Collection; import java.util.Collections; @@ -165,7 +165,7 @@ public abstract class PermissionBackend { public ForChange change(ChangeData cd) { try { return ref(cd.change().getDest()).change(cd); - } catch (OrmException e) { + } catch (StorageException e) { return FailedPermissionBackend.change("unavailable", e); } } @@ -281,7 +281,7 @@ public abstract class PermissionBackend { public ForChange change(ChangeData cd) { try { return ref(cd.change().getDest().get()).change(cd); - } catch (OrmException e) { + } catch (StorageException e) { return FailedPermissionBackend.change("unavailable", e); } } diff --git a/java/com/google/gerrit/server/permissions/ProjectControl.java b/java/com/google/gerrit/server/permissions/ProjectControl.java index 144519a192..aacfe6f9a8 100644 --- a/java/com/google/gerrit/server/permissions/ProjectControl.java +++ b/java/com/google/gerrit/server/permissions/ProjectControl.java @@ -21,6 +21,7 @@ import com.google.common.collect.Sets; import com.google.gerrit.common.data.AccessSection; import com.google.gerrit.common.data.Permission; import com.google.gerrit.common.data.PermissionRule; +import com.google.gerrit.exceptions.StorageException; import com.google.gerrit.extensions.api.access.CoreOrPluginProjectPermission; import com.google.gerrit.extensions.api.access.PluginProjectPermission; import com.google.gerrit.extensions.conditions.BooleanCondition; @@ -43,7 +44,6 @@ import com.google.gerrit.server.permissions.PermissionBackend.RefFilterOptions; import com.google.gerrit.server.project.ProjectState; import com.google.gerrit.server.project.SectionMatcher; import com.google.gerrit.server.query.change.ChangeData; -import com.google.gwtorm.server.OrmException; import com.google.inject.Inject; import com.google.inject.assistedinject.Assisted; import java.util.Collection; @@ -99,7 +99,7 @@ class ProjectControl { return new ForProjectImpl(); } - ChangeControl controlFor(Change change) throws OrmException { + ChangeControl controlFor(Change change) throws StorageException { return changeControlFactory.create( controlForRef(change.getDest()), change.getProject(), change.getId()); } @@ -353,7 +353,7 @@ class ProjectControl { try { checkProject(cd.change()); return super.change(cd); - } catch (OrmException e) { + } catch (StorageException e) { return FailedPermissionBackend.change("unavailable", e); } } diff --git a/java/com/google/gerrit/server/permissions/RefControl.java b/java/com/google/gerrit/server/permissions/RefControl.java index 60fd15bfad..9a2ecdd17e 100644 --- a/java/com/google/gerrit/server/permissions/RefControl.java +++ b/java/com/google/gerrit/server/permissions/RefControl.java @@ -21,6 +21,7 @@ import com.google.gerrit.common.data.Permission; import com.google.gerrit.common.data.PermissionRange; import com.google.gerrit.common.data.PermissionRule; import com.google.gerrit.common.data.PermissionRule.Action; +import com.google.gerrit.exceptions.StorageException; import com.google.gerrit.extensions.conditions.BooleanCondition; import com.google.gerrit.extensions.restapi.AuthException; import com.google.gerrit.reviewdb.client.Change; @@ -33,7 +34,6 @@ import com.google.gerrit.server.permissions.PermissionBackend.ForChange; import com.google.gerrit.server.permissions.PermissionBackend.ForRef; import com.google.gerrit.server.query.change.ChangeData; import com.google.gerrit.server.util.MagicBranch; -import com.google.gwtorm.server.OrmException; import java.util.Collection; import java.util.EnumSet; import java.util.List; @@ -442,7 +442,7 @@ class RefControl { try { // TODO(hiesel) Force callers to call database() and use db instead of cd.db() return getProjectControl().controlFor(cd.change()).asForChange(cd); - } catch (OrmException e) { + } catch (StorageException e) { return FailedPermissionBackend.change("unavailable", e); } } diff --git a/java/com/google/gerrit/server/project/NoSuchChangeException.java b/java/com/google/gerrit/server/project/NoSuchChangeException.java index 7946a3a15b..6f65659f04 100644 --- a/java/com/google/gerrit/server/project/NoSuchChangeException.java +++ b/java/com/google/gerrit/server/project/NoSuchChangeException.java @@ -14,11 +14,11 @@ package com.google.gerrit.server.project; +import com.google.gerrit.exceptions.StorageException; import com.google.gerrit.reviewdb.client.Change; -import com.google.gwtorm.server.OrmException; /** Indicates the change does not exist. */ -public class NoSuchChangeException extends OrmException { +public class NoSuchChangeException extends StorageException { private static final long serialVersionUID = 1L; public NoSuchChangeException(Change.Id key) { diff --git a/java/com/google/gerrit/server/project/ProjectsConsistencyChecker.java b/java/com/google/gerrit/server/project/ProjectsConsistencyChecker.java index 894037d2ac..8fd594ff17 100644 --- a/java/com/google/gerrit/server/project/ProjectsConsistencyChecker.java +++ b/java/com/google/gerrit/server/project/ProjectsConsistencyChecker.java @@ -24,6 +24,7 @@ import com.google.common.annotations.VisibleForTesting; import com.google.common.base.Strings; import com.google.common.base.Throwables; import com.google.common.collect.ImmutableList; +import com.google.gerrit.exceptions.StorageException; import com.google.gerrit.extensions.api.changes.FixInput; import com.google.gerrit.extensions.api.projects.CheckProjectInput; import com.google.gerrit.extensions.api.projects.CheckProjectInput.AutoCloseableChangesCheckInput; @@ -51,7 +52,6 @@ import com.google.gerrit.server.query.change.ProjectPredicate; import com.google.gerrit.server.query.change.RefPredicate; import com.google.gerrit.server.update.RetryHelper; import com.google.gerrit.server.update.RetryHelper.ActionType; -import com.google.gwtorm.server.OrmException; import com.google.inject.Inject; import com.google.inject.Provider; import com.google.inject.Singleton; @@ -94,7 +94,7 @@ public class ProjectsConsistencyChecker { } public CheckProjectResultInfo check(Project.NameKey projectName, CheckProjectInput input) - throws IOException, OrmException, RestApiException { + throws IOException, StorageException, RestApiException { CheckProjectResultInfo r = new CheckProjectResultInfo(); if (input.autoCloseableChangesCheck != null) { r.autoCloseableChangesCheckResult = @@ -105,7 +105,7 @@ public class ProjectsConsistencyChecker { private AutoCloseableChangesCheckResult checkForAutoCloseableChanges( Project.NameKey projectName, AutoCloseableChangesCheckInput input) - throws IOException, OrmException, RestApiException { + throws IOException, StorageException, RestApiException { AutoCloseableChangesCheckResult r = new AutoCloseableChangesCheckResult(); if (Strings.isNullOrEmpty(input.branch)) { throw new BadRequestException("branch is required"); @@ -257,7 +257,7 @@ public class ProjectsConsistencyChecker { boolean fix, Map changeIdToMergedSha1, List mergedSha1s) - throws OrmException { + throws StorageException { if (predicates.isEmpty()) { return ImmutableList.of(); } @@ -273,7 +273,7 @@ public class ProjectsConsistencyChecker { .setRequestedFields(ChangeField.CHANGE, ChangeField.PATCH_SET) .query(and(basePredicate, or(predicates))); }, - OrmException.class::isInstance); + StorageException.class::isInstance); // Result for this query that we want to return to the client. List autoCloseableChangesByBranch = new ArrayList<>(); @@ -307,15 +307,15 @@ public class ProjectsConsistencyChecker { } return null; }, - OrmException.class::isInstance); + StorageException.class::isInstance); } } return autoCloseableChangesByBranch; } catch (Exception e) { Throwables.throwIfUnchecked(e); - Throwables.throwIfInstanceOf(e, OrmException.class); - throw new OrmException(e); + Throwables.throwIfInstanceOf(e, StorageException.class); + throw new StorageException(e); } } diff --git a/java/com/google/gerrit/server/project/RemoveReviewerControl.java b/java/com/google/gerrit/server/project/RemoveReviewerControl.java index 7353ce8dfa..d0067a67d3 100644 --- a/java/com/google/gerrit/server/project/RemoveReviewerControl.java +++ b/java/com/google/gerrit/server/project/RemoveReviewerControl.java @@ -14,6 +14,7 @@ package com.google.gerrit.server.project; +import com.google.gerrit.exceptions.StorageException; import com.google.gerrit.extensions.restapi.AuthException; import com.google.gerrit.reviewdb.client.Account; import com.google.gerrit.reviewdb.client.Change; @@ -26,7 +27,6 @@ import com.google.gerrit.server.permissions.PermissionBackend; import com.google.gerrit.server.permissions.PermissionBackendException; import com.google.gerrit.server.permissions.RefPermission; import com.google.gerrit.server.query.change.ChangeData; -import com.google.gwtorm.server.OrmException; import com.google.inject.Inject; import com.google.inject.Singleton; @@ -66,7 +66,7 @@ public class RemoveReviewerControl { /** @return true if the user is allowed to remove this reviewer. */ public boolean testRemoveReviewer( ChangeData cd, CurrentUser currentUser, Account.Id reviewer, int value) - throws PermissionBackendException, OrmException { + throws PermissionBackendException, StorageException { if (canRemoveReviewerWithoutPermissionCheck( permissionBackend, cd.change(), currentUser, reviewer, value)) { return true; diff --git a/java/com/google/gerrit/server/project/SubmitRuleEvaluator.java b/java/com/google/gerrit/server/project/SubmitRuleEvaluator.java index 1afa426a11..85d91e7887 100644 --- a/java/com/google/gerrit/server/project/SubmitRuleEvaluator.java +++ b/java/com/google/gerrit/server/project/SubmitRuleEvaluator.java @@ -18,12 +18,12 @@ import com.google.common.collect.Streams; import com.google.common.flogger.FluentLogger; import com.google.gerrit.common.data.SubmitRecord; import com.google.gerrit.common.data.SubmitTypeRecord; +import com.google.gerrit.exceptions.StorageException; import com.google.gerrit.reviewdb.client.Change; import com.google.gerrit.server.plugincontext.PluginSetContext; import com.google.gerrit.server.query.change.ChangeData; import com.google.gerrit.server.rules.PrologRule; import com.google.gerrit.server.rules.SubmitRule; -import com.google.gwtorm.server.OrmException; import com.google.inject.Inject; import com.google.inject.assistedinject.Assisted; import java.util.Collection; @@ -91,14 +91,14 @@ public class SubmitRuleEvaluator { try { change = cd.change(); if (change == null) { - throw new OrmException("Change not found"); + throw new StorageException("Change not found"); } projectState = projectCache.get(cd.project()); if (projectState == null) { throw new NoSuchProjectException(cd.project()); } - } catch (OrmException | NoSuchProjectException e) { + } catch (StorageException | NoSuchProjectException e) { return ruleError("Error looking up change " + cd.getId(), e); } diff --git a/java/com/google/gerrit/server/query/account/AccountIsVisibleToPredicate.java b/java/com/google/gerrit/server/query/account/AccountIsVisibleToPredicate.java index bd7b7fe3be..fe0ac75351 100644 --- a/java/com/google/gerrit/server/query/account/AccountIsVisibleToPredicate.java +++ b/java/com/google/gerrit/server/query/account/AccountIsVisibleToPredicate.java @@ -15,11 +15,11 @@ package com.google.gerrit.server.query.account; import com.google.common.flogger.FluentLogger; +import com.google.gerrit.exceptions.StorageException; import com.google.gerrit.index.query.IsVisibleToPredicate; import com.google.gerrit.server.account.AccountControl; import com.google.gerrit.server.account.AccountState; import com.google.gerrit.server.index.IndexUtils; -import com.google.gwtorm.server.OrmException; public class AccountIsVisibleToPredicate extends IsVisibleToPredicate { private static final FluentLogger logger = FluentLogger.forEnclosingClass(); @@ -32,7 +32,7 @@ public class AccountIsVisibleToPredicate extends IsVisibleToPredicate cansee(String change) - throws QueryParseException, OrmException, PermissionBackendException { + throws QueryParseException, StorageException, PermissionBackendException { ChangeNotes changeNotes = args.changeFinder.findOne(change); if (changeNotes == null) { throw error(String.format("change %s not found", change)); @@ -195,7 +195,7 @@ public class AccountQueryBuilder extends QueryBuilder { private final PermissionBackend permissionBackend; @@ -34,7 +34,7 @@ public class CanSeeChangePredicate extends PostFilterPredicate { } @Override - public boolean match(AccountState accountState) throws OrmException { + public boolean match(AccountState accountState) throws StorageException { try { permissionBackend .absentUser(accountState.getAccount().getId()) @@ -42,7 +42,7 @@ public class CanSeeChangePredicate extends PostFilterPredicate { .check(ChangePermission.READ); return true; } catch (PermissionBackendException e) { - throw new OrmException("Failed to check if account can see change", e); + throw new StorageException("Failed to check if account can see change", e); } catch (AuthException e) { return false; } diff --git a/java/com/google/gerrit/server/query/account/InternalAccountQuery.java b/java/com/google/gerrit/server/query/account/InternalAccountQuery.java index 61a969083e..f31a2356e4 100644 --- a/java/com/google/gerrit/server/query/account/InternalAccountQuery.java +++ b/java/com/google/gerrit/server/query/account/InternalAccountQuery.java @@ -21,6 +21,7 @@ import com.google.common.collect.ArrayListMultimap; import com.google.common.collect.ImmutableList; import com.google.common.collect.ImmutableListMultimap; import com.google.common.collect.Multimap; +import com.google.gerrit.exceptions.StorageException; import com.google.gerrit.index.FieldDef; import com.google.gerrit.index.IndexConfig; import com.google.gerrit.index.Schema; @@ -30,7 +31,6 @@ import com.google.gerrit.server.account.AccountState; import com.google.gerrit.server.account.externalids.ExternalId; import com.google.gerrit.server.index.account.AccountField; import com.google.gerrit.server.index.account.AccountIndexCollection; -import com.google.gwtorm.server.OrmException; import com.google.inject.Inject; import java.util.Arrays; import java.util.List; @@ -51,19 +51,19 @@ public class InternalAccountQuery extends InternalQuery byDefault(String query) throws OrmException { + public List byDefault(String query) throws StorageException { return query(AccountPredicates.defaultPredicate(schema(), true, query)); } - public List byExternalId(String scheme, String id) throws OrmException { + public List byExternalId(String scheme, String id) throws StorageException { return byExternalId(ExternalId.Key.create(scheme, id)); } - public List byExternalId(ExternalId.Key externalId) throws OrmException { + public List byExternalId(ExternalId.Key externalId) throws StorageException { return query(AccountPredicates.externalIdIncludingSecondaryEmails(externalId.toString())); } - public List byFullName(String fullName) throws OrmException { + public List byFullName(String fullName) throws StorageException { return query(AccountPredicates.fullName(fullName)); } @@ -72,9 +72,9 @@ public class InternalAccountQuery extends InternalQuery byPreferredEmail(String email) throws OrmException { + public List byPreferredEmail(String email) throws StorageException { if (hasPreferredEmailExact()) { return query(AccountPredicates.preferredEmailExact(email)); } @@ -94,9 +94,9 @@ public class InternalAccountQuery extends InternalQuery byPreferredEmail(String... emails) throws OrmException { + public Multimap byPreferredEmail(String... emails) throws StorageException { List emailList = Arrays.asList(emails); if (hasPreferredEmailExact()) { @@ -127,7 +127,7 @@ public class InternalAccountQuery extends InternalQuery byWatchedProject(Project.NameKey project) throws OrmException { + public List byWatchedProject(Project.NameKey project) throws StorageException { return query(AccountPredicates.watchedProject(project)); } diff --git a/java/com/google/gerrit/server/query/change/AddedPredicate.java b/java/com/google/gerrit/server/query/change/AddedPredicate.java index 099e841b50..9e55c83d6a 100644 --- a/java/com/google/gerrit/server/query/change/AddedPredicate.java +++ b/java/com/google/gerrit/server/query/change/AddedPredicate.java @@ -14,9 +14,9 @@ package com.google.gerrit.server.query.change; +import com.google.gerrit.exceptions.StorageException; import com.google.gerrit.index.query.QueryParseException; import com.google.gerrit.server.index.change.ChangeField; -import com.google.gwtorm.server.OrmException; public class AddedPredicate extends IntegerRangeChangePredicate { public AddedPredicate(String value) throws QueryParseException { @@ -24,7 +24,7 @@ public class AddedPredicate extends IntegerRangeChangePredicate { } @Override - protected Integer getValueInt(ChangeData changeData) throws OrmException { + protected Integer getValueInt(ChangeData changeData) throws StorageException { return ChangeField.ADDED.get(changeData); } } diff --git a/java/com/google/gerrit/server/query/change/AfterPredicate.java b/java/com/google/gerrit/server/query/change/AfterPredicate.java index de57b3bfba..8d96850c47 100644 --- a/java/com/google/gerrit/server/query/change/AfterPredicate.java +++ b/java/com/google/gerrit/server/query/change/AfterPredicate.java @@ -14,9 +14,9 @@ package com.google.gerrit.server.query.change; +import com.google.gerrit.exceptions.StorageException; import com.google.gerrit.index.query.QueryParseException; import com.google.gerrit.server.index.change.ChangeField; -import com.google.gwtorm.server.OrmException; import java.util.Date; public class AfterPredicate extends TimestampRangeChangePredicate { @@ -38,7 +38,7 @@ public class AfterPredicate extends TimestampRangeChangePredicate { } @Override - public boolean match(ChangeData cd) throws OrmException { + public boolean match(ChangeData cd) throws StorageException { return cd.change().getLastUpdatedOn().getTime() >= cut.getTime(); } } diff --git a/java/com/google/gerrit/server/query/change/AgePredicate.java b/java/com/google/gerrit/server/query/change/AgePredicate.java index 29f1b8af70..0dc5242d55 100644 --- a/java/com/google/gerrit/server/query/change/AgePredicate.java +++ b/java/com/google/gerrit/server/query/change/AgePredicate.java @@ -17,11 +17,11 @@ package com.google.gerrit.server.query.change; import static java.util.concurrent.TimeUnit.MILLISECONDS; import static java.util.concurrent.TimeUnit.SECONDS; +import com.google.gerrit.exceptions.StorageException; import com.google.gerrit.reviewdb.client.Change; import com.google.gerrit.server.config.ConfigUtil; import com.google.gerrit.server.index.change.ChangeField; import com.google.gerrit.server.util.time.TimeUtil; -import com.google.gwtorm.server.OrmException; import java.sql.Timestamp; public class AgePredicate extends TimestampRangeChangePredicate { @@ -46,7 +46,7 @@ public class AgePredicate extends TimestampRangeChangePredicate { } @Override - public boolean match(ChangeData object) throws OrmException { + public boolean match(ChangeData object) throws StorageException { Change change = object.change(); return change != null && change.getLastUpdatedOn().getTime() <= cut; } diff --git a/java/com/google/gerrit/server/query/change/AndChangeSource.java b/java/com/google/gerrit/server/query/change/AndChangeSource.java index ff1ab23c89..d2b104a7af 100644 --- a/java/com/google/gerrit/server/query/change/AndChangeSource.java +++ b/java/com/google/gerrit/server/query/change/AndChangeSource.java @@ -14,11 +14,11 @@ package com.google.gerrit.server.query.change; +import com.google.gerrit.exceptions.StorageException; +import com.google.gerrit.exceptions.StorageRuntimeException; import com.google.gerrit.index.query.AndSource; import com.google.gerrit.index.query.IsVisibleToPredicate; import com.google.gerrit.index.query.Predicate; -import com.google.gwtorm.server.OrmException; -import com.google.gwtorm.server.OrmRuntimeException; import java.util.Collection; import java.util.List; @@ -43,12 +43,13 @@ public class AndChangeSource extends AndSource implements ChangeData } @Override - protected List transformBuffer(List buffer) throws OrmRuntimeException { + protected List transformBuffer(List buffer) + throws StorageRuntimeException { if (!hasChange()) { try { ChangeData.ensureChangeLoaded(buffer); - } catch (OrmException e) { - throw new OrmRuntimeException(e); + } catch (StorageException e) { + throw new StorageRuntimeException(e); } } return super.transformBuffer(buffer); diff --git a/java/com/google/gerrit/server/query/change/AssigneePredicate.java b/java/com/google/gerrit/server/query/change/AssigneePredicate.java index 63f7467bfd..7af31d2b94 100644 --- a/java/com/google/gerrit/server/query/change/AssigneePredicate.java +++ b/java/com/google/gerrit/server/query/change/AssigneePredicate.java @@ -14,9 +14,9 @@ package com.google.gerrit.server.query.change; +import com.google.gerrit.exceptions.StorageException; import com.google.gerrit.reviewdb.client.Account; import com.google.gerrit.server.index.change.ChangeField; -import com.google.gwtorm.server.OrmException; public class AssigneePredicate extends ChangeIndexPredicate { protected final Account.Id id; @@ -27,7 +27,7 @@ public class AssigneePredicate extends ChangeIndexPredicate { } @Override - public boolean match(ChangeData object) throws OrmException { + public boolean match(ChangeData object) throws StorageException { if (id.get() == ChangeField.NO_ASSIGNEE) { Account.Id assignee = object.change().getAssignee(); return assignee == null; diff --git a/java/com/google/gerrit/server/query/change/AuthorPredicate.java b/java/com/google/gerrit/server/query/change/AuthorPredicate.java index 3ee3352345..2217167ed0 100644 --- a/java/com/google/gerrit/server/query/change/AuthorPredicate.java +++ b/java/com/google/gerrit/server/query/change/AuthorPredicate.java @@ -17,8 +17,8 @@ package com.google.gerrit.server.query.change; import static com.google.gerrit.server.index.change.ChangeField.AUTHOR; import static com.google.gerrit.server.query.change.ChangeQueryBuilder.FIELD_AUTHOR; +import com.google.gerrit.exceptions.StorageException; import com.google.gerrit.server.index.change.ChangeField; -import com.google.gwtorm.server.OrmException; import java.io.IOException; public class AuthorPredicate extends ChangeIndexPredicate { @@ -27,11 +27,11 @@ public class AuthorPredicate extends ChangeIndexPredicate { } @Override - public boolean match(ChangeData object) throws OrmException { + public boolean match(ChangeData object) throws StorageException { try { return ChangeField.getAuthorParts(object).contains(getValue().toLowerCase()); } catch (IOException e) { - throw new OrmException(e); + throw new StorageException(e); } } diff --git a/java/com/google/gerrit/server/query/change/BeforePredicate.java b/java/com/google/gerrit/server/query/change/BeforePredicate.java index 4d6ed69333..bf77decdbd 100644 --- a/java/com/google/gerrit/server/query/change/BeforePredicate.java +++ b/java/com/google/gerrit/server/query/change/BeforePredicate.java @@ -14,9 +14,9 @@ package com.google.gerrit.server.query.change; +import com.google.gerrit.exceptions.StorageException; import com.google.gerrit.index.query.QueryParseException; import com.google.gerrit.server.index.change.ChangeField; -import com.google.gwtorm.server.OrmException; import java.util.Date; public class BeforePredicate extends TimestampRangeChangePredicate { @@ -38,7 +38,7 @@ public class BeforePredicate extends TimestampRangeChangePredicate { } @Override - public boolean match(ChangeData cd) throws OrmException { + public boolean match(ChangeData cd) throws StorageException { return cd.change().getLastUpdatedOn().getTime() <= cut.getTime(); } } diff --git a/java/com/google/gerrit/server/query/change/BooleanPredicate.java b/java/com/google/gerrit/server/query/change/BooleanPredicate.java index 5930b74d66..b349617f12 100644 --- a/java/com/google/gerrit/server/query/change/BooleanPredicate.java +++ b/java/com/google/gerrit/server/query/change/BooleanPredicate.java @@ -14,8 +14,8 @@ package com.google.gerrit.server.query.change; +import com.google.gerrit.exceptions.StorageException; import com.google.gerrit.index.FieldDef; -import com.google.gwtorm.server.OrmException; public class BooleanPredicate extends ChangeIndexPredicate { public BooleanPredicate(FieldDef field) { @@ -23,7 +23,7 @@ public class BooleanPredicate extends ChangeIndexPredicate { } @Override - public boolean match(ChangeData object) throws OrmException { + public boolean match(ChangeData object) throws StorageException { return getValue().equals(getField().get(object)); } diff --git a/java/com/google/gerrit/server/query/change/ChangeData.java b/java/com/google/gerrit/server/query/change/ChangeData.java index 5a300b4911..4114d7aa3f 100644 --- a/java/com/google/gerrit/server/query/change/ChangeData.java +++ b/java/com/google/gerrit/server/query/change/ChangeData.java @@ -34,6 +34,7 @@ import com.google.gerrit.common.Nullable; import com.google.gerrit.common.data.LabelTypes; import com.google.gerrit.common.data.SubmitRecord; import com.google.gerrit.common.data.SubmitTypeRecord; +import com.google.gerrit.exceptions.StorageException; import com.google.gerrit.extensions.client.DiffPreferencesInfo.Whitespace; import com.google.gerrit.extensions.restapi.BadRequestException; import com.google.gerrit.extensions.restapi.ResourceConflictException; @@ -73,7 +74,6 @@ import com.google.gerrit.server.project.ProjectCache; import com.google.gerrit.server.project.ProjectState; import com.google.gerrit.server.project.SubmitRuleEvaluator; import com.google.gerrit.server.project.SubmitRuleOptions; -import com.google.gwtorm.server.OrmException; import com.google.inject.Inject; import com.google.inject.assistedinject.Assisted; import java.io.IOException; @@ -101,7 +101,7 @@ import org.eclipse.jgit.revwalk.RevCommit; import org.eclipse.jgit.revwalk.RevWalk; public class ChangeData { - public static List asChanges(List changeDatas) throws OrmException { + public static List asChanges(List changeDatas) throws StorageException { List result = new ArrayList<>(changeDatas.size()); for (ChangeData cd : changeDatas) { result.add(cd.change()); @@ -113,7 +113,7 @@ public class ChangeData { return changes.stream().collect(toMap(ChangeData::getId, Function.identity())); } - public static void ensureChangeLoaded(Iterable changes) throws OrmException { + public static void ensureChangeLoaded(Iterable changes) throws StorageException { ChangeData first = Iterables.getFirst(changes, null); if (first == null) { return; @@ -124,7 +124,8 @@ public class ChangeData { } } - public static void ensureAllPatchSetsLoaded(Iterable changes) throws OrmException { + public static void ensureAllPatchSetsLoaded(Iterable changes) + throws StorageException { ChangeData first = Iterables.getFirst(changes, null); if (first == null) { return; @@ -135,7 +136,8 @@ public class ChangeData { } } - public static void ensureCurrentPatchSetLoaded(Iterable changes) throws OrmException { + public static void ensureCurrentPatchSetLoaded(Iterable changes) + throws StorageException { ChangeData first = Iterables.getFirst(changes, null); if (first == null) { return; @@ -147,7 +149,7 @@ public class ChangeData { } public static void ensureCurrentApprovalsLoaded(Iterable changes) - throws OrmException { + throws StorageException { ChangeData first = Iterables.getFirst(changes, null); if (first == null) { return; @@ -158,7 +160,7 @@ public class ChangeData { } } - public static void ensureMessagesLoaded(Iterable changes) throws OrmException { + public static void ensureMessagesLoaded(Iterable changes) throws StorageException { ChangeData first = Iterables.getFirst(changes, null); if (first == null) { return; @@ -170,7 +172,7 @@ public class ChangeData { } public static void ensureReviewedByLoadedForOpenChanges(Iterable changes) - throws OrmException { + throws StorageException { List pending = new ArrayList<>(); for (ChangeData cd : changes) { if (cd.reviewedBy == null && cd.change().isNew()) { @@ -362,14 +364,14 @@ public class ChangeData { return allUsersName; } - public void setCurrentFilePaths(List filePaths) throws OrmException { + public void setCurrentFilePaths(List filePaths) throws StorageException { PatchSet ps = currentPatchSet(); if (ps != null) { currentFiles = ImmutableList.copyOf(filePaths); } } - public List currentFilePaths() throws IOException, OrmException { + public List currentFilePaths() throws IOException, StorageException { if (currentFiles == null) { if (!lazyLoad) { return Collections.emptyList(); @@ -380,7 +382,7 @@ public class ChangeData { return currentFiles; } - private Optional getDiffSummary() throws OrmException, IOException { + private Optional getDiffSummary() throws StorageException, IOException { if (diffSummary == null) { if (!lazyLoad) { return Optional.empty(); @@ -408,7 +410,7 @@ public class ChangeData { return diffSummary; } - private Optional computeChangedLines() throws OrmException, IOException { + private Optional computeChangedLines() throws StorageException, IOException { Optional ds = getDiffSummary(); if (ds.isPresent()) { return Optional.of(ds.get().getChangedLines()); @@ -416,7 +418,7 @@ public class ChangeData { return Optional.empty(); } - public Optional changedLines() throws OrmException, IOException { + public Optional changedLines() throws StorageException, IOException { if (changedLines == null) { if (!lazyLoad) { return Optional.empty(); @@ -450,7 +452,7 @@ public class ChangeData { visibleTo = user; } - public Change change() throws OrmException { + public Change change() throws StorageException { if (change == null && lazyLoad) { reloadChange(); } @@ -461,41 +463,41 @@ public class ChangeData { change = c; } - public Change reloadChange() throws OrmException { + public Change reloadChange() throws StorageException { try { notes = notesFactory.createChecked(project, legacyId); } catch (NoSuchChangeException e) { - throw new OrmException("Unable to load change " + legacyId, e); + throw new StorageException("Unable to load change " + legacyId, e); } change = notes.getChange(); setPatchSets(null); return change; } - public LabelTypes getLabelTypes() throws OrmException { + public LabelTypes getLabelTypes() throws StorageException { if (labelTypes == null) { ProjectState state; try { state = projectCache.checkedGet(project()); } catch (IOException e) { - throw new OrmException("project state not available", e); + throw new StorageException("project state not available", e); } labelTypes = state.getLabelTypes(change().getDest()); } return labelTypes; } - public ChangeNotes notes() throws OrmException { + public ChangeNotes notes() throws StorageException { if (notes == null) { if (!lazyLoad) { - throw new OrmException("ChangeNotes not available, lazyLoad = false"); + throw new StorageException("ChangeNotes not available, lazyLoad = false"); } notes = notesFactory.create(project(), legacyId); } return notes; } - public PatchSet currentPatchSet() throws OrmException { + public PatchSet currentPatchSet() throws StorageException { if (currentPatchSet == null) { Change c = change(); if (c == null) { @@ -511,7 +513,7 @@ public class ChangeData { return currentPatchSet; } - public List currentApprovals() throws OrmException { + public List currentApprovals() throws StorageException { if (currentApprovals == null) { if (!lazyLoad) { return Collections.emptyList(); @@ -524,7 +526,7 @@ public class ChangeData { currentApprovals = ImmutableList.copyOf( approvalsUtil.byPatchSet(notes(), c.currentPatchSetId(), null, null)); - } catch (OrmException e) { + } catch (StorageException e) { if (e.getCause() instanceof NoSuchChangeException) { currentApprovals = Collections.emptyList(); } else { @@ -540,7 +542,7 @@ public class ChangeData { currentApprovals = approvals; } - public String commitMessage() throws IOException, OrmException { + public String commitMessage() throws IOException, StorageException { if (commitMessage == null) { if (!loadCommitData()) { return null; @@ -549,7 +551,7 @@ public class ChangeData { return commitMessage; } - public List commitFooters() throws IOException, OrmException { + public List commitFooters() throws IOException, StorageException { if (commitFooters == null) { if (!loadCommitData()) { return null; @@ -558,11 +560,11 @@ public class ChangeData { return commitFooters; } - public ListMultimap trackingFooters() throws IOException, OrmException { + public ListMultimap trackingFooters() throws IOException, StorageException { return trackingFooters.extract(commitFooters()); } - public PersonIdent getAuthor() throws IOException, OrmException { + public PersonIdent getAuthor() throws IOException, StorageException { if (author == null) { if (!loadCommitData()) { return null; @@ -571,7 +573,7 @@ public class ChangeData { return author; } - public PersonIdent getCommitter() throws IOException, OrmException { + public PersonIdent getCommitter() throws IOException, StorageException { if (committer == null) { if (!loadCommitData()) { return null; @@ -581,7 +583,7 @@ public class ChangeData { } private boolean loadCommitData() - throws OrmException, RepositoryNotFoundException, IOException, MissingObjectException, + throws StorageException, RepositoryNotFoundException, IOException, MissingObjectException, IncorrectObjectTypeException { PatchSet ps = currentPatchSet(); if (ps == null) { @@ -602,9 +604,9 @@ public class ChangeData { /** * @return patches for the change, in patch set ID order. - * @throws OrmException an error occurred reading the database. + * @throws StorageException an error occurred reading the database. */ - public Collection patchSets() throws OrmException { + public Collection patchSets() throws StorageException { if (patchSets == null) { patchSets = psUtil.byChange(notes()); } @@ -618,9 +620,9 @@ public class ChangeData { /** * @return patch with the given ID, or null if it does not exist. - * @throws OrmException an error occurred reading the database. + * @throws StorageException an error occurred reading the database. */ - public PatchSet patchSet(PatchSet.Id psId) throws OrmException { + public PatchSet patchSet(PatchSet.Id psId) throws StorageException { if (currentPatchSet != null && currentPatchSet.getId().equals(psId)) { return currentPatchSet; } @@ -635,9 +637,9 @@ public class ChangeData { /** * @return all patch set approvals for the change, keyed by ID, ordered by timestamp within each * patch set. - * @throws OrmException an error occurred reading the database. + * @throws StorageException an error occurred reading the database. */ - public ListMultimap approvals() throws OrmException { + public ListMultimap approvals() throws StorageException { if (allApprovals == null) { if (!lazyLoad) { return ImmutableListMultimap.of(); @@ -649,13 +651,13 @@ public class ChangeData { /** * @return The submit ('SUBM') approval label - * @throws OrmException an error occurred reading the database. + * @throws StorageException an error occurred reading the database. */ - public Optional getSubmitApproval() throws OrmException { + public Optional getSubmitApproval() throws StorageException { return currentApprovals().stream().filter(PatchSetApproval::isLegacySubmit).findFirst(); } - public ReviewerSet reviewers() throws OrmException { + public ReviewerSet reviewers() throws StorageException { if (reviewers == null) { if (!lazyLoad) { return ReviewerSet.empty(); @@ -673,7 +675,7 @@ public class ChangeData { return reviewers; } - public ReviewerByEmailSet reviewersByEmail() throws OrmException { + public ReviewerByEmailSet reviewersByEmail() throws StorageException { if (reviewersByEmail == null) { if (!lazyLoad) { return ReviewerByEmailSet.empty(); @@ -699,7 +701,7 @@ public class ChangeData { return this.pendingReviewers; } - public ReviewerSet pendingReviewers() throws OrmException { + public ReviewerSet pendingReviewers() throws StorageException { if (pendingReviewers == null) { if (!lazyLoad) { return ReviewerSet.empty(); @@ -717,7 +719,7 @@ public class ChangeData { return pendingReviewersByEmail; } - public ReviewerByEmailSet pendingReviewersByEmail() throws OrmException { + public ReviewerByEmailSet pendingReviewersByEmail() throws StorageException { if (pendingReviewersByEmail == null) { if (!lazyLoad) { return ReviewerByEmailSet.empty(); @@ -727,7 +729,7 @@ public class ChangeData { return pendingReviewersByEmail; } - public List reviewerUpdates() throws OrmException { + public List reviewerUpdates() throws StorageException { if (reviewerUpdates == null) { if (!lazyLoad) { return Collections.emptyList(); @@ -745,7 +747,7 @@ public class ChangeData { return reviewerUpdates; } - public Collection publishedComments() throws OrmException { + public Collection publishedComments() throws StorageException { if (publishedComments == null) { if (!lazyLoad) { return Collections.emptyList(); @@ -755,7 +757,7 @@ public class ChangeData { return publishedComments; } - public Collection robotComments() throws OrmException { + public Collection robotComments() throws StorageException { if (robotComments == null) { if (!lazyLoad) { return Collections.emptyList(); @@ -765,7 +767,7 @@ public class ChangeData { return robotComments; } - public Integer unresolvedCommentCount() throws OrmException { + public Integer unresolvedCommentCount() throws StorageException { if (unresolvedCommentCount == null) { if (!lazyLoad) { return null; @@ -819,7 +821,7 @@ public class ChangeData { this.unresolvedCommentCount = count; } - public Integer totalCommentCount() throws OrmException { + public Integer totalCommentCount() throws StorageException { if (totalCommentCount == null) { if (!lazyLoad) { return null; @@ -836,7 +838,7 @@ public class ChangeData { this.totalCommentCount = count; } - public List messages() throws OrmException { + public List messages() throws StorageException { if (messages == null) { if (!lazyLoad) { return Collections.emptyList(); @@ -880,7 +882,7 @@ public class ChangeData { } @Nullable - public Boolean isMergeable() throws OrmException { + public Boolean isMergeable() throws StorageException { if (mergeable == null) { Change c = change(); if (c == null) { @@ -920,18 +922,18 @@ public class ChangeData { c.getDest(), repo); } catch (IOException e) { - throw new OrmException(e); + throw new StorageException(e); } } } return mergeable; } - public Set editsByUser() throws OrmException { + public Set editsByUser() throws StorageException { return editRefs().keySet(); } - public Map editRefs() throws OrmException { + public Map editRefs() throws StorageException { if (editsByUser == null) { if (!lazyLoad) { return Collections.emptyMap(); @@ -953,17 +955,17 @@ public class ChangeData { } } } catch (IOException e) { - throw new OrmException(e); + throw new StorageException(e); } } return editsByUser; } - public Set draftsByUser() throws OrmException { + public Set draftsByUser() throws StorageException { return draftRefs().keySet(); } - public Map draftRefs() throws OrmException { + public Map draftRefs() throws StorageException { if (draftsByUser == null) { if (!lazyLoad) { return Collections.emptyMap(); @@ -991,7 +993,7 @@ public class ChangeData { return draftsByUser; } - public boolean isReviewedBy(Account.Id accountId) throws OrmException { + public boolean isReviewedBy(Account.Id accountId) throws StorageException { Collection stars = stars(accountId); PatchSet ps = currentPatchSet(); @@ -1008,7 +1010,7 @@ public class ChangeData { return reviewedBy().contains(accountId); } - public Set reviewedBy() throws OrmException { + public Set reviewedBy() throws StorageException { if (reviewedBy == null) { if (!lazyLoad) { return Collections.emptySet(); @@ -1040,7 +1042,7 @@ public class ChangeData { this.reviewedBy = reviewedBy; } - public Set hashtags() throws OrmException { + public Set hashtags() throws StorageException { if (hashtags == null) { if (!lazyLoad) { return Collections.emptySet(); @@ -1054,7 +1056,7 @@ public class ChangeData { this.hashtags = hashtags; } - public ImmutableListMultimap stars() throws OrmException { + public ImmutableListMultimap stars() throws StorageException { if (stars == null) { if (!lazyLoad) { return ImmutableListMultimap.of(); @@ -1072,7 +1074,7 @@ public class ChangeData { this.stars = ImmutableListMultimap.copyOf(stars); } - public ImmutableMap starRefs() throws OrmException { + public ImmutableMap starRefs() throws StorageException { if (starRefs == null) { if (!lazyLoad) { return ImmutableMap.of(); @@ -1082,7 +1084,7 @@ public class ChangeData { return starRefs; } - public Set stars(Account.Id accountId) throws OrmException { + public Set stars(Account.Id accountId) throws StorageException { if (starsOf != null) { if (!starsOf.accountId().equals(accountId)) { starsOf = null; @@ -1106,14 +1108,14 @@ public class ChangeData { * false otherwise. */ @Nullable - public Boolean isPureRevert() throws OrmException { + public Boolean isPureRevert() throws StorageException { if (change().getRevertOf() == null) { return null; } try { return pureRevert.get(notes(), Optional.empty()); } catch (IOException | BadRequestException | ResourceConflictException e) { - throw new OrmException("could not compute pure revert", e); + throw new StorageException("could not compute pure revert", e); } } diff --git a/java/com/google/gerrit/server/query/change/ChangeIdPredicate.java b/java/com/google/gerrit/server/query/change/ChangeIdPredicate.java index d541d189cf..aea7ad5b3d 100644 --- a/java/com/google/gerrit/server/query/change/ChangeIdPredicate.java +++ b/java/com/google/gerrit/server/query/change/ChangeIdPredicate.java @@ -14,9 +14,9 @@ package com.google.gerrit.server.query.change; +import com.google.gerrit.exceptions.StorageException; import com.google.gerrit.reviewdb.client.Change; import com.google.gerrit.server.index.change.ChangeField; -import com.google.gwtorm.server.OrmException; /** Predicate over Change-Id strings (aka Change.Key). */ public class ChangeIdPredicate extends ChangeIndexPredicate { @@ -25,7 +25,7 @@ public class ChangeIdPredicate extends ChangeIndexPredicate { } @Override - public boolean match(ChangeData cd) throws OrmException { + public boolean match(ChangeData cd) throws StorageException { Change change = cd.change(); if (change == null) { return false; diff --git a/java/com/google/gerrit/server/query/change/ChangeIsVisibleToPredicate.java b/java/com/google/gerrit/server/query/change/ChangeIsVisibleToPredicate.java index a793cf24af..ffaf5a0a54 100644 --- a/java/com/google/gerrit/server/query/change/ChangeIsVisibleToPredicate.java +++ b/java/com/google/gerrit/server/query/change/ChangeIsVisibleToPredicate.java @@ -15,6 +15,7 @@ package com.google.gerrit.server.query.change; import com.google.common.flogger.FluentLogger; +import com.google.gerrit.exceptions.StorageException; import com.google.gerrit.extensions.restapi.AuthException; import com.google.gerrit.index.query.IsVisibleToPredicate; import com.google.gerrit.reviewdb.client.Change; @@ -27,7 +28,6 @@ import com.google.gerrit.server.permissions.PermissionBackend; import com.google.gerrit.server.permissions.PermissionBackendException; import com.google.gerrit.server.project.ProjectCache; import com.google.gerrit.server.project.ProjectState; -import com.google.gwtorm.server.OrmException; import com.google.inject.Inject; import com.google.inject.Provider; import java.io.IOException; @@ -58,7 +58,7 @@ public class ChangeIsVisibleToPredicate extends IsVisibleToPredicate } @Override - public boolean match(ChangeData cd) throws OrmException { + public boolean match(ChangeData cd) throws StorageException { if (cd.fastIsVisibleTo(user)) { return true; } @@ -80,7 +80,7 @@ public class ChangeIsVisibleToPredicate extends IsVisibleToPredicate return false; } } catch (IOException e) { - throw new OrmException("unable to read project state", e); + throw new StorageException("unable to read project state", e); } PermissionBackend.WithUser withUser = @@ -97,7 +97,7 @@ public class ChangeIsVisibleToPredicate extends IsVisibleToPredicate cd, cd.project()); return false; } - throw new OrmException("unable to check permissions on change " + cd.getId(), e); + throw new StorageException("unable to check permissions on change " + cd.getId(), e); } catch (AuthException e) { logger.atFine().log("Filter out non-visisble change: %s", cd); return false; diff --git a/java/com/google/gerrit/server/query/change/ChangeQueryBuilder.java b/java/com/google/gerrit/server/query/change/ChangeQueryBuilder.java index 1177282d81..5c26970073 100644 --- a/java/com/google/gerrit/server/query/change/ChangeQueryBuilder.java +++ b/java/com/google/gerrit/server/query/change/ChangeQueryBuilder.java @@ -32,6 +32,7 @@ import com.google.gerrit.common.data.GroupDescription; import com.google.gerrit.common.data.GroupReference; import com.google.gerrit.common.data.SubmitRecord; import com.google.gerrit.exceptions.NotSignedInException; +import com.google.gerrit.exceptions.StorageException; import com.google.gerrit.extensions.registration.DynamicMap; import com.google.gerrit.index.IndexConfig; import com.google.gerrit.index.Schema; @@ -75,7 +76,6 @@ import com.google.gerrit.server.permissions.PermissionBackend; import com.google.gerrit.server.project.ChildProjects; import com.google.gerrit.server.project.ProjectCache; import com.google.gerrit.server.submit.SubmitDryRun; -import com.google.gwtorm.server.OrmException; import com.google.inject.Inject; import com.google.inject.Provider; import com.google.inject.ProvisionException; @@ -608,7 +608,8 @@ public class ChangeQueryBuilder extends QueryBuilder conflicts(String value) throws OrmException, QueryParseException { + public Predicate conflicts(String value) + throws StorageException, QueryParseException { List changes = parseChange(value); List> or = new ArrayList<>(changes.size()); for (Change c : changes) { @@ -782,7 +783,7 @@ public class ChangeQueryBuilder extends QueryBuilder label(String name) - throws QueryParseException, OrmException, IOException, ConfigInvalidException { + throws QueryParseException, StorageException, IOException, ConfigInvalidException { Set accounts = null; AccountGroup.UUID group = null; @@ -882,7 +883,7 @@ public class ChangeQueryBuilder extends QueryBuilder starredby(String who) - throws QueryParseException, OrmException, IOException, ConfigInvalidException { + throws QueryParseException, StorageException, IOException, ConfigInvalidException { return starredby(parseAccount(who)); } @@ -900,7 +901,7 @@ public class ChangeQueryBuilder extends QueryBuilder watchedby(String who) - throws QueryParseException, OrmException, IOException, ConfigInvalidException { + throws QueryParseException, StorageException, IOException, ConfigInvalidException { Set m = parseAccount(who); List p = Lists.newArrayListWithCapacity(m.size()); @@ -925,7 +926,7 @@ public class ChangeQueryBuilder extends QueryBuilder draftby(String who) - throws QueryParseException, OrmException, IOException, ConfigInvalidException { + throws QueryParseException, StorageException, IOException, ConfigInvalidException { Set m = parseAccount(who); List> p = Lists.newArrayListWithCapacity(m.size()); for (Account.Id id : m) { @@ -940,7 +941,7 @@ public class ChangeQueryBuilder extends QueryBuilder visibleto(String who) - throws QueryParseException, OrmException, IOException, ConfigInvalidException { + throws QueryParseException, StorageException, IOException, ConfigInvalidException { if (isSelf(who)) { return is_visible(); } @@ -983,13 +984,13 @@ public class ChangeQueryBuilder extends QueryBuilder o(String who) - throws QueryParseException, OrmException, IOException, ConfigInvalidException { + throws QueryParseException, StorageException, IOException, ConfigInvalidException { return owner(who); } @Operator public Predicate owner(String who) - throws QueryParseException, OrmException, IOException, ConfigInvalidException { + throws QueryParseException, StorageException, IOException, ConfigInvalidException { return owner(parseAccount(who)); } @@ -1002,7 +1003,7 @@ public class ChangeQueryBuilder extends QueryBuilder ownerDefaultField(String who) - throws QueryParseException, OrmException, IOException, ConfigInvalidException { + throws QueryParseException, StorageException, IOException, ConfigInvalidException { Set accounts = parseAccount(who); if (accounts.size() > MAX_ACCOUNTS_PER_DEFAULT_FIELD) { return Predicate.any(); @@ -1012,7 +1013,7 @@ public class ChangeQueryBuilder extends QueryBuilder assignee(String who) - throws QueryParseException, OrmException, IOException, ConfigInvalidException { + throws QueryParseException, StorageException, IOException, ConfigInvalidException { return assignee(parseAccount(who)); } @@ -1047,23 +1048,23 @@ public class ChangeQueryBuilder extends QueryBuilder r(String who) - throws QueryParseException, OrmException, IOException, ConfigInvalidException { + throws QueryParseException, StorageException, IOException, ConfigInvalidException { return reviewer(who); } @Operator public Predicate reviewer(String who) - throws QueryParseException, OrmException, IOException, ConfigInvalidException { + throws QueryParseException, StorageException, IOException, ConfigInvalidException { return reviewer(who, false); } private Predicate reviewerDefaultField(String who) - throws QueryParseException, OrmException, IOException, ConfigInvalidException { + throws QueryParseException, StorageException, IOException, ConfigInvalidException { return reviewer(who, true); } private Predicate reviewer(String who, boolean forDefaultField) - throws QueryParseException, OrmException, IOException, ConfigInvalidException { + throws QueryParseException, StorageException, IOException, ConfigInvalidException { Predicate byState = reviewerByState(who, ReviewerStateInternal.REVIEWER, forDefaultField); if (Objects.equals(byState, Predicate.any())) { @@ -1077,7 +1078,7 @@ public class ChangeQueryBuilder extends QueryBuilder cc(String who) - throws QueryParseException, OrmException, IOException, ConfigInvalidException { + throws QueryParseException, StorageException, IOException, ConfigInvalidException { return reviewerByState(who, ReviewerStateInternal.CC, false); } @@ -1131,7 +1132,7 @@ public class ChangeQueryBuilder extends QueryBuilder commentby(String who) - throws QueryParseException, OrmException, IOException, ConfigInvalidException { + throws QueryParseException, StorageException, IOException, ConfigInvalidException { return commentby(parseAccount(who)); } @@ -1145,7 +1146,7 @@ public class ChangeQueryBuilder extends QueryBuilder from(String who) - throws QueryParseException, OrmException, IOException, ConfigInvalidException { + throws QueryParseException, StorageException, IOException, ConfigInvalidException { Set ownerIds = parseAccount(who); return Predicate.or(owner(ownerIds), commentby(ownerIds)); } @@ -1170,7 +1171,7 @@ public class ChangeQueryBuilder extends QueryBuilder reviewedby(String who) - throws QueryParseException, OrmException, IOException, ConfigInvalidException { + throws QueryParseException, StorageException, IOException, ConfigInvalidException { return IsReviewedPredicate.create(parseAccount(who)); } @@ -1260,7 +1261,7 @@ public class ChangeQueryBuilder extends QueryBuilderany())) { predicates.add(p); } - } catch (OrmException | IOException | ConfigInvalidException | QueryParseException e) { + } catch (StorageException | IOException | ConfigInvalidException | QueryParseException e) { // Skip. } try { @@ -1268,13 +1269,13 @@ public class ChangeQueryBuilder extends QueryBuilderany())) { predicates.add(p); } - } catch (OrmException | IOException | ConfigInvalidException | QueryParseException e) { + } catch (StorageException | IOException | ConfigInvalidException | QueryParseException e) { // Skip. } predicates.add(file(query)); try { predicates.add(label(query)); - } catch (OrmException | IOException | ConfigInvalidException | QueryParseException e) { + } catch (StorageException | IOException | ConfigInvalidException | QueryParseException e) { // Skip. } predicates.add(commit(query)); @@ -1328,7 +1329,7 @@ public class ChangeQueryBuilder extends QueryBuilder parseAccount(String who) - throws QueryParseException, OrmException, IOException, ConfigInvalidException { + throws QueryParseException, StorageException, IOException, ConfigInvalidException { try { return args.accountResolver.resolve(who).asNonEmptyIdSet(); } catch (UnresolvableAccountException e) { @@ -1347,7 +1348,7 @@ public class ChangeQueryBuilder extends QueryBuilder parseChange(String value) throws OrmException, QueryParseException { + private List parseChange(String value) throws StorageException, QueryParseException { if (PAT_LEGACY_ID.matcher(value).matches()) { return asChanges(args.queryProvider.get().byLegacyChangeId(Change.Id.parse(value))); } else if (PAT_CHANGE_ID.matcher(value).matches()) { @@ -1374,7 +1375,7 @@ public class ChangeQueryBuilder extends QueryBuilder reviewerByState( String who, ReviewerStateInternal state, boolean forDefaultField) - throws QueryParseException, OrmException, IOException, ConfigInvalidException { + throws QueryParseException, StorageException, IOException, ConfigInvalidException { Predicate reviewerByEmailPredicate = null; if (args.index.getSchema().hasField(ChangeField.REVIEWER_BY_EMAIL)) { Address address = Address.tryParse(who); diff --git a/java/com/google/gerrit/server/query/change/ChangeStatusPredicate.java b/java/com/google/gerrit/server/query/change/ChangeStatusPredicate.java index 5a7efb8863..a316e70ba2 100644 --- a/java/com/google/gerrit/server/query/change/ChangeStatusPredicate.java +++ b/java/com/google/gerrit/server/query/change/ChangeStatusPredicate.java @@ -18,11 +18,11 @@ import static com.google.common.base.Preconditions.checkState; import static java.util.Objects.requireNonNull; import com.google.gerrit.common.Nullable; +import com.google.gerrit.exceptions.StorageException; import com.google.gerrit.index.query.Predicate; import com.google.gerrit.reviewdb.client.Change; import com.google.gerrit.reviewdb.client.Change.Status; import com.google.gerrit.server.index.change.ChangeField; -import com.google.gwtorm.server.OrmException; import java.util.ArrayList; import java.util.List; import java.util.Map; @@ -119,7 +119,7 @@ public final class ChangeStatusPredicate extends ChangeIndexPredicate { } @Override - public boolean match(ChangeData object) throws OrmException { + public boolean match(ChangeData object) throws StorageException { Change change = object.change(); return change != null && Objects.equals(status, change.getStatus()); } diff --git a/java/com/google/gerrit/server/query/change/CommentByPredicate.java b/java/com/google/gerrit/server/query/change/CommentByPredicate.java index 7ad7afe28a..f0c2034dfd 100644 --- a/java/com/google/gerrit/server/query/change/CommentByPredicate.java +++ b/java/com/google/gerrit/server/query/change/CommentByPredicate.java @@ -14,11 +14,11 @@ package com.google.gerrit.server.query.change; +import com.google.gerrit.exceptions.StorageException; import com.google.gerrit.reviewdb.client.Account; import com.google.gerrit.reviewdb.client.ChangeMessage; import com.google.gerrit.reviewdb.client.Comment; import com.google.gerrit.server.index.change.ChangeField; -import com.google.gwtorm.server.OrmException; import java.util.Objects; public class CommentByPredicate extends ChangeIndexPredicate { @@ -34,7 +34,7 @@ public class CommentByPredicate extends ChangeIndexPredicate { } @Override - public boolean match(ChangeData cd) throws OrmException { + public boolean match(ChangeData cd) throws StorageException { for (ChangeMessage m : cd.messages()) { if (Objects.equals(m.getAuthor(), id)) { return true; diff --git a/java/com/google/gerrit/server/query/change/CommentPredicate.java b/java/com/google/gerrit/server/query/change/CommentPredicate.java index 5a6d186ad8..3d70185c95 100644 --- a/java/com/google/gerrit/server/query/change/CommentPredicate.java +++ b/java/com/google/gerrit/server/query/change/CommentPredicate.java @@ -14,12 +14,12 @@ package com.google.gerrit.server.query.change; +import com.google.gerrit.exceptions.StorageException; import com.google.gerrit.index.query.Predicate; import com.google.gerrit.index.query.QueryParseException; import com.google.gerrit.server.index.change.ChangeField; import com.google.gerrit.server.index.change.ChangeIndex; import com.google.gerrit.server.index.change.IndexedChangeQuery; -import com.google.gwtorm.server.OrmException; public class CommentPredicate extends ChangeIndexPredicate { protected final ChangeIndex index; @@ -30,7 +30,7 @@ public class CommentPredicate extends ChangeIndexPredicate { } @Override - public boolean match(ChangeData object) throws OrmException { + public boolean match(ChangeData object) throws StorageException { try { Predicate p = Predicate.and(new LegacyChangeIdPredicate(object.getId()), this); for (ChangeData cData : index.getSource(p, IndexedChangeQuery.oneResult()).read()) { @@ -39,7 +39,7 @@ public class CommentPredicate extends ChangeIndexPredicate { } } } catch (QueryParseException e) { - throw new OrmException(e); + throw new StorageException(e); } return false; diff --git a/java/com/google/gerrit/server/query/change/CommitPredicate.java b/java/com/google/gerrit/server/query/change/CommitPredicate.java index d1ae529e53..3062eb9c84 100644 --- a/java/com/google/gerrit/server/query/change/CommitPredicate.java +++ b/java/com/google/gerrit/server/query/change/CommitPredicate.java @@ -18,9 +18,9 @@ import static com.google.gerrit.server.index.change.ChangeField.COMMIT; import static com.google.gerrit.server.index.change.ChangeField.EXACT_COMMIT; import static org.eclipse.jgit.lib.Constants.OBJECT_ID_STRING_LENGTH; +import com.google.gerrit.exceptions.StorageException; import com.google.gerrit.index.FieldDef; import com.google.gerrit.reviewdb.client.PatchSet; -import com.google.gwtorm.server.OrmException; public class CommitPredicate extends ChangeIndexPredicate { static FieldDef commitField(String id) { @@ -35,7 +35,7 @@ public class CommitPredicate extends ChangeIndexPredicate { } @Override - public boolean match(ChangeData object) throws OrmException { + public boolean match(ChangeData object) throws StorageException { String id = getValue().toLowerCase(); for (PatchSet p : object.patchSets()) { if (equals(p, id)) { diff --git a/java/com/google/gerrit/server/query/change/CommitterPredicate.java b/java/com/google/gerrit/server/query/change/CommitterPredicate.java index 797cb9d04f..a9e05f48cb 100644 --- a/java/com/google/gerrit/server/query/change/CommitterPredicate.java +++ b/java/com/google/gerrit/server/query/change/CommitterPredicate.java @@ -17,8 +17,8 @@ package com.google.gerrit.server.query.change; import static com.google.gerrit.server.index.change.ChangeField.COMMITTER; import static com.google.gerrit.server.query.change.ChangeQueryBuilder.FIELD_COMMITTER; +import com.google.gerrit.exceptions.StorageException; import com.google.gerrit.server.index.change.ChangeField; -import com.google.gwtorm.server.OrmException; import java.io.IOException; public class CommitterPredicate extends ChangeIndexPredicate { @@ -27,11 +27,11 @@ public class CommitterPredicate extends ChangeIndexPredicate { } @Override - public boolean match(ChangeData object) throws OrmException { + public boolean match(ChangeData object) throws StorageException { try { return ChangeField.getCommitterParts(object).contains(getValue().toLowerCase()); } catch (IOException e) { - throw new OrmException(e); + throw new StorageException(e); } } diff --git a/java/com/google/gerrit/server/query/change/ConflictsPredicate.java b/java/com/google/gerrit/server/query/change/ConflictsPredicate.java index ada9f2706d..46dab43bc4 100644 --- a/java/com/google/gerrit/server/query/change/ConflictsPredicate.java +++ b/java/com/google/gerrit/server/query/change/ConflictsPredicate.java @@ -20,6 +20,7 @@ import static java.util.concurrent.TimeUnit.MINUTES; import com.google.common.flogger.FluentLogger; import com.google.gerrit.common.data.SubmitTypeRecord; +import com.google.gerrit.exceptions.StorageException; import com.google.gerrit.index.query.PostFilterPredicate; import com.google.gerrit.index.query.Predicate; import com.google.gerrit.index.query.QueryParseException; @@ -35,7 +36,6 @@ import com.google.gerrit.server.project.ProjectState; import com.google.gerrit.server.query.change.ChangeQueryBuilder.Arguments; import com.google.gerrit.server.submit.IntegrationException; import com.google.gerrit.server.submit.SubmitDryRun; -import com.google.gwtorm.server.OrmException; import java.io.IOException; import java.util.ArrayList; import java.util.HashSet; @@ -61,7 +61,7 @@ public class ConflictsPredicate { try { cd = args.changeDataFactory.create(c); files = cd.currentFilePaths(); - } catch (IOException | OrmException e) { + } catch (IOException | StorageException e) { warnWithOccasionalStackTrace( e, "Error constructing conflicts predicates for change %s in %s", @@ -158,7 +158,7 @@ public class ConflictsPredicate { args.conflictsCache.put(conflictsKey, conflicts); return conflicts; } - } catch (IntegrationException | NoSuchProjectException | OrmException | IOException e) { + } catch (IntegrationException | NoSuchProjectException | StorageException | IOException e) { ObjectId finalOther = other; warnWithOccasionalStackTrace( e, @@ -186,7 +186,7 @@ public class ConflictsPredicate { accepted.add(rw.parseCommit(tip)); } return accepted; - } catch (OrmException | IOException e) { + } catch (StorageException | IOException e) { throw new IntegrationException("Failed to determine already accepted commits.", e); } } @@ -205,7 +205,7 @@ public class ConflictsPredicate { this.projectCache = projectCache; } - ObjectId getTestAgainst() throws OrmException { + ObjectId getTestAgainst() throws StorageException { if (testAgainst == null) { testAgainst = ObjectId.fromString(cd.currentPatchSet().getRevision().get()); } diff --git a/java/com/google/gerrit/server/query/change/DeletedPredicate.java b/java/com/google/gerrit/server/query/change/DeletedPredicate.java index 6232fc5815..f0085d5d76 100644 --- a/java/com/google/gerrit/server/query/change/DeletedPredicate.java +++ b/java/com/google/gerrit/server/query/change/DeletedPredicate.java @@ -14,9 +14,9 @@ package com.google.gerrit.server.query.change; +import com.google.gerrit.exceptions.StorageException; import com.google.gerrit.index.query.QueryParseException; import com.google.gerrit.server.index.change.ChangeField; -import com.google.gwtorm.server.OrmException; public class DeletedPredicate extends IntegerRangeChangePredicate { public DeletedPredicate(String value) throws QueryParseException { @@ -24,7 +24,7 @@ public class DeletedPredicate extends IntegerRangeChangePredicate { } @Override - protected Integer getValueInt(ChangeData changeData) throws OrmException { + protected Integer getValueInt(ChangeData changeData) throws StorageException { return ChangeField.DELETED.get(changeData); } } diff --git a/java/com/google/gerrit/server/query/change/DeltaPredicate.java b/java/com/google/gerrit/server/query/change/DeltaPredicate.java index aae0a201b2..15dfaeea50 100644 --- a/java/com/google/gerrit/server/query/change/DeltaPredicate.java +++ b/java/com/google/gerrit/server/query/change/DeltaPredicate.java @@ -14,9 +14,9 @@ package com.google.gerrit.server.query.change; +import com.google.gerrit.exceptions.StorageException; import com.google.gerrit.index.query.QueryParseException; import com.google.gerrit.server.index.change.ChangeField; -import com.google.gwtorm.server.OrmException; public class DeltaPredicate extends IntegerRangeChangePredicate { public DeltaPredicate(String value) throws QueryParseException { @@ -24,7 +24,7 @@ public class DeltaPredicate extends IntegerRangeChangePredicate { } @Override - protected Integer getValueInt(ChangeData changeData) throws OrmException { + protected Integer getValueInt(ChangeData changeData) throws StorageException { return ChangeField.DELTA.get(changeData); } } diff --git a/java/com/google/gerrit/server/query/change/DestinationPredicate.java b/java/com/google/gerrit/server/query/change/DestinationPredicate.java index a824a87ceb..90e69bfc7b 100644 --- a/java/com/google/gerrit/server/query/change/DestinationPredicate.java +++ b/java/com/google/gerrit/server/query/change/DestinationPredicate.java @@ -14,10 +14,10 @@ package com.google.gerrit.server.query.change; +import com.google.gerrit.exceptions.StorageException; import com.google.gerrit.index.query.PostFilterPredicate; import com.google.gerrit.reviewdb.client.Branch; import com.google.gerrit.reviewdb.client.Change; -import com.google.gwtorm.server.OrmException; import java.util.Set; public class DestinationPredicate extends PostFilterPredicate { @@ -29,7 +29,7 @@ public class DestinationPredicate extends PostFilterPredicate { } @Override - public boolean match(ChangeData object) throws OrmException { + public boolean match(ChangeData object) throws StorageException { Change change = object.change(); if (change == null) { return false; diff --git a/java/com/google/gerrit/server/query/change/DirectoryPredicate.java b/java/com/google/gerrit/server/query/change/DirectoryPredicate.java index 676a2089c1..b5a286a5f3 100644 --- a/java/com/google/gerrit/server/query/change/DirectoryPredicate.java +++ b/java/com/google/gerrit/server/query/change/DirectoryPredicate.java @@ -15,8 +15,8 @@ package com.google.gerrit.server.query.change; import com.google.common.base.CharMatcher; +import com.google.gerrit.exceptions.StorageException; import com.google.gerrit.server.index.change.ChangeField; -import com.google.gwtorm.server.OrmException; import java.util.Locale; public class DirectoryPredicate extends ChangeIndexPredicate { @@ -29,7 +29,7 @@ public class DirectoryPredicate extends ChangeIndexPredicate { } @Override - public boolean match(ChangeData cd) throws OrmException { + public boolean match(ChangeData cd) throws StorageException { return ChangeField.getDirectories(cd).contains(value); } diff --git a/java/com/google/gerrit/server/query/change/EditByPredicate.java b/java/com/google/gerrit/server/query/change/EditByPredicate.java index 3238dc9faa..cb87a33791 100644 --- a/java/com/google/gerrit/server/query/change/EditByPredicate.java +++ b/java/com/google/gerrit/server/query/change/EditByPredicate.java @@ -14,9 +14,9 @@ package com.google.gerrit.server.query.change; +import com.google.gerrit.exceptions.StorageException; import com.google.gerrit.reviewdb.client.Account; import com.google.gerrit.server.index.change.ChangeField; -import com.google.gwtorm.server.OrmException; public class EditByPredicate extends ChangeIndexPredicate { protected final Account.Id id; @@ -27,7 +27,7 @@ public class EditByPredicate extends ChangeIndexPredicate { } @Override - public boolean match(ChangeData cd) throws OrmException { + public boolean match(ChangeData cd) throws StorageException { return cd.editsByUser().contains(id); } diff --git a/java/com/google/gerrit/server/query/change/EqualsFilePredicate.java b/java/com/google/gerrit/server/query/change/EqualsFilePredicate.java index b5a2d05ad5..b3e073b754 100644 --- a/java/com/google/gerrit/server/query/change/EqualsFilePredicate.java +++ b/java/com/google/gerrit/server/query/change/EqualsFilePredicate.java @@ -14,10 +14,10 @@ package com.google.gerrit.server.query.change; +import com.google.gerrit.exceptions.StorageException; import com.google.gerrit.index.query.Predicate; import com.google.gerrit.server.index.change.ChangeField; import com.google.gerrit.server.query.change.ChangeQueryBuilder.Arguments; -import com.google.gwtorm.server.OrmException; public class EqualsFilePredicate extends ChangeIndexPredicate { public static Predicate create(Arguments args, String value) { @@ -33,7 +33,7 @@ public class EqualsFilePredicate extends ChangeIndexPredicate { } @Override - public boolean match(ChangeData object) throws OrmException { + public boolean match(ChangeData object) throws StorageException { return ChangeField.getFileParts(object).contains(value); } diff --git a/java/com/google/gerrit/server/query/change/EqualsLabelPredicate.java b/java/com/google/gerrit/server/query/change/EqualsLabelPredicate.java index 430d8c3cfd..78f43c5273 100644 --- a/java/com/google/gerrit/server/query/change/EqualsLabelPredicate.java +++ b/java/com/google/gerrit/server/query/change/EqualsLabelPredicate.java @@ -16,6 +16,7 @@ package com.google.gerrit.server.query.change; import com.google.gerrit.common.data.LabelType; import com.google.gerrit.common.data.LabelTypes; +import com.google.gerrit.exceptions.StorageException; import com.google.gerrit.extensions.restapi.AuthException; import com.google.gerrit.reviewdb.client.Account; import com.google.gerrit.reviewdb.client.AccountGroup; @@ -28,7 +29,6 @@ import com.google.gerrit.server.permissions.PermissionBackend; import com.google.gerrit.server.permissions.PermissionBackendException; import com.google.gerrit.server.project.ProjectCache; import com.google.gerrit.server.project.ProjectState; -import com.google.gwtorm.server.OrmException; import java.io.IOException; public class EqualsLabelPredicate extends ChangeIndexPredicate { @@ -53,7 +53,7 @@ public class EqualsLabelPredicate extends ChangeIndexPredicate { } @Override - public boolean match(ChangeData object) throws OrmException { + public boolean match(ChangeData object) throws StorageException { Change c = object.change(); if (c == null) { // The change has disappeared. diff --git a/java/com/google/gerrit/server/query/change/EqualsPathPredicate.java b/java/com/google/gerrit/server/query/change/EqualsPathPredicate.java index fc00283e87..d5f34b1a77 100644 --- a/java/com/google/gerrit/server/query/change/EqualsPathPredicate.java +++ b/java/com/google/gerrit/server/query/change/EqualsPathPredicate.java @@ -14,8 +14,8 @@ package com.google.gerrit.server.query.change; +import com.google.gerrit.exceptions.StorageException; import com.google.gerrit.server.index.change.ChangeField; -import com.google.gwtorm.server.OrmException; import java.io.IOException; import java.util.Collections; import java.util.List; @@ -26,12 +26,12 @@ public class EqualsPathPredicate extends ChangeIndexPredicate { } @Override - public boolean match(ChangeData object) throws OrmException { + public boolean match(ChangeData object) throws StorageException { List files; try { files = object.currentFilePaths(); } catch (IOException e) { - throw new OrmException(e); + throw new StorageException(e); } return Collections.binarySearch(files, value) >= 0; } diff --git a/java/com/google/gerrit/server/query/change/ExactAuthorPredicate.java b/java/com/google/gerrit/server/query/change/ExactAuthorPredicate.java index bca5d3bfba..39c68c6464 100644 --- a/java/com/google/gerrit/server/query/change/ExactAuthorPredicate.java +++ b/java/com/google/gerrit/server/query/change/ExactAuthorPredicate.java @@ -17,8 +17,8 @@ package com.google.gerrit.server.query.change; import static com.google.gerrit.server.index.change.ChangeField.EXACT_AUTHOR; import static com.google.gerrit.server.query.change.ChangeQueryBuilder.FIELD_EXACTAUTHOR; +import com.google.gerrit.exceptions.StorageException; import com.google.gerrit.server.index.change.ChangeField; -import com.google.gwtorm.server.OrmException; import java.io.IOException; import java.util.Locale; @@ -28,11 +28,11 @@ public class ExactAuthorPredicate extends ChangeIndexPredicate { } @Override - public boolean match(ChangeData object) throws OrmException { + public boolean match(ChangeData object) throws StorageException { try { return ChangeField.getAuthorNameAndEmail(object).contains(getValue()); } catch (IOException e) { - throw new OrmException(e); + throw new StorageException(e); } } diff --git a/java/com/google/gerrit/server/query/change/ExactCommitterPredicate.java b/java/com/google/gerrit/server/query/change/ExactCommitterPredicate.java index 3fae5e5286..6624babd6a 100644 --- a/java/com/google/gerrit/server/query/change/ExactCommitterPredicate.java +++ b/java/com/google/gerrit/server/query/change/ExactCommitterPredicate.java @@ -17,8 +17,8 @@ package com.google.gerrit.server.query.change; import static com.google.gerrit.server.index.change.ChangeField.EXACT_COMMITTER; import static com.google.gerrit.server.query.change.ChangeQueryBuilder.FIELD_EXACTCOMMITTER; +import com.google.gerrit.exceptions.StorageException; import com.google.gerrit.server.index.change.ChangeField; -import com.google.gwtorm.server.OrmException; import java.io.IOException; import java.util.Locale; @@ -28,11 +28,11 @@ public class ExactCommitterPredicate extends ChangeIndexPredicate { } @Override - public boolean match(ChangeData object) throws OrmException { + public boolean match(ChangeData object) throws StorageException { try { return ChangeField.getCommitterNameAndEmail(object).contains(getValue()); } catch (IOException e) { - throw new OrmException(e); + throw new StorageException(e); } } diff --git a/java/com/google/gerrit/server/query/change/ExactTopicPredicate.java b/java/com/google/gerrit/server/query/change/ExactTopicPredicate.java index 138cce50e0..54327f9a97 100644 --- a/java/com/google/gerrit/server/query/change/ExactTopicPredicate.java +++ b/java/com/google/gerrit/server/query/change/ExactTopicPredicate.java @@ -16,8 +16,8 @@ package com.google.gerrit.server.query.change; import static com.google.gerrit.server.index.change.ChangeField.EXACT_TOPIC; +import com.google.gerrit.exceptions.StorageException; import com.google.gerrit.reviewdb.client.Change; -import com.google.gwtorm.server.OrmException; public class ExactTopicPredicate extends ChangeIndexPredicate { public ExactTopicPredicate(String topic) { @@ -25,7 +25,7 @@ public class ExactTopicPredicate extends ChangeIndexPredicate { } @Override - public boolean match(ChangeData object) throws OrmException { + public boolean match(ChangeData object) throws StorageException { Change change = object.change(); if (change == null) { return false; diff --git a/java/com/google/gerrit/server/query/change/FileExtensionListPredicate.java b/java/com/google/gerrit/server/query/change/FileExtensionListPredicate.java index fc33b65e04..5867ac1e5f 100644 --- a/java/com/google/gerrit/server/query/change/FileExtensionListPredicate.java +++ b/java/com/google/gerrit/server/query/change/FileExtensionListPredicate.java @@ -17,8 +17,8 @@ package com.google.gerrit.server.query.change; import static java.util.stream.Collectors.joining; import com.google.common.base.Splitter; +import com.google.gerrit.exceptions.StorageException; import com.google.gerrit.server.index.change.ChangeField; -import com.google.gwtorm.server.OrmException; public class FileExtensionListPredicate extends ChangeIndexPredicate { private static String clean(String extList) { @@ -34,7 +34,7 @@ public class FileExtensionListPredicate extends ChangeIndexPredicate { } @Override - public boolean match(ChangeData cd) throws OrmException { + public boolean match(ChangeData cd) throws StorageException { return ChangeField.getAllExtensionsAsList(cd).equals(value); } diff --git a/java/com/google/gerrit/server/query/change/FileExtensionPredicate.java b/java/com/google/gerrit/server/query/change/FileExtensionPredicate.java index 5353f11712..d131b00df0 100644 --- a/java/com/google/gerrit/server/query/change/FileExtensionPredicate.java +++ b/java/com/google/gerrit/server/query/change/FileExtensionPredicate.java @@ -14,8 +14,8 @@ package com.google.gerrit.server.query.change; +import com.google.gerrit.exceptions.StorageException; import com.google.gerrit.server.index.change.ChangeField; -import com.google.gwtorm.server.OrmException; import java.util.Locale; public class FileExtensionPredicate extends ChangeIndexPredicate { @@ -31,7 +31,7 @@ public class FileExtensionPredicate extends ChangeIndexPredicate { } @Override - public boolean match(ChangeData object) throws OrmException { + public boolean match(ChangeData object) throws StorageException { return ChangeField.getExtensions(object).contains(value); } diff --git a/java/com/google/gerrit/server/query/change/FooterPredicate.java b/java/com/google/gerrit/server/query/change/FooterPredicate.java index 1d7d19bef5..0aa60484d5 100644 --- a/java/com/google/gerrit/server/query/change/FooterPredicate.java +++ b/java/com/google/gerrit/server/query/change/FooterPredicate.java @@ -14,8 +14,8 @@ package com.google.gerrit.server.query.change; +import com.google.gerrit.exceptions.StorageException; import com.google.gerrit.server.index.change.ChangeField; -import com.google.gwtorm.server.OrmException; import java.util.Locale; public class FooterPredicate extends ChangeIndexPredicate { @@ -35,7 +35,7 @@ public class FooterPredicate extends ChangeIndexPredicate { } @Override - public boolean match(ChangeData cd) throws OrmException { + public boolean match(ChangeData cd) throws StorageException { return ChangeField.getFooters(cd).contains(value); } diff --git a/java/com/google/gerrit/server/query/change/FuzzyTopicPredicate.java b/java/com/google/gerrit/server/query/change/FuzzyTopicPredicate.java index 545b6689f6..c8fb0c60a0 100644 --- a/java/com/google/gerrit/server/query/change/FuzzyTopicPredicate.java +++ b/java/com/google/gerrit/server/query/change/FuzzyTopicPredicate.java @@ -17,12 +17,12 @@ package com.google.gerrit.server.query.change; import static com.google.gerrit.server.index.change.ChangeField.FUZZY_TOPIC; import com.google.common.collect.Iterables; +import com.google.gerrit.exceptions.StorageException; import com.google.gerrit.index.query.Predicate; import com.google.gerrit.index.query.QueryParseException; import com.google.gerrit.reviewdb.client.Change; import com.google.gerrit.server.index.change.ChangeIndex; import com.google.gerrit.server.index.change.IndexedChangeQuery; -import com.google.gwtorm.server.OrmException; public class FuzzyTopicPredicate extends ChangeIndexPredicate { protected final ChangeIndex index; @@ -33,7 +33,7 @@ public class FuzzyTopicPredicate extends ChangeIndexPredicate { } @Override - public boolean match(ChangeData cd) throws OrmException { + public boolean match(ChangeData cd) throws StorageException { Change change = cd.change(); if (change == null) { return false; @@ -48,7 +48,7 @@ public class FuzzyTopicPredicate extends ChangeIndexPredicate { index.getSource(and(thisId, this), IndexedChangeQuery.oneResult()).read(); return !Iterables.isEmpty(results); } catch (QueryParseException e) { - throw new OrmException(e); + throw new StorageException(e); } } diff --git a/java/com/google/gerrit/server/query/change/GroupPredicate.java b/java/com/google/gerrit/server/query/change/GroupPredicate.java index d2645dcf5b..ec2ead276a 100644 --- a/java/com/google/gerrit/server/query/change/GroupPredicate.java +++ b/java/com/google/gerrit/server/query/change/GroupPredicate.java @@ -14,9 +14,9 @@ package com.google.gerrit.server.query.change; +import com.google.gerrit.exceptions.StorageException; import com.google.gerrit.reviewdb.client.PatchSet; import com.google.gerrit.server.index.change.ChangeField; -import com.google.gwtorm.server.OrmException; import java.util.List; public class GroupPredicate extends ChangeIndexPredicate { @@ -25,7 +25,7 @@ public class GroupPredicate extends ChangeIndexPredicate { } @Override - public boolean match(ChangeData cd) throws OrmException { + public boolean match(ChangeData cd) throws StorageException { for (PatchSet ps : cd.patchSets()) { List groups = ps.getGroups(); if (groups != null && groups.contains(getValue())) { diff --git a/java/com/google/gerrit/server/query/change/HasDraftByPredicate.java b/java/com/google/gerrit/server/query/change/HasDraftByPredicate.java index e422b74418..9ffe53409d 100644 --- a/java/com/google/gerrit/server/query/change/HasDraftByPredicate.java +++ b/java/com/google/gerrit/server/query/change/HasDraftByPredicate.java @@ -14,9 +14,9 @@ package com.google.gerrit.server.query.change; +import com.google.gerrit.exceptions.StorageException; import com.google.gerrit.reviewdb.client.Account; import com.google.gerrit.server.index.change.ChangeField; -import com.google.gwtorm.server.OrmException; public class HasDraftByPredicate extends ChangeIndexPredicate { protected final Account.Id accountId; @@ -27,7 +27,7 @@ public class HasDraftByPredicate extends ChangeIndexPredicate { } @Override - public boolean match(ChangeData cd) throws OrmException { + public boolean match(ChangeData cd) throws StorageException { return cd.draftsByUser().contains(accountId); } diff --git a/java/com/google/gerrit/server/query/change/HasStarsPredicate.java b/java/com/google/gerrit/server/query/change/HasStarsPredicate.java index b17fffd0b3..0814a4120f 100644 --- a/java/com/google/gerrit/server/query/change/HasStarsPredicate.java +++ b/java/com/google/gerrit/server/query/change/HasStarsPredicate.java @@ -14,9 +14,9 @@ package com.google.gerrit.server.query.change; +import com.google.gerrit.exceptions.StorageException; import com.google.gerrit.reviewdb.client.Account; import com.google.gerrit.server.index.change.ChangeField; -import com.google.gwtorm.server.OrmException; public class HasStarsPredicate extends ChangeIndexPredicate { protected final Account.Id accountId; @@ -27,7 +27,7 @@ public class HasStarsPredicate extends ChangeIndexPredicate { } @Override - public boolean match(ChangeData cd) throws OrmException { + public boolean match(ChangeData cd) throws StorageException { return cd.stars().containsKey(accountId); } diff --git a/java/com/google/gerrit/server/query/change/HashtagPredicate.java b/java/com/google/gerrit/server/query/change/HashtagPredicate.java index 95ecf89469..ab89d40802 100644 --- a/java/com/google/gerrit/server/query/change/HashtagPredicate.java +++ b/java/com/google/gerrit/server/query/change/HashtagPredicate.java @@ -14,9 +14,9 @@ package com.google.gerrit.server.query.change; +import com.google.gerrit.exceptions.StorageException; import com.google.gerrit.server.change.HashtagsUtil; import com.google.gerrit.server.index.change.ChangeField; -import com.google.gwtorm.server.OrmException; public class HashtagPredicate extends ChangeIndexPredicate { public HashtagPredicate(String hashtag) { @@ -26,7 +26,7 @@ public class HashtagPredicate extends ChangeIndexPredicate { } @Override - public boolean match(ChangeData object) throws OrmException { + public boolean match(ChangeData object) throws StorageException { for (String hashtag : object.notes().load().getHashtags()) { if (hashtag.equalsIgnoreCase(getValue())) { return true; diff --git a/java/com/google/gerrit/server/query/change/InternalChangeQuery.java b/java/com/google/gerrit/server/query/change/InternalChangeQuery.java index 6bd9025b31..0c288ff1f4 100644 --- a/java/com/google/gerrit/server/query/change/InternalChangeQuery.java +++ b/java/com/google/gerrit/server/query/change/InternalChangeQuery.java @@ -25,6 +25,7 @@ import com.google.common.base.Strings; import com.google.common.collect.Iterables; import com.google.common.collect.Lists; import com.google.common.collect.Sets; +import com.google.gerrit.exceptions.StorageException; import com.google.gerrit.index.IndexConfig; import com.google.gerrit.index.query.InternalQuery; import com.google.gerrit.index.query.Predicate; @@ -34,7 +35,6 @@ import com.google.gerrit.reviewdb.client.Project; import com.google.gerrit.reviewdb.client.RefNames; import com.google.gerrit.server.index.change.ChangeIndexCollection; import com.google.gerrit.server.notedb.ChangeNotes; -import com.google.gwtorm.server.OrmException; import com.google.inject.Inject; import com.google.inject.Provider; import java.io.IOException; @@ -91,19 +91,19 @@ public class InternalChangeQuery extends InternalQuery byKey(Change.Key key) throws OrmException { + public List byKey(Change.Key key) throws StorageException { return byKeyPrefix(key.get()); } - public List byKeyPrefix(String prefix) throws OrmException { + public List byKeyPrefix(String prefix) throws StorageException { return query(new ChangeIdPredicate(prefix)); } - public List byLegacyChangeId(Change.Id id) throws OrmException { + public List byLegacyChangeId(Change.Id id) throws StorageException { return query(new LegacyChangeIdPredicate(id)); } - public List byLegacyChangeIds(Collection ids) throws OrmException { + public List byLegacyChangeIds(Collection ids) throws StorageException { List> preds = new ArrayList<>(ids.size()); for (Change.Id id : ids) { preds.add(new LegacyChangeIdPredicate(id)); @@ -111,12 +111,13 @@ public class InternalChangeQuery extends InternalQuery byBranchKey(Branch.NameKey branch, Change.Key key) throws OrmException { + public List byBranchKey(Branch.NameKey branch, Change.Key key) + throws StorageException { return query(byBranchKeyPred(branch, key)); } public List byBranchKeyOpen(Project.NameKey project, String branch, Change.Key key) - throws OrmException { + throws StorageException { return query(and(byBranchKeyPred(new Branch.NameKey(project, branch), key), open())); } @@ -129,21 +130,21 @@ public class InternalChangeQuery extends InternalQuery byProject(Project.NameKey project) throws OrmException { + public List byProject(Project.NameKey project) throws StorageException { return query(project(project)); } - public List byBranchOpen(Branch.NameKey branch) throws OrmException { + public List byBranchOpen(Branch.NameKey branch) throws StorageException { return query(and(ref(branch), project(branch.getParentKey()), open())); } - public List byBranchNew(Branch.NameKey branch) throws OrmException { + public List byBranchNew(Branch.NameKey branch) throws StorageException { return query(and(ref(branch), project(branch.getParentKey()), status(Change.Status.NEW))); } public Iterable byCommitsOnBranchNotMerged( Repository repo, Branch.NameKey branch, Collection hashes) - throws OrmException, IOException { + throws StorageException, IOException { return byCommitsOnBranchNotMerged( repo, branch, @@ -155,7 +156,7 @@ public class InternalChangeQuery extends InternalQuery byCommitsOnBranchNotMerged( Repository repo, Branch.NameKey branch, Collection hashes, int indexLimit) - throws OrmException, IOException { + throws StorageException, IOException { if (hashes.size() > indexLimit) { return byCommitsOnBranchNotMergedFromDatabase(repo, branch, hashes); } @@ -164,7 +165,7 @@ public class InternalChangeQuery extends InternalQuery byCommitsOnBranchNotMergedFromDatabase( Repository repo, Branch.NameKey branch, Collection hashes) - throws OrmException, IOException { + throws StorageException, IOException { Set changeIds = Sets.newHashSetWithExpectedSize(hashes.size()); String lastPrefix = null; for (Ref ref : repo.getRefDatabase().getRefsByPrefix(RefNames.REFS_CHANGES)) { @@ -194,7 +195,7 @@ public class InternalChangeQuery extends InternalQuery byCommitsOnBranchNotMergedFromIndex( - Branch.NameKey branch, Collection hashes) throws OrmException { + Branch.NameKey branch, Collection hashes) throws StorageException { return query( and( ref(branch), @@ -211,50 +212,51 @@ public class InternalChangeQuery extends InternalQuery byProjectOpen(Project.NameKey project) throws OrmException { + public List byProjectOpen(Project.NameKey project) throws StorageException { return query(and(project(project), open())); } - public List byTopicOpen(String topic) throws OrmException { + public List byTopicOpen(String topic) throws StorageException { return query(and(new ExactTopicPredicate(topic), open())); } - public List byCommit(ObjectId id) throws OrmException { + public List byCommit(ObjectId id) throws StorageException { return byCommit(id.name()); } - public List byCommit(String hash) throws OrmException { + public List byCommit(String hash) throws StorageException { return query(commit(hash)); } public List byProjectCommit(Project.NameKey project, ObjectId id) - throws OrmException { + throws StorageException { return byProjectCommit(project, id.name()); } public List byProjectCommit(Project.NameKey project, String hash) - throws OrmException { + throws StorageException { return query(and(project(project), commit(hash))); } public List byProjectCommits(Project.NameKey project, List hashes) - throws OrmException { + throws StorageException { int n = indexConfig.maxTerms() - 1; checkArgument(hashes.size() <= n, "cannot exceed %s commits", n); return query(and(project(project), or(commits(hashes)))); } public List byBranchCommit(String project, String branch, String hash) - throws OrmException { + throws StorageException { return query(byBranchCommitPred(project, branch, hash)); } - public List byBranchCommit(Branch.NameKey branch, String hash) throws OrmException { + public List byBranchCommit(Branch.NameKey branch, String hash) + throws StorageException { return byBranchCommit(branch.getParentKey().get(), branch.get(), hash); } public List byBranchCommitOpen(String project, String branch, String hash) - throws OrmException { + throws StorageException { return query(and(byBranchCommitPred(project, branch, hash), open())); } @@ -268,7 +270,7 @@ public class InternalChangeQuery extends InternalQuery bySubmissionId(String cs) throws OrmException { + public List bySubmissionId(String cs) throws StorageException { if (Strings.isNullOrEmpty(cs)) { return Collections.emptyList(); } @@ -291,7 +293,7 @@ public class InternalChangeQuery extends InternalQuery groups) - throws OrmException { + throws StorageException { // These queries may be complex along multiple dimensions: // * Many groups per change, if there are very many patch sets. This requires partitioning the // list of predicates and combining results. diff --git a/java/com/google/gerrit/server/query/change/IsReviewedPredicate.java b/java/com/google/gerrit/server/query/change/IsReviewedPredicate.java index 7ff5a28600..d88021ae51 100644 --- a/java/com/google/gerrit/server/query/change/IsReviewedPredicate.java +++ b/java/com/google/gerrit/server/query/change/IsReviewedPredicate.java @@ -16,10 +16,10 @@ package com.google.gerrit.server.query.change; import static com.google.gerrit.server.index.change.ChangeField.REVIEWEDBY; +import com.google.gerrit.exceptions.StorageException; import com.google.gerrit.index.query.Predicate; import com.google.gerrit.reviewdb.client.Account; import com.google.gerrit.server.index.change.ChangeField; -import com.google.gwtorm.server.OrmException; import java.util.ArrayList; import java.util.Collection; import java.util.List; @@ -48,7 +48,7 @@ public class IsReviewedPredicate extends ChangeIndexPredicate { } @Override - public boolean match(ChangeData cd) throws OrmException { + public boolean match(ChangeData cd) throws StorageException { Set reviewedBy = cd.reviewedBy(); return !reviewedBy.isEmpty() ? reviewedBy.contains(id) : id.equals(NOT_REVIEWED); } diff --git a/java/com/google/gerrit/server/query/change/IsUnresolvedPredicate.java b/java/com/google/gerrit/server/query/change/IsUnresolvedPredicate.java index 225dc454da..3b52e22a4e 100644 --- a/java/com/google/gerrit/server/query/change/IsUnresolvedPredicate.java +++ b/java/com/google/gerrit/server/query/change/IsUnresolvedPredicate.java @@ -14,9 +14,9 @@ package com.google.gerrit.server.query.change; +import com.google.gerrit.exceptions.StorageException; import com.google.gerrit.index.query.QueryParseException; import com.google.gerrit.server.index.change.ChangeField; -import com.google.gwtorm.server.OrmException; public class IsUnresolvedPredicate extends IntegerRangeChangePredicate { public IsUnresolvedPredicate() throws QueryParseException { @@ -28,7 +28,7 @@ public class IsUnresolvedPredicate extends IntegerRangeChangePredicate { } @Override - protected Integer getValueInt(ChangeData changeData) throws OrmException { + protected Integer getValueInt(ChangeData changeData) throws StorageException { return ChangeField.UNRESOLVED_COMMENT_COUNT.get(changeData); } } diff --git a/java/com/google/gerrit/server/query/change/MessagePredicate.java b/java/com/google/gerrit/server/query/change/MessagePredicate.java index 0cfcedbfb8..1b4d0a3815 100644 --- a/java/com/google/gerrit/server/query/change/MessagePredicate.java +++ b/java/com/google/gerrit/server/query/change/MessagePredicate.java @@ -14,12 +14,12 @@ package com.google.gerrit.server.query.change; +import com.google.gerrit.exceptions.StorageException; import com.google.gerrit.index.query.Predicate; import com.google.gerrit.index.query.QueryParseException; import com.google.gerrit.server.index.change.ChangeField; import com.google.gerrit.server.index.change.ChangeIndex; import com.google.gerrit.server.index.change.IndexedChangeQuery; -import com.google.gwtorm.server.OrmException; /** Predicate to match changes that contains specified text in commit messages body. */ public class MessagePredicate extends ChangeIndexPredicate { @@ -31,7 +31,7 @@ public class MessagePredicate extends ChangeIndexPredicate { } @Override - public boolean match(ChangeData object) throws OrmException { + public boolean match(ChangeData object) throws StorageException { try { Predicate p = Predicate.and(new LegacyChangeIdPredicate(object.getId()), this); for (ChangeData cData : index.getSource(p, IndexedChangeQuery.oneResult()).read()) { @@ -40,7 +40,7 @@ public class MessagePredicate extends ChangeIndexPredicate { } } } catch (QueryParseException e) { - throw new OrmException(e); + throw new StorageException(e); } return false; diff --git a/java/com/google/gerrit/server/query/change/OrSource.java b/java/com/google/gerrit/server/query/change/OrSource.java index dcbf5170ab..b07da595f1 100644 --- a/java/com/google/gerrit/server/query/change/OrSource.java +++ b/java/com/google/gerrit/server/query/change/OrSource.java @@ -14,13 +14,13 @@ package com.google.gerrit.server.query.change; +import com.google.gerrit.exceptions.StorageException; import com.google.gerrit.index.query.FieldBundle; import com.google.gerrit.index.query.ListResultSet; import com.google.gerrit.index.query.OrPredicate; import com.google.gerrit.index.query.Predicate; import com.google.gerrit.index.query.ResultSet; import com.google.gerrit.reviewdb.client.Change; -import com.google.gwtorm.server.OrmException; import java.util.ArrayList; import java.util.Collection; import java.util.HashSet; @@ -35,7 +35,7 @@ public class OrSource extends OrPredicate implements ChangeDataSourc } @Override - public ResultSet read() throws OrmException { + public ResultSet read() throws StorageException { // TODO(spearce) This probably should be more lazy. // List r = new ArrayList<>(); @@ -48,14 +48,14 @@ public class OrSource extends OrPredicate implements ChangeDataSourc } } } else { - throw new OrmException("No ChangeDataSource: " + p); + throw new StorageException("No ChangeDataSource: " + p); } } return new ListResultSet<>(r); } @Override - public ResultSet readRaw() throws OrmException { + public ResultSet readRaw() throws StorageException { throw new UnsupportedOperationException("not implemented"); } diff --git a/java/com/google/gerrit/server/query/change/OutputStreamQuery.java b/java/com/google/gerrit/server/query/change/OutputStreamQuery.java index 09ff687054..6eb6764d5e 100644 --- a/java/com/google/gerrit/server/query/change/OutputStreamQuery.java +++ b/java/com/google/gerrit/server/query/change/OutputStreamQuery.java @@ -19,6 +19,7 @@ import static java.nio.charset.StandardCharsets.UTF_8; import com.google.common.flogger.FluentLogger; import com.google.gerrit.common.data.LabelTypes; +import com.google.gerrit.exceptions.StorageException; import com.google.gerrit.index.query.QueryParseException; import com.google.gerrit.index.query.QueryResult; import com.google.gerrit.reviewdb.client.PatchSet; @@ -34,7 +35,6 @@ import com.google.gerrit.server.project.SubmitRuleEvaluator; import com.google.gerrit.server.project.SubmitRuleOptions; import com.google.gerrit.server.util.time.TimeUtil; import com.google.gson.Gson; -import com.google.gwtorm.server.OrmException; import com.google.inject.Inject; import java.io.BufferedWriter; import java.io.IOException; @@ -219,7 +219,7 @@ public class OutputStreamQuery { stats.moreChanges = results.more(); stats.runTimeMilliseconds = TimeUtil.nowMs() - stats.runTimeMilliseconds; show(stats); - } catch (OrmException err) { + } catch (StorageException err) { logger.atSevere().withCause(err).log("Cannot execute query: %s", queryString); ErrorMessage m = new ErrorMessage(); @@ -242,7 +242,7 @@ public class OutputStreamQuery { private ChangeAttribute buildChangeAttribute( ChangeData d, Map repos, Map revWalks) - throws OrmException, IOException { + throws StorageException, IOException { LabelTypes labelTypes = d.getLabelTypes(); ChangeAttribute c = eventFactory.asChangeAttribute(d.change(), d.notes()); eventFactory.extend(c, d.change()); diff --git a/java/com/google/gerrit/server/query/change/OwnerPredicate.java b/java/com/google/gerrit/server/query/change/OwnerPredicate.java index ff494fc9f3..3169bbdcfa 100644 --- a/java/com/google/gerrit/server/query/change/OwnerPredicate.java +++ b/java/com/google/gerrit/server/query/change/OwnerPredicate.java @@ -14,10 +14,10 @@ package com.google.gerrit.server.query.change; +import com.google.gerrit.exceptions.StorageException; import com.google.gerrit.reviewdb.client.Account; import com.google.gerrit.reviewdb.client.Change; import com.google.gerrit.server.index.change.ChangeField; -import com.google.gwtorm.server.OrmException; public class OwnerPredicate extends ChangeIndexPredicate { protected final Account.Id id; @@ -32,7 +32,7 @@ public class OwnerPredicate extends ChangeIndexPredicate { } @Override - public boolean match(ChangeData object) throws OrmException { + public boolean match(ChangeData object) throws StorageException { Change change = object.change(); return change != null && id.equals(change.getOwner()); } diff --git a/java/com/google/gerrit/server/query/change/OwnerinPredicate.java b/java/com/google/gerrit/server/query/change/OwnerinPredicate.java index c48bdd5673..3b4f5fc8a2 100644 --- a/java/com/google/gerrit/server/query/change/OwnerinPredicate.java +++ b/java/com/google/gerrit/server/query/change/OwnerinPredicate.java @@ -14,11 +14,11 @@ package com.google.gerrit.server.query.change; +import com.google.gerrit.exceptions.StorageException; import com.google.gerrit.index.query.PostFilterPredicate; import com.google.gerrit.reviewdb.client.AccountGroup; import com.google.gerrit.reviewdb.client.Change; import com.google.gerrit.server.IdentifiedUser; -import com.google.gwtorm.server.OrmException; public class OwnerinPredicate extends PostFilterPredicate { protected final IdentifiedUser.GenericFactory userFactory; @@ -31,7 +31,7 @@ public class OwnerinPredicate extends PostFilterPredicate { } @Override - public boolean match(ChangeData object) throws OrmException { + public boolean match(ChangeData object) throws StorageException { final Change change = object.change(); if (change == null) { return false; diff --git a/java/com/google/gerrit/server/query/change/ProjectPredicate.java b/java/com/google/gerrit/server/query/change/ProjectPredicate.java index 09a46a42bd..2c2579a907 100644 --- a/java/com/google/gerrit/server/query/change/ProjectPredicate.java +++ b/java/com/google/gerrit/server/query/change/ProjectPredicate.java @@ -14,10 +14,10 @@ package com.google.gerrit.server.query.change; +import com.google.gerrit.exceptions.StorageException; import com.google.gerrit.reviewdb.client.Change; import com.google.gerrit.reviewdb.client.Project; import com.google.gerrit.server.index.change.ChangeField; -import com.google.gwtorm.server.OrmException; public class ProjectPredicate extends ChangeIndexPredicate { public ProjectPredicate(String id) { @@ -29,7 +29,7 @@ public class ProjectPredicate extends ChangeIndexPredicate { } @Override - public boolean match(ChangeData object) throws OrmException { + public boolean match(ChangeData object) throws StorageException { Change change = object.change(); if (change == null) { return false; diff --git a/java/com/google/gerrit/server/query/change/ProjectPrefixPredicate.java b/java/com/google/gerrit/server/query/change/ProjectPrefixPredicate.java index 28b1302d15..483dac414a 100644 --- a/java/com/google/gerrit/server/query/change/ProjectPrefixPredicate.java +++ b/java/com/google/gerrit/server/query/change/ProjectPrefixPredicate.java @@ -14,9 +14,9 @@ package com.google.gerrit.server.query.change; +import com.google.gerrit.exceptions.StorageException; import com.google.gerrit.reviewdb.client.Change; import com.google.gerrit.server.index.change.ChangeField; -import com.google.gwtorm.server.OrmException; public class ProjectPrefixPredicate extends ChangeIndexPredicate { public ProjectPrefixPredicate(String prefix) { @@ -24,7 +24,7 @@ public class ProjectPrefixPredicate extends ChangeIndexPredicate { } @Override - public boolean match(ChangeData object) throws OrmException { + public boolean match(ChangeData object) throws StorageException { Change c = object.change(); return c != null && c.getDest().getParentKey().get().startsWith(getValue()); } diff --git a/java/com/google/gerrit/server/query/change/RefPredicate.java b/java/com/google/gerrit/server/query/change/RefPredicate.java index c9314e49be..418c45285a 100644 --- a/java/com/google/gerrit/server/query/change/RefPredicate.java +++ b/java/com/google/gerrit/server/query/change/RefPredicate.java @@ -14,9 +14,9 @@ package com.google.gerrit.server.query.change; +import com.google.gerrit.exceptions.StorageException; import com.google.gerrit.reviewdb.client.Change; import com.google.gerrit.server.index.change.ChangeField; -import com.google.gwtorm.server.OrmException; public class RefPredicate extends ChangeIndexPredicate { public RefPredicate(String ref) { @@ -24,7 +24,7 @@ public class RefPredicate extends ChangeIndexPredicate { } @Override - public boolean match(ChangeData object) throws OrmException { + public boolean match(ChangeData object) throws StorageException { Change change = object.change(); if (change == null) { return false; diff --git a/java/com/google/gerrit/server/query/change/RegexDirectoryPredicate.java b/java/com/google/gerrit/server/query/change/RegexDirectoryPredicate.java index 1d49f1e113..1b714ada02 100644 --- a/java/com/google/gerrit/server/query/change/RegexDirectoryPredicate.java +++ b/java/com/google/gerrit/server/query/change/RegexDirectoryPredicate.java @@ -14,8 +14,8 @@ package com.google.gerrit.server.query.change; +import com.google.gerrit.exceptions.StorageException; import com.google.gerrit.server.index.change.ChangeField; -import com.google.gwtorm.server.OrmException; import dk.brics.automaton.RegExp; import dk.brics.automaton.RunAutomaton; @@ -37,7 +37,7 @@ public class RegexDirectoryPredicate extends ChangeRegexPredicate { } @Override - public boolean match(ChangeData cd) throws OrmException { + public boolean match(ChangeData cd) throws StorageException { return ChangeField.getDirectories(cd).stream().anyMatch(pattern::run); } diff --git a/java/com/google/gerrit/server/query/change/RegexPathPredicate.java b/java/com/google/gerrit/server/query/change/RegexPathPredicate.java index f6949041a9..7d6ec91141 100644 --- a/java/com/google/gerrit/server/query/change/RegexPathPredicate.java +++ b/java/com/google/gerrit/server/query/change/RegexPathPredicate.java @@ -14,9 +14,9 @@ package com.google.gerrit.server.query.change; +import com.google.gerrit.exceptions.StorageException; import com.google.gerrit.server.index.change.ChangeField; import com.google.gerrit.server.ioutil.RegexListSearcher; -import com.google.gwtorm.server.OrmException; import java.io.IOException; import java.util.List; @@ -26,12 +26,12 @@ public class RegexPathPredicate extends ChangeRegexPredicate { } @Override - public boolean match(ChangeData object) throws OrmException { + public boolean match(ChangeData object) throws StorageException { List files; try { files = object.currentFilePaths(); } catch (IOException e) { - throw new OrmException(e); + throw new StorageException(e); } return RegexListSearcher.ofStrings(getValue()).search(files).findAny().isPresent(); } diff --git a/java/com/google/gerrit/server/query/change/RegexProjectPredicate.java b/java/com/google/gerrit/server/query/change/RegexProjectPredicate.java index 1efc77d87f..27233ed178 100644 --- a/java/com/google/gerrit/server/query/change/RegexProjectPredicate.java +++ b/java/com/google/gerrit/server/query/change/RegexProjectPredicate.java @@ -14,10 +14,10 @@ package com.google.gerrit.server.query.change; +import com.google.gerrit.exceptions.StorageException; import com.google.gerrit.reviewdb.client.Change; import com.google.gerrit.reviewdb.client.Project; import com.google.gerrit.server.index.change.ChangeField; -import com.google.gwtorm.server.OrmException; import dk.brics.automaton.RegExp; import dk.brics.automaton.RunAutomaton; @@ -39,7 +39,7 @@ public class RegexProjectPredicate extends ChangeRegexPredicate { } @Override - public boolean match(ChangeData object) throws OrmException { + public boolean match(ChangeData object) throws StorageException { Change change = object.change(); if (change == null) { return false; diff --git a/java/com/google/gerrit/server/query/change/RegexRefPredicate.java b/java/com/google/gerrit/server/query/change/RegexRefPredicate.java index 92abafb6ab..96d48df976 100644 --- a/java/com/google/gerrit/server/query/change/RegexRefPredicate.java +++ b/java/com/google/gerrit/server/query/change/RegexRefPredicate.java @@ -14,9 +14,9 @@ package com.google.gerrit.server.query.change; +import com.google.gerrit.exceptions.StorageException; import com.google.gerrit.reviewdb.client.Change; import com.google.gerrit.server.index.change.ChangeField; -import com.google.gwtorm.server.OrmException; import dk.brics.automaton.RegExp; import dk.brics.automaton.RunAutomaton; @@ -38,7 +38,7 @@ public class RegexRefPredicate extends ChangeRegexPredicate { } @Override - public boolean match(ChangeData object) throws OrmException { + public boolean match(ChangeData object) throws StorageException { Change change = object.change(); if (change == null) { return false; diff --git a/java/com/google/gerrit/server/query/change/RegexTopicPredicate.java b/java/com/google/gerrit/server/query/change/RegexTopicPredicate.java index 2b58c88dbc..d30b5b517c 100644 --- a/java/com/google/gerrit/server/query/change/RegexTopicPredicate.java +++ b/java/com/google/gerrit/server/query/change/RegexTopicPredicate.java @@ -16,8 +16,8 @@ package com.google.gerrit.server.query.change; import static com.google.gerrit.server.index.change.ChangeField.EXACT_TOPIC; +import com.google.gerrit.exceptions.StorageException; import com.google.gerrit.reviewdb.client.Change; -import com.google.gwtorm.server.OrmException; import dk.brics.automaton.RegExp; import dk.brics.automaton.RunAutomaton; @@ -39,7 +39,7 @@ public class RegexTopicPredicate extends ChangeRegexPredicate { } @Override - public boolean match(ChangeData object) throws OrmException { + public boolean match(ChangeData object) throws StorageException { Change change = object.change(); if (change == null || change.getTopic() == null) { return false; diff --git a/java/com/google/gerrit/server/query/change/RevertOfPredicate.java b/java/com/google/gerrit/server/query/change/RevertOfPredicate.java index 7f4ade0a71..c6d5d628c8 100644 --- a/java/com/google/gerrit/server/query/change/RevertOfPredicate.java +++ b/java/com/google/gerrit/server/query/change/RevertOfPredicate.java @@ -14,8 +14,8 @@ package com.google.gerrit.server.query.change; +import com.google.gerrit.exceptions.StorageException; import com.google.gerrit.server.index.change.ChangeField; -import com.google.gwtorm.server.OrmException; public class RevertOfPredicate extends ChangeIndexPredicate { public RevertOfPredicate(String revertOf) { @@ -23,7 +23,7 @@ public class RevertOfPredicate extends ChangeIndexPredicate { } @Override - public boolean match(ChangeData cd) throws OrmException { + public boolean match(ChangeData cd) throws StorageException { if (cd.change().getRevertOf() == null) { return false; } diff --git a/java/com/google/gerrit/server/query/change/ReviewerByEmailPredicate.java b/java/com/google/gerrit/server/query/change/ReviewerByEmailPredicate.java index 667c630814..ea4c41ee65 100644 --- a/java/com/google/gerrit/server/query/change/ReviewerByEmailPredicate.java +++ b/java/com/google/gerrit/server/query/change/ReviewerByEmailPredicate.java @@ -16,11 +16,11 @@ package com.google.gerrit.server.query.change; import static com.google.common.base.Preconditions.checkArgument; +import com.google.gerrit.exceptions.StorageException; import com.google.gerrit.index.query.Predicate; import com.google.gerrit.mail.Address; import com.google.gerrit.server.index.change.ChangeField; import com.google.gerrit.server.notedb.ReviewerStateInternal; -import com.google.gwtorm.server.OrmException; class ReviewerByEmailPredicate extends ChangeIndexPredicate { @@ -43,7 +43,7 @@ class ReviewerByEmailPredicate extends ChangeIndexPredicate { } @Override - public boolean match(ChangeData cd) throws OrmException { + public boolean match(ChangeData cd) throws StorageException { return cd.reviewersByEmail().asTable().get(state, adr) != null; } diff --git a/java/com/google/gerrit/server/query/change/ReviewerPredicate.java b/java/com/google/gerrit/server/query/change/ReviewerPredicate.java index 0d1ae44107..4ce9ada101 100644 --- a/java/com/google/gerrit/server/query/change/ReviewerPredicate.java +++ b/java/com/google/gerrit/server/query/change/ReviewerPredicate.java @@ -16,11 +16,11 @@ package com.google.gerrit.server.query.change; import static com.google.common.base.Preconditions.checkArgument; +import com.google.gerrit.exceptions.StorageException; import com.google.gerrit.index.query.Predicate; import com.google.gerrit.reviewdb.client.Account; import com.google.gerrit.server.index.change.ChangeField; import com.google.gerrit.server.notedb.ReviewerStateInternal; -import com.google.gwtorm.server.OrmException; public class ReviewerPredicate extends ChangeIndexPredicate { protected static Predicate forState(Account.Id id, ReviewerStateInternal state) { @@ -50,7 +50,7 @@ public class ReviewerPredicate extends ChangeIndexPredicate { } @Override - public boolean match(ChangeData cd) throws OrmException { + public boolean match(ChangeData cd) throws StorageException { return cd.reviewers().asTable().get(state, id) != null; } diff --git a/java/com/google/gerrit/server/query/change/ReviewerinPredicate.java b/java/com/google/gerrit/server/query/change/ReviewerinPredicate.java index a0aa8b5868..21800dc380 100644 --- a/java/com/google/gerrit/server/query/change/ReviewerinPredicate.java +++ b/java/com/google/gerrit/server/query/change/ReviewerinPredicate.java @@ -14,12 +14,12 @@ package com.google.gerrit.server.query.change; +import com.google.gerrit.exceptions.StorageException; import com.google.gerrit.index.query.PostFilterPredicate; import com.google.gerrit.reviewdb.client.Account; import com.google.gerrit.reviewdb.client.AccountGroup; import com.google.gerrit.server.IdentifiedUser; import com.google.gerrit.server.notedb.ReviewerStateInternal; -import com.google.gwtorm.server.OrmException; public class ReviewerinPredicate extends PostFilterPredicate { protected final IdentifiedUser.GenericFactory userFactory; @@ -36,7 +36,7 @@ public class ReviewerinPredicate extends PostFilterPredicate { } @Override - public boolean match(ChangeData object) throws OrmException { + public boolean match(ChangeData object) throws StorageException { for (Account.Id accountId : object.reviewers().byState(ReviewerStateInternal.REVIEWER)) { IdentifiedUser reviewer = userFactory.create(accountId); if (reviewer.getEffectiveGroups().contains(uuid)) { diff --git a/java/com/google/gerrit/server/query/change/StarPredicate.java b/java/com/google/gerrit/server/query/change/StarPredicate.java index 12d4753d8a..4642aef396 100644 --- a/java/com/google/gerrit/server/query/change/StarPredicate.java +++ b/java/com/google/gerrit/server/query/change/StarPredicate.java @@ -14,10 +14,10 @@ package com.google.gerrit.server.query.change; +import com.google.gerrit.exceptions.StorageException; import com.google.gerrit.reviewdb.client.Account; import com.google.gerrit.server.StarredChangesUtil; import com.google.gerrit.server.index.change.ChangeField; -import com.google.gwtorm.server.OrmException; public class StarPredicate extends ChangeIndexPredicate { protected final Account.Id accountId; @@ -30,7 +30,7 @@ public class StarPredicate extends ChangeIndexPredicate { } @Override - public boolean match(ChangeData cd) throws OrmException { + public boolean match(ChangeData cd) throws StorageException { return cd.stars().get(accountId).contains(label); } diff --git a/java/com/google/gerrit/server/query/change/SubmissionIdPredicate.java b/java/com/google/gerrit/server/query/change/SubmissionIdPredicate.java index 5fdeb68da6..a81616712b 100644 --- a/java/com/google/gerrit/server/query/change/SubmissionIdPredicate.java +++ b/java/com/google/gerrit/server/query/change/SubmissionIdPredicate.java @@ -14,9 +14,9 @@ package com.google.gerrit.server.query.change; +import com.google.gerrit.exceptions.StorageException; import com.google.gerrit.reviewdb.client.Change; import com.google.gerrit.server.index.change.ChangeField; -import com.google.gwtorm.server.OrmException; public class SubmissionIdPredicate extends ChangeIndexPredicate { public SubmissionIdPredicate(String changeSet) { @@ -24,7 +24,7 @@ public class SubmissionIdPredicate extends ChangeIndexPredicate { } @Override - public boolean match(ChangeData object) throws OrmException { + public boolean match(ChangeData object) throws StorageException { Change change = object.change(); if (change == null) { return false; diff --git a/java/com/google/gerrit/server/query/change/SubmitRecordPredicate.java b/java/com/google/gerrit/server/query/change/SubmitRecordPredicate.java index 6a81ff60df..2339652b34 100644 --- a/java/com/google/gerrit/server/query/change/SubmitRecordPredicate.java +++ b/java/com/google/gerrit/server/query/change/SubmitRecordPredicate.java @@ -17,10 +17,10 @@ package com.google.gerrit.server.query.change; import static java.util.stream.Collectors.toList; import com.google.gerrit.common.data.SubmitRecord; +import com.google.gerrit.exceptions.StorageException; import com.google.gerrit.index.query.Predicate; import com.google.gerrit.reviewdb.client.Account; import com.google.gerrit.server.index.change.ChangeField; -import com.google.gwtorm.server.OrmException; import java.util.Set; public class SubmitRecordPredicate extends ChangeIndexPredicate { @@ -41,7 +41,7 @@ public class SubmitRecordPredicate extends ChangeIndexPredicate { } @Override - public boolean match(ChangeData in) throws OrmException { + public boolean match(ChangeData in) throws StorageException { return ChangeField.formatSubmitRecordValues(in).contains(getValue()); } diff --git a/java/com/google/gerrit/server/query/change/SubmittablePredicate.java b/java/com/google/gerrit/server/query/change/SubmittablePredicate.java index 8a2c8896b9..2592fc515c 100644 --- a/java/com/google/gerrit/server/query/change/SubmittablePredicate.java +++ b/java/com/google/gerrit/server/query/change/SubmittablePredicate.java @@ -15,8 +15,8 @@ package com.google.gerrit.server.query.change; import com.google.gerrit.common.data.SubmitRecord; +import com.google.gerrit.exceptions.StorageException; import com.google.gerrit.server.index.change.ChangeField; -import com.google.gwtorm.server.OrmException; public class SubmittablePredicate extends ChangeIndexPredicate { protected final SubmitRecord.Status status; @@ -27,7 +27,7 @@ public class SubmittablePredicate extends ChangeIndexPredicate { } @Override - public boolean match(ChangeData cd) throws OrmException { + public boolean match(ChangeData cd) throws StorageException { return cd.submitRecords(ChangeField.SUBMIT_RULE_OPTIONS_STRICT).stream() .anyMatch(r -> r.status == status); } diff --git a/java/com/google/gerrit/server/query/change/TrackingIdPredicate.java b/java/com/google/gerrit/server/query/change/TrackingIdPredicate.java index 4f751c58da..9075343050 100644 --- a/java/com/google/gerrit/server/query/change/TrackingIdPredicate.java +++ b/java/com/google/gerrit/server/query/change/TrackingIdPredicate.java @@ -15,8 +15,8 @@ package com.google.gerrit.server.query.change; import com.google.common.flogger.FluentLogger; +import com.google.gerrit.exceptions.StorageException; import com.google.gerrit.server.index.change.ChangeField; -import com.google.gwtorm.server.OrmException; import java.io.IOException; public class TrackingIdPredicate extends ChangeIndexPredicate { @@ -27,7 +27,7 @@ public class TrackingIdPredicate extends ChangeIndexPredicate { } @Override - public boolean match(ChangeData cd) throws OrmException { + public boolean match(ChangeData cd) throws StorageException { try { return cd.trackingFooters().containsValue(getValue()); } catch (IOException e) { diff --git a/java/com/google/gerrit/server/query/group/GroupIsVisibleToPredicate.java b/java/com/google/gerrit/server/query/group/GroupIsVisibleToPredicate.java index c7f12399e7..1a6352204b 100644 --- a/java/com/google/gerrit/server/query/group/GroupIsVisibleToPredicate.java +++ b/java/com/google/gerrit/server/query/group/GroupIsVisibleToPredicate.java @@ -16,13 +16,13 @@ package com.google.gerrit.server.query.group; import com.google.common.flogger.FluentLogger; import com.google.gerrit.exceptions.NoSuchGroupException; +import com.google.gerrit.exceptions.StorageException; import com.google.gerrit.index.query.IsVisibleToPredicate; import com.google.gerrit.server.CurrentUser; import com.google.gerrit.server.account.GroupControl; import com.google.gerrit.server.group.InternalGroup; import com.google.gerrit.server.index.IndexUtils; import com.google.gerrit.server.query.account.AccountQueryBuilder; -import com.google.gwtorm.server.OrmException; public class GroupIsVisibleToPredicate extends IsVisibleToPredicate { private static final FluentLogger logger = FluentLogger.forEnclosingClass(); @@ -38,7 +38,7 @@ public class GroupIsVisibleToPredicate extends IsVisibleToPredicate member(String query) - throws QueryParseException, OrmException, ConfigInvalidException, IOException { + throws QueryParseException, StorageException, ConfigInvalidException, IOException { Set accounts = parseAccount(query); List> predicates = accounts.stream().map(GroupPredicates::member).collect(toImmutableList()); @@ -158,7 +158,7 @@ public class GroupQueryBuilder extends QueryBuilder parseAccount(String nameOrEmail) - throws QueryParseException, OrmException, IOException, ConfigInvalidException { + throws QueryParseException, StorageException, IOException, ConfigInvalidException { try { return args.accountResolver.resolve(nameOrEmail).asNonEmptyIdSet(); } catch (UnresolvableAccountException e) { diff --git a/java/com/google/gerrit/server/query/group/InternalGroupQuery.java b/java/com/google/gerrit/server/query/group/InternalGroupQuery.java index 42b38bf62a..33c96f8ffc 100644 --- a/java/com/google/gerrit/server/query/group/InternalGroupQuery.java +++ b/java/com/google/gerrit/server/query/group/InternalGroupQuery.java @@ -19,6 +19,7 @@ import static com.google.common.collect.ImmutableList.toImmutableList; import com.google.common.collect.ImmutableList; import com.google.common.collect.Iterables; import com.google.common.flogger.FluentLogger; +import com.google.gerrit.exceptions.StorageException; import com.google.gerrit.index.IndexConfig; import com.google.gerrit.index.query.InternalQuery; import com.google.gerrit.index.query.Predicate; @@ -26,7 +27,6 @@ import com.google.gerrit.reviewdb.client.Account; import com.google.gerrit.reviewdb.client.AccountGroup; import com.google.gerrit.server.group.InternalGroup; import com.google.gerrit.server.index.group.GroupIndexCollection; -import com.google.gwtorm.server.OrmException; import com.google.inject.Inject; import java.util.List; import java.util.Optional; @@ -46,24 +46,24 @@ public class InternalGroupQuery extends InternalQuery byName(AccountGroup.NameKey groupName) throws OrmException { + public Optional byName(AccountGroup.NameKey groupName) throws StorageException { return getOnlyGroup(GroupPredicates.name(groupName.get()), "group name '" + groupName + "'"); } - public Optional byId(AccountGroup.Id groupId) throws OrmException { + public Optional byId(AccountGroup.Id groupId) throws StorageException { return getOnlyGroup(GroupPredicates.id(groupId), "group id '" + groupId + "'"); } - public List byMember(Account.Id memberId) throws OrmException { + public List byMember(Account.Id memberId) throws StorageException { return query(GroupPredicates.member(memberId)); } - public List bySubgroup(AccountGroup.UUID subgroupId) throws OrmException { + public List bySubgroup(AccountGroup.UUID subgroupId) throws StorageException { return query(GroupPredicates.subgroup(subgroupId)); } private Optional getOnlyGroup( - Predicate predicate, String groupDescription) throws OrmException { + Predicate predicate, String groupDescription) throws StorageException { List groups = query(predicate); if (groups.isEmpty()) { return Optional.empty(); diff --git a/java/com/google/gerrit/server/query/project/ProjectIsVisibleToPredicate.java b/java/com/google/gerrit/server/query/project/ProjectIsVisibleToPredicate.java index b1c5af0553..67ee4c9a0b 100644 --- a/java/com/google/gerrit/server/query/project/ProjectIsVisibleToPredicate.java +++ b/java/com/google/gerrit/server/query/project/ProjectIsVisibleToPredicate.java @@ -15,6 +15,7 @@ package com.google.gerrit.server.query.project; import com.google.common.flogger.FluentLogger; +import com.google.gerrit.exceptions.StorageException; import com.google.gerrit.index.project.ProjectData; import com.google.gerrit.index.query.IsVisibleToPredicate; import com.google.gerrit.server.CurrentUser; @@ -22,7 +23,6 @@ import com.google.gerrit.server.index.IndexUtils; import com.google.gerrit.server.permissions.PermissionBackend; import com.google.gerrit.server.permissions.ProjectPermission; import com.google.gerrit.server.query.account.AccountQueryBuilder; -import com.google.gwtorm.server.OrmException; public class ProjectIsVisibleToPredicate extends IsVisibleToPredicate { private static final FluentLogger logger = FluentLogger.forEnclosingClass(); @@ -37,7 +37,7 @@ public class ProjectIsVisibleToPredicate extends IsVisibleToPredicate { @Override public Map apply(TopLevelResource resource) throws ResourceNotFoundException, ResourceConflictException, IOException, - PermissionBackendException, OrmException { + PermissionBackendException, StorageException { Map access = new TreeMap<>(); for (String p : projects) { access.put(p, getAccess.apply(new Project.NameKey(p))); diff --git a/java/com/google/gerrit/server/restapi/account/AccountsCollection.java b/java/com/google/gerrit/server/restapi/account/AccountsCollection.java index 35922f4e41..6f265610b4 100644 --- a/java/com/google/gerrit/server/restapi/account/AccountsCollection.java +++ b/java/com/google/gerrit/server/restapi/account/AccountsCollection.java @@ -14,6 +14,7 @@ package com.google.gerrit.server.restapi.account; +import com.google.gerrit.exceptions.StorageException; import com.google.gerrit.extensions.registration.DynamicMap; import com.google.gerrit.extensions.restapi.AuthException; import com.google.gerrit.extensions.restapi.IdString; @@ -24,7 +25,6 @@ import com.google.gerrit.extensions.restapi.TopLevelResource; import com.google.gerrit.server.account.AccountResolver; import com.google.gerrit.server.account.AccountResolver.UnresolvableAccountException; import com.google.gerrit.server.account.AccountResource; -import com.google.gwtorm.server.OrmException; import com.google.inject.Inject; import com.google.inject.Provider; import com.google.inject.Singleton; @@ -49,7 +49,7 @@ public class AccountsCollection implements RestCollection apply(AccountResource rsrc, SshKeyInput input) - throws AuthException, BadRequestException, OrmException, IOException, ConfigInvalidException, - PermissionBackendException { + throws AuthException, BadRequestException, StorageException, IOException, + ConfigInvalidException, PermissionBackendException { if (!self.get().hasSameAccountId(rsrc.getUser())) { permissionBackend.currentUser().check(GlobalPermission.ADMINISTRATE_SERVER); } diff --git a/java/com/google/gerrit/server/restapi/account/CreateAccount.java b/java/com/google/gerrit/server/restapi/account/CreateAccount.java index e879ebc18f..75d28dec2d 100644 --- a/java/com/google/gerrit/server/restapi/account/CreateAccount.java +++ b/java/com/google/gerrit/server/restapi/account/CreateAccount.java @@ -24,6 +24,7 @@ import com.google.gerrit.common.data.GlobalCapability; import com.google.gerrit.common.data.GroupDescription; import com.google.gerrit.exceptions.InvalidSshKeyException; import com.google.gerrit.exceptions.NoSuchGroupException; +import com.google.gerrit.exceptions.StorageException; import com.google.gerrit.extensions.annotations.RequiresCapability; import com.google.gerrit.extensions.api.accounts.AccountInput; import com.google.gerrit.extensions.common.AccountInfo; @@ -52,7 +53,6 @@ import com.google.gerrit.server.notedb.Sequences; import com.google.gerrit.server.permissions.PermissionBackendException; import com.google.gerrit.server.plugincontext.PluginSetContext; import com.google.gerrit.server.ssh.SshKeyCache; -import com.google.gwtorm.server.OrmException; import com.google.inject.Inject; import com.google.inject.Provider; import com.google.inject.Singleton; @@ -103,13 +103,13 @@ public class CreateAccount public Response apply( TopLevelResource rsrc, IdString id, @Nullable AccountInput input) throws BadRequestException, ResourceConflictException, UnprocessableEntityException, - OrmException, IOException, ConfigInvalidException, PermissionBackendException { + StorageException, IOException, ConfigInvalidException, PermissionBackendException { return apply(id, input != null ? input : new AccountInput()); } public Response apply(IdString id, AccountInput input) throws BadRequestException, ResourceConflictException, UnprocessableEntityException, - OrmException, IOException, ConfigInvalidException, PermissionBackendException { + StorageException, IOException, ConfigInvalidException, PermissionBackendException { String username = id.get(); if (input.username != null && !username.equals(input.username)) { throw new BadRequestException("username must match URL"); @@ -189,7 +189,7 @@ public class CreateAccount } private void addGroupMember(AccountGroup.UUID groupUuid, Account.Id accountId) - throws OrmException, IOException, NoSuchGroupException, ConfigInvalidException { + throws StorageException, IOException, NoSuchGroupException, ConfigInvalidException { InternalGroupUpdate groupUpdate = InternalGroupUpdate.builder() .setMemberModification(memberIds -> Sets.union(memberIds, ImmutableSet.of(accountId))) diff --git a/java/com/google/gerrit/server/restapi/account/CreateEmail.java b/java/com/google/gerrit/server/restapi/account/CreateEmail.java index 45dcd65984..7d58bbfcfd 100644 --- a/java/com/google/gerrit/server/restapi/account/CreateEmail.java +++ b/java/com/google/gerrit/server/restapi/account/CreateEmail.java @@ -18,6 +18,7 @@ import static com.google.gerrit.extensions.client.AuthType.DEVELOPMENT_BECOME_AN import com.google.common.flogger.FluentLogger; import com.google.gerrit.exceptions.EmailException; +import com.google.gerrit.exceptions.StorageException; import com.google.gerrit.extensions.api.accounts.EmailInput; import com.google.gerrit.extensions.client.AccountFieldName; import com.google.gerrit.extensions.common.EmailInfo; @@ -41,7 +42,6 @@ import com.google.gerrit.server.mail.send.RegisterNewEmailSender; import com.google.gerrit.server.permissions.GlobalPermission; import com.google.gerrit.server.permissions.PermissionBackend; import com.google.gerrit.server.permissions.PermissionBackendException; -import com.google.gwtorm.server.OrmException; import com.google.inject.Inject; import com.google.inject.Provider; import com.google.inject.Singleton; @@ -84,8 +84,8 @@ public class CreateEmail @Override public Response apply(AccountResource rsrc, IdString id, EmailInput input) - throws RestApiException, OrmException, EmailException, MethodNotAllowedException, IOException, - ConfigInvalidException, PermissionBackendException { + throws RestApiException, StorageException, EmailException, MethodNotAllowedException, + IOException, ConfigInvalidException, PermissionBackendException { if (input == null) { input = new EmailInput(); } @@ -103,8 +103,8 @@ public class CreateEmail /** To be used from plugins that want to create emails without permission checks. */ public Response apply(IdentifiedUser user, IdString id, EmailInput input) - throws RestApiException, OrmException, EmailException, MethodNotAllowedException, IOException, - ConfigInvalidException, PermissionBackendException { + throws RestApiException, StorageException, EmailException, MethodNotAllowedException, + IOException, ConfigInvalidException, PermissionBackendException { String email = id.get().trim(); if (input == null) { diff --git a/java/com/google/gerrit/server/restapi/account/DeleteActive.java b/java/com/google/gerrit/server/restapi/account/DeleteActive.java index 43025137b6..a57477abc1 100644 --- a/java/com/google/gerrit/server/restapi/account/DeleteActive.java +++ b/java/com/google/gerrit/server/restapi/account/DeleteActive.java @@ -15,6 +15,7 @@ package com.google.gerrit.server.restapi.account; import com.google.gerrit.common.data.GlobalCapability; +import com.google.gerrit.exceptions.StorageException; import com.google.gerrit.extensions.annotations.RequiresCapability; import com.google.gerrit.extensions.common.Input; import com.google.gerrit.extensions.restapi.ResourceConflictException; @@ -24,7 +25,6 @@ import com.google.gerrit.extensions.restapi.RestModifyView; import com.google.gerrit.server.IdentifiedUser; import com.google.gerrit.server.account.AccountResource; import com.google.gerrit.server.account.SetInactiveFlag; -import com.google.gwtorm.server.OrmException; import com.google.inject.Inject; import com.google.inject.Provider; import com.google.inject.Singleton; @@ -46,7 +46,7 @@ public class DeleteActive implements RestModifyView { @Override public Response apply(AccountResource rsrc, Input input) - throws RestApiException, OrmException, IOException, ConfigInvalidException { + throws RestApiException, StorageException, IOException, ConfigInvalidException { if (self.get().hasSameAccountId(rsrc.getUser())) { throw new ResourceConflictException("cannot deactivate own account"); } diff --git a/java/com/google/gerrit/server/restapi/account/DeleteDraftComments.java b/java/com/google/gerrit/server/restapi/account/DeleteDraftComments.java index 135718b54a..051bac6b61 100644 --- a/java/com/google/gerrit/server/restapi/account/DeleteDraftComments.java +++ b/java/com/google/gerrit/server/restapi/account/DeleteDraftComments.java @@ -21,6 +21,7 @@ import com.google.common.base.CharMatcher; import com.google.common.base.Strings; import com.google.common.collect.ImmutableList; import com.google.gerrit.common.Nullable; +import com.google.gerrit.exceptions.StorageException; import com.google.gerrit.extensions.api.accounts.DeleteDraftCommentsInput; import com.google.gerrit.extensions.api.accounts.DeletedDraftCommentInfo; import com.google.gerrit.extensions.client.ListChangesOption; @@ -56,7 +57,6 @@ import com.google.gerrit.server.update.BatchUpdateOp; import com.google.gerrit.server.update.ChangeContext; import com.google.gerrit.server.update.UpdateException; import com.google.gerrit.server.util.time.TimeUtil; -import com.google.gwtorm.server.OrmException; import com.google.inject.Inject; import com.google.inject.Provider; import com.google.inject.Singleton; @@ -110,7 +110,7 @@ public class DeleteDraftComments @Override public ImmutableList apply( AccountResource rsrc, DeleteDraftCommentsInput input) - throws RestApiException, OrmException, UpdateException { + throws RestApiException, StorageException, UpdateException { CurrentUser user = userProvider.get(); if (!user.isIdentifiedUser()) { throw new AuthException("Authentication required"); @@ -176,7 +176,7 @@ public class DeleteDraftComments @Override public boolean updateChange(ChangeContext ctx) - throws OrmException, PatchListNotAvailableException, PermissionBackendException { + throws StorageException, PatchListNotAvailableException, PermissionBackendException { ImmutableList.Builder comments = ImmutableList.builder(); boolean dirty = false; for (Comment c : commentsUtil.draftByChangeAuthor(ctx.getNotes(), accountId)) { diff --git a/java/com/google/gerrit/server/restapi/account/DeleteEmail.java b/java/com/google/gerrit/server/restapi/account/DeleteEmail.java index 6bacde2220..11e0ac4efd 100644 --- a/java/com/google/gerrit/server/restapi/account/DeleteEmail.java +++ b/java/com/google/gerrit/server/restapi/account/DeleteEmail.java @@ -16,6 +16,7 @@ package com.google.gerrit.server.restapi.account; import static java.util.stream.Collectors.toSet; +import com.google.gerrit.exceptions.StorageException; import com.google.gerrit.extensions.client.AccountFieldName; import com.google.gerrit.extensions.common.Input; import com.google.gerrit.extensions.restapi.AuthException; @@ -35,7 +36,6 @@ import com.google.gerrit.server.account.externalids.ExternalIds; import com.google.gerrit.server.permissions.GlobalPermission; import com.google.gerrit.server.permissions.PermissionBackend; import com.google.gerrit.server.permissions.PermissionBackendException; -import com.google.gwtorm.server.OrmException; import com.google.inject.Inject; import com.google.inject.Provider; import com.google.inject.Singleton; @@ -69,7 +69,7 @@ public class DeleteEmail implements RestModifyView @Override public Response apply(AccountResource.Email rsrc, Input input) throws AuthException, ResourceNotFoundException, ResourceConflictException, - MethodNotAllowedException, OrmException, IOException, ConfigInvalidException, + MethodNotAllowedException, StorageException, IOException, ConfigInvalidException, PermissionBackendException { if (!self.get().hasSameAccountId(rsrc.getUser())) { permissionBackend.currentUser().check(GlobalPermission.MODIFY_ACCOUNT); @@ -79,7 +79,7 @@ public class DeleteEmail implements RestModifyView public Response apply(IdentifiedUser user, String email) throws ResourceNotFoundException, ResourceConflictException, MethodNotAllowedException, - OrmException, IOException, ConfigInvalidException { + StorageException, IOException, ConfigInvalidException { if (!realm.allowsEdit(AccountFieldName.REGISTER_NEW_EMAIL)) { throw new MethodNotAllowedException("realm does not allow deleting emails"); } diff --git a/java/com/google/gerrit/server/restapi/account/DeleteExternalIds.java b/java/com/google/gerrit/server/restapi/account/DeleteExternalIds.java index 9fb535c114..94e40f577b 100644 --- a/java/com/google/gerrit/server/restapi/account/DeleteExternalIds.java +++ b/java/com/google/gerrit/server/restapi/account/DeleteExternalIds.java @@ -18,6 +18,7 @@ import static com.google.gerrit.server.account.externalids.ExternalId.SCHEME_USE import static java.util.stream.Collectors.toMap; import static java.util.stream.Collectors.toSet; +import com.google.gerrit.exceptions.StorageException; import com.google.gerrit.extensions.restapi.BadRequestException; import com.google.gerrit.extensions.restapi.ResourceConflictException; import com.google.gerrit.extensions.restapi.Response; @@ -33,7 +34,6 @@ import com.google.gerrit.server.account.externalids.ExternalIds; import com.google.gerrit.server.permissions.GlobalPermission; import com.google.gerrit.server.permissions.PermissionBackend; import com.google.gerrit.server.permissions.PermissionBackendException; -import com.google.gwtorm.server.OrmException; import com.google.inject.Inject; import com.google.inject.Provider; import com.google.inject.Singleton; @@ -66,7 +66,7 @@ public class DeleteExternalIds implements RestModifyView apply(AccountResource resource, List extIds) - throws RestApiException, IOException, OrmException, ConfigInvalidException, + throws RestApiException, IOException, StorageException, ConfigInvalidException, PermissionBackendException { if (!self.get().hasSameAccountId(resource.getUser())) { permissionBackend.currentUser().check(GlobalPermission.ACCESS_DATABASE); diff --git a/java/com/google/gerrit/server/restapi/account/DeleteSshKey.java b/java/com/google/gerrit/server/restapi/account/DeleteSshKey.java index b7b3c831bd..ac8fd53162 100644 --- a/java/com/google/gerrit/server/restapi/account/DeleteSshKey.java +++ b/java/com/google/gerrit/server/restapi/account/DeleteSshKey.java @@ -14,6 +14,7 @@ package com.google.gerrit.server.restapi.account; +import com.google.gerrit.exceptions.StorageException; import com.google.gerrit.extensions.common.Input; import com.google.gerrit.extensions.restapi.AuthException; import com.google.gerrit.extensions.restapi.Response; @@ -25,7 +26,6 @@ import com.google.gerrit.server.permissions.GlobalPermission; import com.google.gerrit.server.permissions.PermissionBackend; import com.google.gerrit.server.permissions.PermissionBackendException; import com.google.gerrit.server.ssh.SshKeyCache; -import com.google.gwtorm.server.OrmException; import com.google.inject.Inject; import com.google.inject.Provider; import com.google.inject.Singleton; @@ -55,7 +55,7 @@ public class DeleteSshKey implements RestModifyView apply(AccountResource.SshKey rsrc, Input input) - throws AuthException, OrmException, RepositoryNotFoundException, IOException, + throws AuthException, StorageException, RepositoryNotFoundException, IOException, ConfigInvalidException, PermissionBackendException { if (!self.get().hasSameAccountId(rsrc.getUser())) { permissionBackend.currentUser().check(GlobalPermission.ADMINISTRATE_SERVER); diff --git a/java/com/google/gerrit/server/restapi/account/DeleteWatchedProjects.java b/java/com/google/gerrit/server/restapi/account/DeleteWatchedProjects.java index deb70fe8fd..11b4d9363f 100644 --- a/java/com/google/gerrit/server/restapi/account/DeleteWatchedProjects.java +++ b/java/com/google/gerrit/server/restapi/account/DeleteWatchedProjects.java @@ -16,6 +16,7 @@ package com.google.gerrit.server.restapi.account; import static java.util.stream.Collectors.toList; +import com.google.gerrit.exceptions.StorageException; import com.google.gerrit.extensions.client.ProjectWatchInfo; import com.google.gerrit.extensions.restapi.AuthException; import com.google.gerrit.extensions.restapi.Response; @@ -31,7 +32,6 @@ import com.google.gerrit.server.account.ProjectWatches.ProjectWatchKey; import com.google.gerrit.server.permissions.GlobalPermission; import com.google.gerrit.server.permissions.PermissionBackend; import com.google.gerrit.server.permissions.PermissionBackendException; -import com.google.gwtorm.server.OrmException; import com.google.inject.Inject; import com.google.inject.Provider; import com.google.inject.Singleton; @@ -59,7 +59,7 @@ public class DeleteWatchedProjects @Override public Response apply(AccountResource rsrc, List input) - throws AuthException, UnprocessableEntityException, OrmException, IOException, + throws AuthException, UnprocessableEntityException, StorageException, IOException, ConfigInvalidException, PermissionBackendException { if (!self.get().hasSameAccountId(rsrc.getUser())) { permissionBackend.currentUser().check(GlobalPermission.ADMINISTRATE_SERVER); diff --git a/java/com/google/gerrit/server/restapi/account/GetAccount.java b/java/com/google/gerrit/server/restapi/account/GetAccount.java index 6b73ae3b29..616afdcbc7 100644 --- a/java/com/google/gerrit/server/restapi/account/GetAccount.java +++ b/java/com/google/gerrit/server/restapi/account/GetAccount.java @@ -14,12 +14,12 @@ package com.google.gerrit.server.restapi.account; +import com.google.gerrit.exceptions.StorageException; import com.google.gerrit.extensions.common.AccountInfo; import com.google.gerrit.extensions.restapi.RestReadView; import com.google.gerrit.server.account.AccountLoader; import com.google.gerrit.server.account.AccountResource; import com.google.gerrit.server.permissions.PermissionBackendException; -import com.google.gwtorm.server.OrmException; import com.google.inject.Inject; import com.google.inject.Singleton; @@ -33,7 +33,8 @@ public class GetAccount implements RestReadView { } @Override - public AccountInfo apply(AccountResource rsrc) throws OrmException, PermissionBackendException { + public AccountInfo apply(AccountResource rsrc) + throws StorageException, PermissionBackendException { AccountLoader loader = infoFactory.create(true); AccountInfo info = loader.get(rsrc.getUser().getAccountId()); loader.fill(); diff --git a/java/com/google/gerrit/server/restapi/account/GetDetail.java b/java/com/google/gerrit/server/restapi/account/GetDetail.java index 97d0c60b3b..d255ad4b51 100644 --- a/java/com/google/gerrit/server/restapi/account/GetDetail.java +++ b/java/com/google/gerrit/server/restapi/account/GetDetail.java @@ -14,6 +14,7 @@ package com.google.gerrit.server.restapi.account; +import com.google.gerrit.exceptions.StorageException; import com.google.gerrit.extensions.common.AccountDetailInfo; import com.google.gerrit.extensions.restapi.RestReadView; import com.google.gerrit.reviewdb.client.Account; @@ -21,7 +22,6 @@ import com.google.gerrit.server.account.AccountDirectory.FillOptions; import com.google.gerrit.server.account.AccountResource; import com.google.gerrit.server.account.InternalAccountDirectory; import com.google.gerrit.server.permissions.PermissionBackendException; -import com.google.gwtorm.server.OrmException; import com.google.inject.Inject; import com.google.inject.Singleton; import java.util.Collections; @@ -38,7 +38,7 @@ public class GetDetail implements RestReadView { @Override public AccountDetailInfo apply(AccountResource rsrc) - throws OrmException, PermissionBackendException { + throws StorageException, PermissionBackendException { Account a = rsrc.getUser().getAccount(); AccountDetailInfo info = new AccountDetailInfo(a.getId().get()); info.registeredOn = a.getRegisteredOn(); diff --git a/java/com/google/gerrit/server/restapi/account/GetExternalIds.java b/java/com/google/gerrit/server/restapi/account/GetExternalIds.java index 7a420abe59..dc7e3e86b9 100644 --- a/java/com/google/gerrit/server/restapi/account/GetExternalIds.java +++ b/java/com/google/gerrit/server/restapi/account/GetExternalIds.java @@ -18,6 +18,7 @@ import static com.google.gerrit.server.account.externalids.ExternalId.SCHEME_USE import com.google.common.collect.ImmutableList; import com.google.common.collect.Lists; +import com.google.gerrit.exceptions.StorageException; import com.google.gerrit.extensions.common.AccountExternalIdInfo; import com.google.gerrit.extensions.restapi.RestApiException; import com.google.gerrit.extensions.restapi.RestReadView; @@ -29,7 +30,6 @@ import com.google.gerrit.server.config.AuthConfig; import com.google.gerrit.server.permissions.GlobalPermission; import com.google.gerrit.server.permissions.PermissionBackend; import com.google.gerrit.server.permissions.PermissionBackendException; -import com.google.gwtorm.server.OrmException; import com.google.inject.Inject; import com.google.inject.Provider; import com.google.inject.Singleton; @@ -60,7 +60,7 @@ public class GetExternalIds implements RestReadView { @Override public List apply(AccountResource resource) - throws RestApiException, IOException, OrmException, PermissionBackendException { + throws RestApiException, IOException, StorageException, PermissionBackendException { if (!self.get().hasSameAccountId(resource.getUser())) { permissionBackend.currentUser().check(GlobalPermission.ACCESS_DATABASE); } diff --git a/java/com/google/gerrit/server/restapi/account/GetGroups.java b/java/com/google/gerrit/server/restapi/account/GetGroups.java index ac4968e469..9ec0ff6203 100644 --- a/java/com/google/gerrit/server/restapi/account/GetGroups.java +++ b/java/com/google/gerrit/server/restapi/account/GetGroups.java @@ -15,6 +15,7 @@ package com.google.gerrit.server.restapi.account; import com.google.gerrit.exceptions.NoSuchGroupException; +import com.google.gerrit.exceptions.StorageException; import com.google.gerrit.extensions.common.GroupInfo; import com.google.gerrit.extensions.restapi.RestReadView; import com.google.gerrit.reviewdb.client.Account; @@ -24,7 +25,6 @@ import com.google.gerrit.server.account.AccountResource; import com.google.gerrit.server.account.GroupControl; import com.google.gerrit.server.permissions.PermissionBackendException; import com.google.gerrit.server.restapi.group.GroupJson; -import com.google.gwtorm.server.OrmException; import com.google.inject.Inject; import com.google.inject.Singleton; import java.util.ArrayList; @@ -44,7 +44,7 @@ public class GetGroups implements RestReadView { @Override public List apply(AccountResource resource) - throws OrmException, PermissionBackendException { + throws StorageException, PermissionBackendException { IdentifiedUser user = resource.getUser(); Account.Id userId = user.getAccountId(); Set knownGroups = user.getEffectiveGroups().getKnownGroups(); diff --git a/java/com/google/gerrit/server/restapi/account/GetSshKeys.java b/java/com/google/gerrit/server/restapi/account/GetSshKeys.java index a49f9df58c..b92225c1c0 100644 --- a/java/com/google/gerrit/server/restapi/account/GetSshKeys.java +++ b/java/com/google/gerrit/server/restapi/account/GetSshKeys.java @@ -16,6 +16,7 @@ package com.google.gerrit.server.restapi.account; import com.google.common.base.Strings; import com.google.common.collect.Lists; +import com.google.gerrit.exceptions.StorageException; import com.google.gerrit.extensions.common.SshKeyInfo; import com.google.gerrit.extensions.restapi.AuthException; import com.google.gerrit.extensions.restapi.RestReadView; @@ -27,7 +28,6 @@ import com.google.gerrit.server.account.VersionedAuthorizedKeys; import com.google.gerrit.server.permissions.GlobalPermission; import com.google.gerrit.server.permissions.PermissionBackend; import com.google.gerrit.server.permissions.PermissionBackendException; -import com.google.gwtorm.server.OrmException; import com.google.inject.Inject; import com.google.inject.Provider; import com.google.inject.Singleton; @@ -55,7 +55,7 @@ public class GetSshKeys implements RestReadView { @Override public List apply(AccountResource rsrc) - throws AuthException, OrmException, RepositoryNotFoundException, IOException, + throws AuthException, StorageException, RepositoryNotFoundException, IOException, ConfigInvalidException, PermissionBackendException { if (!self.get().hasSameAccountId(rsrc.getUser())) { permissionBackend.currentUser().check(GlobalPermission.MODIFY_ACCOUNT); diff --git a/java/com/google/gerrit/server/restapi/account/GetWatchedProjects.java b/java/com/google/gerrit/server/restapi/account/GetWatchedProjects.java index ba8c72a65d..326595d615 100644 --- a/java/com/google/gerrit/server/restapi/account/GetWatchedProjects.java +++ b/java/com/google/gerrit/server/restapi/account/GetWatchedProjects.java @@ -19,6 +19,7 @@ import static java.util.stream.Collectors.toList; import com.google.common.base.Strings; import com.google.common.collect.ImmutableSet; +import com.google.gerrit.exceptions.StorageException; import com.google.gerrit.extensions.client.ProjectWatchInfo; import com.google.gerrit.extensions.restapi.AuthException; import com.google.gerrit.extensions.restapi.ResourceNotFoundException; @@ -33,7 +34,6 @@ import com.google.gerrit.server.account.ProjectWatches.ProjectWatchKey; import com.google.gerrit.server.permissions.GlobalPermission; import com.google.gerrit.server.permissions.PermissionBackend; import com.google.gerrit.server.permissions.PermissionBackendException; -import com.google.gwtorm.server.OrmException; import com.google.inject.Inject; import com.google.inject.Provider; import com.google.inject.Singleton; @@ -57,7 +57,7 @@ public class GetWatchedProjects implements RestReadView { @Override public List apply(AccountResource rsrc) - throws OrmException, AuthException, IOException, ConfigInvalidException, + throws StorageException, AuthException, IOException, ConfigInvalidException, PermissionBackendException, ResourceNotFoundException { if (!self.get().hasSameAccountId(rsrc.getUser())) { permissionBackend.currentUser().check(GlobalPermission.ADMINISTRATE_SERVER); diff --git a/java/com/google/gerrit/server/restapi/account/PostWatchedProjects.java b/java/com/google/gerrit/server/restapi/account/PostWatchedProjects.java index f29a0ebf4a..8c966aecc0 100644 --- a/java/com/google/gerrit/server/restapi/account/PostWatchedProjects.java +++ b/java/com/google/gerrit/server/restapi/account/PostWatchedProjects.java @@ -14,6 +14,7 @@ package com.google.gerrit.server.restapi.account; +import com.google.gerrit.exceptions.StorageException; import com.google.gerrit.extensions.client.ProjectWatchInfo; import com.google.gerrit.extensions.restapi.BadRequestException; import com.google.gerrit.extensions.restapi.RestApiException; @@ -29,7 +30,6 @@ import com.google.gerrit.server.permissions.GlobalPermission; import com.google.gerrit.server.permissions.PermissionBackend; import com.google.gerrit.server.permissions.PermissionBackendException; import com.google.gerrit.server.restapi.project.ProjectsCollection; -import com.google.gwtorm.server.OrmException; import com.google.inject.Inject; import com.google.inject.Provider; import com.google.inject.Singleton; @@ -66,7 +66,7 @@ public class PostWatchedProjects @Override public List apply(AccountResource rsrc, List input) - throws OrmException, RestApiException, IOException, ConfigInvalidException, + throws StorageException, RestApiException, IOException, ConfigInvalidException, PermissionBackendException { if (!self.get().hasSameAccountId(rsrc.getUser())) { permissionBackend.currentUser().check(GlobalPermission.ADMINISTRATE_SERVER); diff --git a/java/com/google/gerrit/server/restapi/account/PutActive.java b/java/com/google/gerrit/server/restapi/account/PutActive.java index 82557814cb..94fe3968ef 100644 --- a/java/com/google/gerrit/server/restapi/account/PutActive.java +++ b/java/com/google/gerrit/server/restapi/account/PutActive.java @@ -15,6 +15,7 @@ package com.google.gerrit.server.restapi.account; import com.google.gerrit.common.data.GlobalCapability; +import com.google.gerrit.exceptions.StorageException; import com.google.gerrit.extensions.annotations.RequiresCapability; import com.google.gerrit.extensions.common.Input; import com.google.gerrit.extensions.restapi.Response; @@ -22,7 +23,6 @@ import com.google.gerrit.extensions.restapi.RestApiException; import com.google.gerrit.extensions.restapi.RestModifyView; import com.google.gerrit.server.account.AccountResource; import com.google.gerrit.server.account.SetInactiveFlag; -import com.google.gwtorm.server.OrmException; import com.google.inject.Inject; import com.google.inject.Singleton; import java.io.IOException; @@ -41,7 +41,7 @@ public class PutActive implements RestModifyView { @Override public Response apply(AccountResource rsrc, Input input) - throws RestApiException, OrmException, IOException, ConfigInvalidException { + throws RestApiException, StorageException, IOException, ConfigInvalidException { return setInactiveFlag.activate(rsrc.getUser().getAccountId()); } } diff --git a/java/com/google/gerrit/server/restapi/account/PutAgreement.java b/java/com/google/gerrit/server/restapi/account/PutAgreement.java index 3702b70156..95227eda84 100644 --- a/java/com/google/gerrit/server/restapi/account/PutAgreement.java +++ b/java/com/google/gerrit/server/restapi/account/PutAgreement.java @@ -18,6 +18,7 @@ import com.google.common.base.Strings; import com.google.common.collect.ImmutableSet; import com.google.gerrit.common.data.ContributorAgreement; import com.google.gerrit.exceptions.NoSuchGroupException; +import com.google.gerrit.exceptions.StorageException; import com.google.gerrit.extensions.api.accounts.AgreementInput; import com.google.gerrit.extensions.restapi.AuthException; import com.google.gerrit.extensions.restapi.BadRequestException; @@ -35,7 +36,6 @@ import com.google.gerrit.server.config.GerritServerConfig; import com.google.gerrit.server.extensions.events.AgreementSignup; import com.google.gerrit.server.project.ProjectCache; import com.google.gerrit.server.restapi.group.AddMembers; -import com.google.gwtorm.server.OrmException; import com.google.inject.Inject; import com.google.inject.Provider; import com.google.inject.Singleton; @@ -67,7 +67,7 @@ public class PutAgreement implements RestModifyView apply(AccountResource resource, AgreementInput input) - throws IOException, OrmException, RestApiException, ConfigInvalidException { + throws IOException, StorageException, RestApiException, ConfigInvalidException { if (!agreementsEnabled) { throw new MethodNotAllowedException("contributor agreements disabled"); } diff --git a/java/com/google/gerrit/server/restapi/account/PutHttpPassword.java b/java/com/google/gerrit/server/restapi/account/PutHttpPassword.java index c6e2cb046f..efbb8e9f08 100644 --- a/java/com/google/gerrit/server/restapi/account/PutHttpPassword.java +++ b/java/com/google/gerrit/server/restapi/account/PutHttpPassword.java @@ -18,6 +18,7 @@ import static com.google.gerrit.server.account.externalids.ExternalId.SCHEME_USE import com.google.common.base.Strings; import com.google.gerrit.common.UsedAt; +import com.google.gerrit.exceptions.StorageException; import com.google.gerrit.extensions.common.HttpPasswordInput; import com.google.gerrit.extensions.restapi.AuthException; import com.google.gerrit.extensions.restapi.ResourceConflictException; @@ -34,7 +35,6 @@ import com.google.gerrit.server.account.externalids.ExternalIds; import com.google.gerrit.server.permissions.GlobalPermission; import com.google.gerrit.server.permissions.PermissionBackend; import com.google.gerrit.server.permissions.PermissionBackendException; -import com.google.gwtorm.server.OrmException; import com.google.inject.Inject; import com.google.inject.Provider; import java.io.IOException; @@ -75,7 +75,7 @@ public class PutHttpPassword implements RestModifyView apply(AccountResource rsrc, HttpPasswordInput input) - throws AuthException, ResourceNotFoundException, ResourceConflictException, OrmException, + throws AuthException, ResourceNotFoundException, ResourceConflictException, StorageException, IOException, ConfigInvalidException, PermissionBackendException { if (!self.get().hasSameAccountId(rsrc.getUser())) { permissionBackend.currentUser().check(GlobalPermission.ADMINISTRATE_SERVER); @@ -100,7 +100,7 @@ public class PutHttpPassword implements RestModifyView apply(IdentifiedUser user, String newPassword) - throws ResourceNotFoundException, ResourceConflictException, OrmException, IOException, + throws ResourceNotFoundException, ResourceConflictException, StorageException, IOException, ConfigInvalidException { String userName = user.getUserName().orElseThrow(() -> new ResourceConflictException("username must be set")); diff --git a/java/com/google/gerrit/server/restapi/account/PutName.java b/java/com/google/gerrit/server/restapi/account/PutName.java index 1e00aaccaf..95efcbad3d 100644 --- a/java/com/google/gerrit/server/restapi/account/PutName.java +++ b/java/com/google/gerrit/server/restapi/account/PutName.java @@ -15,6 +15,7 @@ package com.google.gerrit.server.restapi.account; import com.google.common.base.Strings; +import com.google.gerrit.exceptions.StorageException; import com.google.gerrit.extensions.client.AccountFieldName; import com.google.gerrit.extensions.common.NameInput; import com.google.gerrit.extensions.restapi.AuthException; @@ -32,7 +33,6 @@ import com.google.gerrit.server.account.Realm; import com.google.gerrit.server.permissions.GlobalPermission; import com.google.gerrit.server.permissions.PermissionBackend; import com.google.gerrit.server.permissions.PermissionBackendException; -import com.google.gwtorm.server.OrmException; import com.google.inject.Inject; import com.google.inject.Provider; import com.google.inject.Singleton; @@ -60,7 +60,7 @@ public class PutName implements RestModifyView { @Override public Response apply(AccountResource rsrc, NameInput input) - throws AuthException, MethodNotAllowedException, ResourceNotFoundException, OrmException, + throws AuthException, MethodNotAllowedException, ResourceNotFoundException, StorageException, IOException, PermissionBackendException, ConfigInvalidException { if (!self.get().hasSameAccountId(rsrc.getUser())) { permissionBackend.currentUser().check(GlobalPermission.MODIFY_ACCOUNT); @@ -70,7 +70,7 @@ public class PutName implements RestModifyView { public Response apply(IdentifiedUser user, NameInput input) throws MethodNotAllowedException, ResourceNotFoundException, IOException, - ConfigInvalidException, OrmException { + ConfigInvalidException, StorageException { if (input == null) { input = new NameInput(); } diff --git a/java/com/google/gerrit/server/restapi/account/PutPreferred.java b/java/com/google/gerrit/server/restapi/account/PutPreferred.java index 265bf530ec..6b64ac75e5 100644 --- a/java/com/google/gerrit/server/restapi/account/PutPreferred.java +++ b/java/com/google/gerrit/server/restapi/account/PutPreferred.java @@ -18,6 +18,7 @@ import static java.util.stream.Collectors.toList; import static java.util.stream.Collectors.toSet; import com.google.common.flogger.FluentLogger; +import com.google.gerrit.exceptions.StorageException; import com.google.gerrit.extensions.common.Input; import com.google.gerrit.extensions.restapi.ResourceConflictException; import com.google.gerrit.extensions.restapi.ResourceNotFoundException; @@ -34,7 +35,6 @@ import com.google.gerrit.server.account.externalids.ExternalIds; import com.google.gerrit.server.permissions.GlobalPermission; import com.google.gerrit.server.permissions.PermissionBackend; import com.google.gerrit.server.permissions.PermissionBackendException; -import com.google.gwtorm.server.OrmException; import com.google.inject.Inject; import com.google.inject.Provider; import com.google.inject.Singleton; @@ -69,7 +69,7 @@ public class PutPreferred implements RestModifyView apply(AccountResource.Email rsrc, Input input) - throws RestApiException, OrmException, IOException, PermissionBackendException, + throws RestApiException, StorageException, IOException, PermissionBackendException, ConfigInvalidException { if (!self.get().hasSameAccountId(rsrc.getUser())) { permissionBackend.currentUser().check(GlobalPermission.MODIFY_ACCOUNT); @@ -78,7 +78,7 @@ public class PutPreferred implements RestModifyView apply(IdentifiedUser user, String preferredEmail) - throws RestApiException, IOException, ConfigInvalidException, OrmException { + throws RestApiException, IOException, ConfigInvalidException, StorageException { AtomicReference> exception = new AtomicReference<>(Optional.empty()); AtomicBoolean alreadyPreferred = new AtomicBoolean(false); accountsUpdateProvider diff --git a/java/com/google/gerrit/server/restapi/account/PutStatus.java b/java/com/google/gerrit/server/restapi/account/PutStatus.java index 9aee0a3274..193ea3dcb7 100644 --- a/java/com/google/gerrit/server/restapi/account/PutStatus.java +++ b/java/com/google/gerrit/server/restapi/account/PutStatus.java @@ -15,6 +15,7 @@ package com.google.gerrit.server.restapi.account; import com.google.common.base.Strings; +import com.google.gerrit.exceptions.StorageException; import com.google.gerrit.extensions.api.accounts.StatusInput; import com.google.gerrit.extensions.restapi.AuthException; import com.google.gerrit.extensions.restapi.ResourceNotFoundException; @@ -29,7 +30,6 @@ import com.google.gerrit.server.account.AccountsUpdate; import com.google.gerrit.server.permissions.GlobalPermission; import com.google.gerrit.server.permissions.PermissionBackend; import com.google.gerrit.server.permissions.PermissionBackendException; -import com.google.gwtorm.server.OrmException; import com.google.inject.Inject; import com.google.inject.Provider; import com.google.inject.Singleton; @@ -54,7 +54,7 @@ public class PutStatus implements RestModifyView { @Override public Response apply(AccountResource rsrc, StatusInput input) - throws AuthException, ResourceNotFoundException, OrmException, IOException, + throws AuthException, ResourceNotFoundException, StorageException, IOException, PermissionBackendException, ConfigInvalidException { if (!self.get().hasSameAccountId(rsrc.getUser())) { permissionBackend.currentUser().check(GlobalPermission.MODIFY_ACCOUNT); @@ -63,7 +63,7 @@ public class PutStatus implements RestModifyView { } public Response apply(IdentifiedUser user, StatusInput input) - throws ResourceNotFoundException, IOException, ConfigInvalidException, OrmException { + throws ResourceNotFoundException, IOException, ConfigInvalidException, StorageException { if (input == null) { input = new StatusInput(); } diff --git a/java/com/google/gerrit/server/restapi/account/PutUsername.java b/java/com/google/gerrit/server/restapi/account/PutUsername.java index 856a5dbb0f..993d0b3742 100644 --- a/java/com/google/gerrit/server/restapi/account/PutUsername.java +++ b/java/com/google/gerrit/server/restapi/account/PutUsername.java @@ -17,6 +17,8 @@ package com.google.gerrit.server.restapi.account; import static com.google.gerrit.server.account.externalids.ExternalId.SCHEME_USERNAME; import com.google.common.base.Strings; +import com.google.gerrit.exceptions.DuplicateKeyException; +import com.google.gerrit.exceptions.StorageException; import com.google.gerrit.extensions.api.accounts.UsernameInput; import com.google.gerrit.extensions.client.AccountFieldName; import com.google.gerrit.extensions.restapi.AuthException; @@ -36,8 +38,6 @@ import com.google.gerrit.server.permissions.GlobalPermission; import com.google.gerrit.server.permissions.PermissionBackend; import com.google.gerrit.server.permissions.PermissionBackendException; import com.google.gerrit.server.ssh.SshKeyCache; -import com.google.gwtorm.server.OrmDuplicateKeyException; -import com.google.gwtorm.server.OrmException; import com.google.inject.Inject; import com.google.inject.Provider; import com.google.inject.Singleton; @@ -73,7 +73,7 @@ public class PutUsername implements RestModifyView u.addExternalId(ExternalId.create(key, accountId, null, null))); - } catch (OrmDuplicateKeyException dupeErr) { + } catch (DuplicateKeyException dupeErr) { // If we are using this identity, don't report the exception. Optional other = externalIds.get(key); if (other.isPresent() && other.get().accountId().equals(accountId)) { diff --git a/java/com/google/gerrit/server/restapi/account/QueryAccounts.java b/java/com/google/gerrit/server/restapi/account/QueryAccounts.java index f527ba41d8..5be548e7cf 100644 --- a/java/com/google/gerrit/server/restapi/account/QueryAccounts.java +++ b/java/com/google/gerrit/server/restapi/account/QueryAccounts.java @@ -16,6 +16,7 @@ package com.google.gerrit.server.restapi.account; import com.google.common.base.Strings; import com.google.common.collect.ImmutableList; +import com.google.gerrit.exceptions.StorageException; import com.google.gerrit.extensions.client.ListAccountsOption; import com.google.gerrit.extensions.client.ListOption; import com.google.gerrit.extensions.common.AccountInfo; @@ -41,7 +42,6 @@ import com.google.gerrit.server.permissions.PermissionBackendException; import com.google.gerrit.server.query.account.AccountPredicates; import com.google.gerrit.server.query.account.AccountQueryBuilder; import com.google.gerrit.server.query.account.AccountQueryProcessor; -import com.google.gwtorm.server.OrmException; import com.google.inject.Inject; import java.util.Collections; import java.util.EnumSet; @@ -149,7 +149,7 @@ public class QueryAccounts implements RestReadView { @Override public List apply(TopLevelResource rsrc) - throws OrmException, RestApiException, PermissionBackendException { + throws StorageException, RestApiException, PermissionBackendException { if (Strings.isNullOrEmpty(query)) { throw new BadRequestException("missing query field"); } diff --git a/java/com/google/gerrit/server/restapi/account/SetDiffPreferences.java b/java/com/google/gerrit/server/restapi/account/SetDiffPreferences.java index f4fa3544cd..e2d1451e5b 100644 --- a/java/com/google/gerrit/server/restapi/account/SetDiffPreferences.java +++ b/java/com/google/gerrit/server/restapi/account/SetDiffPreferences.java @@ -14,6 +14,7 @@ package com.google.gerrit.server.restapi.account; +import com.google.gerrit.exceptions.StorageException; import com.google.gerrit.extensions.client.DiffPreferencesInfo; import com.google.gerrit.extensions.restapi.BadRequestException; import com.google.gerrit.extensions.restapi.IdString; @@ -29,7 +30,6 @@ import com.google.gerrit.server.account.AccountsUpdate; import com.google.gerrit.server.permissions.GlobalPermission; import com.google.gerrit.server.permissions.PermissionBackend; import com.google.gerrit.server.permissions.PermissionBackendException; -import com.google.gwtorm.server.OrmException; import com.google.inject.Inject; import com.google.inject.Provider; import com.google.inject.Singleton; @@ -56,7 +56,7 @@ public class SetDiffPreferences implements RestModifyView apply(AccountResource rsrc, IdString id, EmptyInput in) - throws RestApiException, OrmException, IOException { + throws RestApiException, StorageException, IOException { if (!self.get().hasSameAccountId(rsrc.getUser())) { throw new AuthException("not allowed to add starred change"); } @@ -124,7 +124,7 @@ public class StarredChanges change = changes.parse(TopLevelResource.INSTANCE, id); } catch (ResourceNotFoundException e) { throw new UnprocessableEntityException(String.format("change %s not found", id.get())); - } catch (OrmException | PermissionBackendException | IOException e) { + } catch (StorageException | PermissionBackendException | IOException e) { logger.atSevere().withCause(e).log("cannot resolve change"); throw new UnprocessableEntityException("internal server error"); } @@ -140,7 +140,7 @@ public class StarredChanges throw new ResourceConflictException(e.getMessage()); } catch (IllegalLabelException e) { throw new BadRequestException(e.getMessage()); - } catch (OrmDuplicateKeyException e) { + } catch (DuplicateKeyException e) { return Response.none(); } return Response.none(); @@ -179,7 +179,7 @@ public class StarredChanges @Override public Response apply(AccountResource.StarredChange rsrc, EmptyInput in) - throws AuthException, OrmException, IOException, IllegalLabelException { + throws AuthException, StorageException, IOException, IllegalLabelException { if (!self.get().hasSameAccountId(rsrc.getUser())) { throw new AuthException("not allowed remove starred change"); } diff --git a/java/com/google/gerrit/server/restapi/account/Stars.java b/java/com/google/gerrit/server/restapi/account/Stars.java index 5c4c4d5253..13a8679872 100644 --- a/java/com/google/gerrit/server/restapi/account/Stars.java +++ b/java/com/google/gerrit/server/restapi/account/Stars.java @@ -14,6 +14,7 @@ package com.google.gerrit.server.restapi.account; +import com.google.gerrit.exceptions.StorageException; import com.google.gerrit.extensions.api.changes.StarsInput; import com.google.gerrit.extensions.common.ChangeInfo; import com.google.gerrit.extensions.registration.DynamicMap; @@ -36,7 +37,6 @@ import com.google.gerrit.server.change.ChangeResource; import com.google.gerrit.server.permissions.PermissionBackendException; import com.google.gerrit.server.restapi.change.ChangesCollection; import com.google.gerrit.server.restapi.change.QueryChanges; -import com.google.gwtorm.server.OrmException; import com.google.inject.Inject; import com.google.inject.Provider; import com.google.inject.Singleton; @@ -68,7 +68,7 @@ public class Stars implements ChildCollection labels = starredChangesUtil.getLabels(user.getAccountId(), change.getId()); @@ -99,7 +99,7 @@ public class Stars implements ChildCollection apply(AccountResource rsrc) - throws BadRequestException, AuthException, OrmException, PermissionBackendException { + throws BadRequestException, AuthException, StorageException, PermissionBackendException { if (!self.get().hasSameAccountId(rsrc.getUser())) { throw new AuthException("not allowed to list stars of another account"); } @@ -121,7 +121,8 @@ public class Stars implements ChildCollection apply(AccountResource.Star rsrc) throws AuthException, OrmException { + public SortedSet apply(AccountResource.Star rsrc) + throws AuthException, StorageException { if (!self.get().hasSameAccountId(rsrc.getUser())) { throw new AuthException("not allowed to get stars of another account"); } @@ -142,7 +143,7 @@ public class Stars implements ChildCollection apply(AccountResource.Star rsrc, StarsInput in) - throws AuthException, BadRequestException, OrmException { + throws AuthException, BadRequestException, StorageException { if (!self.get().hasSameAccountId(rsrc.getUser())) { throw new AuthException("not allowed to update stars of another account"); } diff --git a/java/com/google/gerrit/server/restapi/change/Abandon.java b/java/com/google/gerrit/server/restapi/change/Abandon.java index 15dc9e5edf..a6e6eb543a 100644 --- a/java/com/google/gerrit/server/restapi/change/Abandon.java +++ b/java/com/google/gerrit/server/restapi/change/Abandon.java @@ -15,6 +15,7 @@ package com.google.gerrit.server.restapi.change; import com.google.common.flogger.FluentLogger; +import com.google.gerrit.exceptions.StorageException; import com.google.gerrit.extensions.api.changes.AbandonInput; import com.google.gerrit.extensions.api.changes.NotifyHandling; import com.google.gerrit.extensions.common.ChangeInfo; @@ -36,7 +37,6 @@ import com.google.gerrit.server.update.RetryHelper; import com.google.gerrit.server.update.RetryingRestModifyView; import com.google.gerrit.server.update.UpdateException; import com.google.gerrit.server.util.time.TimeUtil; -import com.google.gwtorm.server.OrmException; import com.google.inject.Inject; import com.google.inject.Singleton; import java.io.IOException; @@ -69,7 +69,7 @@ public class Abandon extends RetryingRestModifyView { @Override public Response apply(FixResource fixResource, Void nothing) - throws AuthException, OrmException, ResourceConflictException, IOException, + throws AuthException, StorageException, ResourceConflictException, IOException, ResourceNotFoundException, PermissionBackendException { RevisionResource revisionResource = fixResource.getRevisionResource(); Project.NameKey project = revisionResource.getProject(); diff --git a/java/com/google/gerrit/server/restapi/change/ChangeEdits.java b/java/com/google/gerrit/server/restapi/change/ChangeEdits.java index cabb30df7b..48e8e43884 100644 --- a/java/com/google/gerrit/server/restapi/change/ChangeEdits.java +++ b/java/com/google/gerrit/server/restapi/change/ChangeEdits.java @@ -15,6 +15,7 @@ package com.google.gerrit.server.restapi.change; import com.google.common.base.Strings; +import com.google.gerrit.exceptions.StorageException; import com.google.gerrit.extensions.common.DiffWebLinkInfo; import com.google.gerrit.extensions.common.EditInfo; import com.google.gerrit.extensions.common.Input; @@ -54,7 +55,6 @@ import com.google.gerrit.server.patch.PatchListNotAvailableException; import com.google.gerrit.server.permissions.PermissionBackendException; import com.google.gerrit.server.project.InvalidChangeOperationException; import com.google.gerrit.server.project.ProjectCache; -import com.google.gwtorm.server.OrmException; import com.google.inject.Inject; import com.google.inject.Provider; import com.google.inject.Singleton; @@ -95,7 +95,7 @@ public class ChangeEdits implements ChildCollection edit = editUtil.byChange(rsrc.getNotes(), rsrc.getUser()); if (!edit.isPresent()) { throw new ResourceNotFoundException(id); @@ -119,7 +119,7 @@ public class ChangeEdits implements ChildCollection apply(ChangeResource resource, IdString id, Put.Input input) - throws AuthException, ResourceConflictException, IOException, OrmException, + throws AuthException, ResourceConflictException, IOException, StorageException, PermissionBackendException { putEdit.apply(resource, id.get(), input.content); return Response.none(); @@ -137,7 +137,7 @@ public class ChangeEdits implements ChildCollection apply(ChangeResource rsrc, IdString id, Input in) - throws IOException, AuthException, ResourceConflictException, OrmException, + throws IOException, AuthException, ResourceConflictException, StorageException, PermissionBackendException { return deleteContent.apply(rsrc, id.get()); } @@ -184,7 +184,7 @@ public class ChangeEdits implements ChildCollection apply(ChangeResource rsrc) - throws AuthException, IOException, ResourceNotFoundException, OrmException, + throws AuthException, IOException, ResourceNotFoundException, StorageException, PermissionBackendException { Optional edit = editUtil.byChange(rsrc.getNotes(), rsrc.getUser()); if (!edit.isPresent()) { @@ -240,7 +240,7 @@ public class ChangeEdits implements ChildCollection apply(ChangeResource resource, Post.Input input) - throws AuthException, IOException, ResourceConflictException, OrmException, + throws AuthException, IOException, ResourceConflictException, StorageException, PermissionBackendException { Project.NameKey project = resource.getProject(); try (Repository repository = repositoryManager.openRepository(project)) { @@ -286,13 +286,13 @@ public class ChangeEdits implements ChildCollection apply(ChangeEditResource rsrc, Input input) - throws AuthException, ResourceConflictException, IOException, OrmException, + throws AuthException, ResourceConflictException, IOException, StorageException, PermissionBackendException { return apply(rsrc.getChangeResource(), rsrc.getPath(), input.content); } public Response apply(ChangeResource rsrc, String path, RawInput newContent) - throws ResourceConflictException, AuthException, IOException, OrmException, + throws ResourceConflictException, AuthException, IOException, StorageException, PermissionBackendException { if (Strings.isNullOrEmpty(path) || path.charAt(0) == '/') { throw new ResourceConflictException("Invalid path: " + path); @@ -327,13 +327,13 @@ public class ChangeEdits implements ChildCollection apply(ChangeEditResource rsrc, Input input) - throws AuthException, ResourceConflictException, OrmException, IOException, + throws AuthException, ResourceConflictException, StorageException, IOException, PermissionBackendException { return apply(rsrc.getChangeResource(), rsrc.getPath()); } public Response apply(ChangeResource rsrc, String filePath) - throws AuthException, IOException, OrmException, ResourceConflictException, + throws AuthException, IOException, StorageException, ResourceConflictException, PermissionBackendException { try (Repository repository = repositoryManager.openRepository(rsrc.getProject())) { editModifier.deleteFile(repository, rsrc.getNotes(), filePath); @@ -429,7 +429,7 @@ public class ChangeEdits implements ChildCollection edit = editUtil.byChange(rsrc.getNotes(), rsrc.getUser()); String msg; if (edit.isPresent()) { diff --git a/java/com/google/gerrit/server/restapi/change/ChangeIncludedIn.java b/java/com/google/gerrit/server/restapi/change/ChangeIncludedIn.java index 59b311148e..8a20d47f1b 100644 --- a/java/com/google/gerrit/server/restapi/change/ChangeIncludedIn.java +++ b/java/com/google/gerrit/server/restapi/change/ChangeIncludedIn.java @@ -14,6 +14,7 @@ package com.google.gerrit.server.restapi.change; +import com.google.gerrit.exceptions.StorageException; import com.google.gerrit.extensions.api.changes.IncludedInInfo; import com.google.gerrit.extensions.restapi.RestApiException; import com.google.gerrit.extensions.restapi.RestReadView; @@ -21,7 +22,6 @@ import com.google.gerrit.reviewdb.client.PatchSet; import com.google.gerrit.server.PatchSetUtil; import com.google.gerrit.server.change.ChangeResource; import com.google.gerrit.server.change.IncludedIn; -import com.google.gwtorm.server.OrmException; import com.google.inject.Inject; import com.google.inject.Singleton; import java.io.IOException; @@ -39,7 +39,7 @@ public class ChangeIncludedIn implements RestReadView { @Override public IncludedInInfo apply(ChangeResource rsrc) - throws RestApiException, OrmException, IOException { + throws RestApiException, StorageException, IOException { PatchSet ps = psUtil.current(rsrc.getNotes()); return includedIn.apply(rsrc.getProject(), ps.getRevision().get()); } diff --git a/java/com/google/gerrit/server/restapi/change/ChangeMessages.java b/java/com/google/gerrit/server/restapi/change/ChangeMessages.java index 25fc350720..68be85688f 100644 --- a/java/com/google/gerrit/server/restapi/change/ChangeMessages.java +++ b/java/com/google/gerrit/server/restapi/change/ChangeMessages.java @@ -14,6 +14,7 @@ package com.google.gerrit.server.restapi.change; +import com.google.gerrit.exceptions.StorageException; import com.google.gerrit.extensions.common.ChangeMessageInfo; import com.google.gerrit.extensions.registration.DynamicMap; import com.google.gerrit.extensions.restapi.ChildCollection; @@ -23,7 +24,6 @@ import com.google.gerrit.extensions.restapi.RestView; import com.google.gerrit.server.change.ChangeMessageResource; import com.google.gerrit.server.change.ChangeResource; import com.google.gerrit.server.permissions.PermissionBackendException; -import com.google.gwtorm.server.OrmException; import com.google.inject.Inject; import com.google.inject.Singleton; import java.util.List; @@ -52,7 +52,7 @@ public class ChangeMessages implements ChildCollection changeMessages = listChangeMessages.apply(parent); diff --git a/java/com/google/gerrit/server/restapi/change/ChangesCollection.java b/java/com/google/gerrit/server/restapi/change/ChangesCollection.java index 9972195838..7fed3edead 100644 --- a/java/com/google/gerrit/server/restapi/change/ChangesCollection.java +++ b/java/com/google/gerrit/server/restapi/change/ChangesCollection.java @@ -14,6 +14,7 @@ package com.google.gerrit.server.restapi.change; +import com.google.gerrit.exceptions.StorageException; import com.google.gerrit.extensions.registration.DynamicMap; import com.google.gerrit.extensions.restapi.AuthException; import com.google.gerrit.extensions.restapi.IdString; @@ -34,7 +35,6 @@ import com.google.gerrit.server.permissions.PermissionBackend; import com.google.gerrit.server.permissions.PermissionBackendException; import com.google.gerrit.server.project.ProjectCache; import com.google.gerrit.server.project.ProjectState; -import com.google.gwtorm.server.OrmException; import com.google.inject.Inject; import com.google.inject.Provider; import com.google.inject.Singleton; @@ -81,7 +81,7 @@ public class ChangesCollection implements RestCollection notes = changeFinder.find(id.encoded(), true); if (notes.isEmpty()) { throw new ResourceNotFoundException(id); @@ -98,7 +98,7 @@ public class ChangesCollection implements RestCollection notes = changeFinder.find(id); if (notes.isEmpty()) { diff --git a/java/com/google/gerrit/server/restapi/change/Check.java b/java/com/google/gerrit/server/restapi/change/Check.java index dd0ce1091d..1c991262b2 100644 --- a/java/com/google/gerrit/server/restapi/change/Check.java +++ b/java/com/google/gerrit/server/restapi/change/Check.java @@ -14,6 +14,7 @@ package com.google.gerrit.server.restapi.change; +import com.google.gerrit.exceptions.StorageException; import com.google.gerrit.extensions.api.changes.FixInput; import com.google.gerrit.extensions.client.ListChangesOption; import com.google.gerrit.extensions.common.ChangeInfo; @@ -29,7 +30,6 @@ import com.google.gerrit.server.permissions.PermissionBackend; import com.google.gerrit.server.permissions.PermissionBackendException; import com.google.gerrit.server.permissions.ProjectPermission; import com.google.gerrit.server.project.NoSuchProjectException; -import com.google.gwtorm.server.OrmException; import com.google.inject.Inject; import com.google.inject.Singleton; import java.io.IOException; @@ -47,13 +47,13 @@ public class Check } @Override - public Response apply(ChangeResource rsrc) throws RestApiException, OrmException { + public Response apply(ChangeResource rsrc) throws RestApiException, StorageException { return Response.withMustRevalidate(newChangeJson().format(rsrc)); } @Override public Response apply(ChangeResource rsrc, FixInput input) - throws RestApiException, OrmException, PermissionBackendException, NoSuchProjectException, + throws RestApiException, StorageException, PermissionBackendException, NoSuchProjectException, IOException { PermissionBackend.WithUser perm = permissionBackend.currentUser(); if (!rsrc.isUserOwner()) { diff --git a/java/com/google/gerrit/server/restapi/change/CherryPick.java b/java/com/google/gerrit/server/restapi/change/CherryPick.java index b68122e6f5..e0eb44467a 100644 --- a/java/com/google/gerrit/server/restapi/change/CherryPick.java +++ b/java/com/google/gerrit/server/restapi/change/CherryPick.java @@ -17,6 +17,7 @@ package com.google.gerrit.server.restapi.change; import static com.google.gerrit.extensions.conditions.BooleanCondition.and; import com.google.common.flogger.FluentLogger; +import com.google.gerrit.exceptions.StorageException; import com.google.gerrit.extensions.api.changes.CherryPickInput; import com.google.gerrit.extensions.common.CherryPickChangeInfo; import com.google.gerrit.extensions.restapi.BadRequestException; @@ -41,7 +42,6 @@ import com.google.gerrit.server.update.BatchUpdate; import com.google.gerrit.server.update.RetryHelper; import com.google.gerrit.server.update.RetryingRestModifyView; import com.google.gerrit.server.update.UpdateException; -import com.google.gwtorm.server.OrmException; import com.google.inject.Inject; import com.google.inject.Singleton; import java.io.IOException; @@ -78,7 +78,7 @@ public class CherryPick @Override public CherryPickChangeInfo applyImpl( BatchUpdate.Factory updateFactory, RevisionResource rsrc, CherryPickInput input) - throws OrmException, IOException, UpdateException, RestApiException, + throws StorageException, IOException, UpdateException, RestApiException, PermissionBackendException, ConfigInvalidException, NoSuchProjectException { input.parent = input.parent == null ? 1 : input.parent; if (input.message == null || input.message.trim().isEmpty()) { diff --git a/java/com/google/gerrit/server/restapi/change/CherryPickChange.java b/java/com/google/gerrit/server/restapi/change/CherryPickChange.java index 6b92720568..555f19d62a 100644 --- a/java/com/google/gerrit/server/restapi/change/CherryPickChange.java +++ b/java/com/google/gerrit/server/restapi/change/CherryPickChange.java @@ -21,6 +21,7 @@ import com.google.common.base.Strings; import com.google.common.collect.ImmutableSet; import com.google.gerrit.common.FooterConstants; import com.google.gerrit.common.Nullable; +import com.google.gerrit.exceptions.StorageException; import com.google.gerrit.extensions.api.changes.CherryPickInput; import com.google.gerrit.extensions.api.changes.NotifyHandling; import com.google.gerrit.extensions.restapi.BadRequestException; @@ -59,7 +60,6 @@ import com.google.gerrit.server.submit.MergeIdenticalTreeException; import com.google.gerrit.server.update.BatchUpdate; import com.google.gerrit.server.update.UpdateException; import com.google.gerrit.server.util.time.TimeUtil; -import com.google.gwtorm.server.OrmException; import com.google.inject.Inject; import com.google.inject.Provider; import com.google.inject.Singleton; @@ -141,7 +141,7 @@ public class CherryPickChange { PatchSet patch, CherryPickInput input, Branch.NameKey dest) - throws OrmException, IOException, InvalidChangeOperationException, IntegrationException, + throws StorageException, IOException, InvalidChangeOperationException, IntegrationException, UpdateException, RestApiException, ConfigInvalidException, NoSuchProjectException { return cherryPick( batchUpdateFactory, @@ -159,7 +159,7 @@ public class CherryPickChange { ObjectId sourceCommit, CherryPickInput input, Branch.NameKey dest) - throws OrmException, IOException, InvalidChangeOperationException, IntegrationException, + throws StorageException, IOException, InvalidChangeOperationException, IntegrationException, UpdateException, RestApiException, ConfigInvalidException, NoSuchProjectException { IdentifiedUser identifiedUser = user.get(); @@ -275,7 +275,7 @@ public class CherryPickChange { } private RevCommit getBaseCommit(Ref destRef, String project, RevWalk revWalk, String base) - throws RestApiException, IOException, OrmException { + throws RestApiException, IOException, StorageException { RevCommit destRefTip = revWalk.parseCommit(destRef.getObjectId()); // The tip commit of the destination ref is the default base for the newly created change. if (Strings.isNullOrEmpty(base)) { @@ -336,7 +336,7 @@ public class CherryPickChange { @Nullable Change sourceChange, ObjectId sourceCommit, CherryPickInput input) - throws OrmException, IOException { + throws StorageException, IOException { Change.Id changeId = new Change.Id(seq.nextChangeId()); ChangeInserter ins = changeInserterFactory.create(changeId, cherryPickCommit, refName); Branch.NameKey sourceBranch = sourceChange == null ? null : sourceChange.getDest(); @@ -363,7 +363,7 @@ public class CherryPickChange { } private NotifyResolver.Result resolveNotify(CherryPickInput input) - throws BadRequestException, OrmException, ConfigInvalidException, IOException { + throws BadRequestException, StorageException, ConfigInvalidException, IOException { return notifyResolver.resolve( firstNonNull(input.notify, NotifyHandling.ALL), input.notifyDetails); } diff --git a/java/com/google/gerrit/server/restapi/change/CherryPickCommit.java b/java/com/google/gerrit/server/restapi/change/CherryPickCommit.java index f76689c4e2..b6faf15296 100644 --- a/java/com/google/gerrit/server/restapi/change/CherryPickCommit.java +++ b/java/com/google/gerrit/server/restapi/change/CherryPickCommit.java @@ -15,6 +15,7 @@ package com.google.gerrit.server.restapi.change; import com.google.common.base.Strings; +import com.google.gerrit.exceptions.StorageException; import com.google.gerrit.extensions.api.changes.CherryPickInput; import com.google.gerrit.extensions.common.CherryPickChangeInfo; import com.google.gerrit.extensions.restapi.BadRequestException; @@ -37,7 +38,6 @@ import com.google.gerrit.server.update.BatchUpdate; import com.google.gerrit.server.update.RetryHelper; import com.google.gerrit.server.update.RetryingRestModifyView; import com.google.gerrit.server.update.UpdateException; -import com.google.gwtorm.server.OrmException; import com.google.inject.Inject; import com.google.inject.Provider; import com.google.inject.Singleton; @@ -73,7 +73,7 @@ public class CherryPickCommit @Override public CherryPickChangeInfo applyImpl( BatchUpdate.Factory updateFactory, CommitResource rsrc, CherryPickInput input) - throws OrmException, IOException, UpdateException, RestApiException, + throws StorageException, IOException, UpdateException, RestApiException, PermissionBackendException, ConfigInvalidException, NoSuchProjectException { RevCommit commit = rsrc.getCommit(); String message = Strings.nullToEmpty(input.message).trim(); diff --git a/java/com/google/gerrit/server/restapi/change/Comments.java b/java/com/google/gerrit/server/restapi/change/Comments.java index 22f376be98..ea6420bd88 100644 --- a/java/com/google/gerrit/server/restapi/change/Comments.java +++ b/java/com/google/gerrit/server/restapi/change/Comments.java @@ -14,6 +14,7 @@ package com.google.gerrit.server.restapi.change; +import com.google.gerrit.exceptions.StorageException; import com.google.gerrit.extensions.registration.DynamicMap; import com.google.gerrit.extensions.restapi.ChildCollection; import com.google.gerrit.extensions.restapi.IdString; @@ -24,7 +25,6 @@ import com.google.gerrit.server.CommentsUtil; import com.google.gerrit.server.change.CommentResource; import com.google.gerrit.server.change.RevisionResource; import com.google.gerrit.server.notedb.ChangeNotes; -import com.google.gwtorm.server.OrmException; import com.google.inject.Inject; import com.google.inject.Singleton; @@ -56,7 +56,7 @@ public class Comments implements ChildCollection applyImpl( BatchUpdate.Factory updateFactory, TopLevelResource parent, ChangeInput input) - throws OrmException, IOException, InvalidChangeOperationException, RestApiException, + throws StorageException, IOException, InvalidChangeOperationException, RestApiException, UpdateException, PermissionBackendException, ConfigInvalidException { IdentifiedUser me = user.get().asIdentifiedUser(); checkAndSanitizeChangeInput(input, me); @@ -267,7 +267,7 @@ public class CreateChange IdentifiedUser me, ProjectState projectState, BatchUpdate.Factory updateFactory) - throws RestApiException, OrmException, PermissionBackendException, IOException, + throws RestApiException, StorageException, PermissionBackendException, IOException, ConfigInvalidException, UpdateException { try (Repository git = gitManager.openRepository(projectState.getNameKey()); ObjectInserter oi = git.newObjectInserter(); @@ -320,7 +320,7 @@ public class CreateChange } private ChangeNotes getBaseChange(String baseChange) - throws OrmException, UnprocessableEntityException, PermissionBackendException { + throws StorageException, UnprocessableEntityException, PermissionBackendException { List notes = changeFinder.find(baseChange); if (notes.size() != 1) { throw new UnprocessableEntityException("Base change not found: " + baseChange); @@ -442,7 +442,7 @@ public class CreateChange MergeInput merge, PersonIdent authorIdent, String commitMessage) - throws RestApiException, IOException, OrmException { + throws RestApiException, IOException, StorageException { if (Strings.isNullOrEmpty(merge.source)) { throw new BadRequestException("merge.source must be non-empty"); } diff --git a/java/com/google/gerrit/server/restapi/change/CreateDraftComment.java b/java/com/google/gerrit/server/restapi/change/CreateDraftComment.java index fa8adc0979..df6cf6334f 100644 --- a/java/com/google/gerrit/server/restapi/change/CreateDraftComment.java +++ b/java/com/google/gerrit/server/restapi/change/CreateDraftComment.java @@ -17,6 +17,7 @@ package com.google.gerrit.server.restapi.change; import static com.google.gerrit.server.CommentsUtil.setCommentRevId; import com.google.common.base.Strings; +import com.google.gerrit.exceptions.StorageException; import com.google.gerrit.extensions.api.changes.DraftInput; import com.google.gerrit.extensions.common.CommentInfo; import com.google.gerrit.extensions.restapi.BadRequestException; @@ -41,7 +42,6 @@ import com.google.gerrit.server.update.RetryHelper; import com.google.gerrit.server.update.RetryingRestModifyView; import com.google.gerrit.server.update.UpdateException; import com.google.gerrit.server.util.time.TimeUtil; -import com.google.gwtorm.server.OrmException; import com.google.inject.Inject; import com.google.inject.Provider; import com.google.inject.Singleton; @@ -72,7 +72,7 @@ public class CreateDraftComment @Override protected Response applyImpl( BatchUpdate.Factory updateFactory, RevisionResource rsrc, DraftInput in) - throws RestApiException, UpdateException, OrmException, PermissionBackendException { + throws RestApiException, UpdateException, StorageException, PermissionBackendException { if (Strings.isNullOrEmpty(in.path)) { throw new BadRequestException("path must be non-empty"); } else if (in.message == null || in.message.trim().isEmpty()) { @@ -106,7 +106,7 @@ public class CreateDraftComment @Override public boolean updateChange(ChangeContext ctx) - throws ResourceNotFoundException, OrmException, UnprocessableEntityException, + throws ResourceNotFoundException, StorageException, UnprocessableEntityException, PatchListNotAvailableException { PatchSet ps = psUtil.get(ctx.getNotes(), psId); if (ps == null) { diff --git a/java/com/google/gerrit/server/restapi/change/CreateMergePatchSet.java b/java/com/google/gerrit/server/restapi/change/CreateMergePatchSet.java index 6df490cac4..f2e4bc5a1a 100644 --- a/java/com/google/gerrit/server/restapi/change/CreateMergePatchSet.java +++ b/java/com/google/gerrit/server/restapi/change/CreateMergePatchSet.java @@ -17,6 +17,7 @@ package com.google.gerrit.server.restapi.change; import com.google.common.base.MoreObjects; import com.google.common.base.Strings; import com.google.common.collect.Iterables; +import com.google.gerrit.exceptions.StorageException; import com.google.gerrit.extensions.client.ListChangesOption; import com.google.gerrit.extensions.common.ChangeInfo; import com.google.gerrit.extensions.common.MergeInput; @@ -57,7 +58,6 @@ import com.google.gerrit.server.update.RetryHelper; import com.google.gerrit.server.update.RetryingRestModifyView; import com.google.gerrit.server.update.UpdateException; import com.google.gerrit.server.util.time.TimeUtil; -import com.google.gwtorm.server.OrmException; import com.google.inject.Inject; import com.google.inject.Provider; import com.google.inject.Singleton; @@ -121,7 +121,7 @@ public class CreateMergePatchSet @Override protected Response applyImpl( BatchUpdate.Factory updateFactory, ChangeResource rsrc, MergePatchSetInput in) - throws OrmException, IOException, RestApiException, UpdateException, + throws StorageException, IOException, RestApiException, UpdateException, PermissionBackendException { // Not allowed to create a new patch set if the current patch set is locked. psUtil.checkPatchSetNotLocked(rsrc.getNotes()); @@ -200,7 +200,7 @@ public class CreateMergePatchSet } private PatchSet findBasePatchSet(String baseChange) - throws PermissionBackendException, OrmException, UnprocessableEntityException { + throws PermissionBackendException, StorageException, UnprocessableEntityException { List notes = changeFinder.find(baseChange); if (notes.size() != 1) { throw new UnprocessableEntityException("Base change not found: " + baseChange); diff --git a/java/com/google/gerrit/server/restapi/change/DeleteAssignee.java b/java/com/google/gerrit/server/restapi/change/DeleteAssignee.java index 907347f36b..c6e3ff474c 100644 --- a/java/com/google/gerrit/server/restapi/change/DeleteAssignee.java +++ b/java/com/google/gerrit/server/restapi/change/DeleteAssignee.java @@ -14,6 +14,7 @@ package com.google.gerrit.server.restapi.change; +import com.google.gerrit.exceptions.StorageException; import com.google.gerrit.extensions.common.AccountInfo; import com.google.gerrit.extensions.common.Input; import com.google.gerrit.extensions.restapi.Response; @@ -38,7 +39,6 @@ import com.google.gerrit.server.update.RetryHelper; import com.google.gerrit.server.update.RetryingRestModifyView; import com.google.gerrit.server.update.UpdateException; import com.google.gerrit.server.util.time.TimeUtil; -import com.google.gwtorm.server.OrmException; import com.google.inject.Inject; import com.google.inject.Singleton; @@ -68,7 +68,7 @@ public class DeleteAssignee @Override protected Response applyImpl( BatchUpdate.Factory updateFactory, ChangeResource rsrc, Input input) - throws RestApiException, UpdateException, OrmException, PermissionBackendException { + throws RestApiException, UpdateException, StorageException, PermissionBackendException { rsrc.permissions().check(ChangePermission.EDIT_ASSIGNEE); try (BatchUpdate bu = @@ -88,7 +88,7 @@ public class DeleteAssignee private AccountState deletedAssignee; @Override - public boolean updateChange(ChangeContext ctx) throws RestApiException, OrmException { + public boolean updateChange(ChangeContext ctx) throws RestApiException, StorageException { change = ctx.getChange(); ChangeUpdate update = ctx.getUpdate(change.currentPatchSetId()); Account.Id currentAssigneeId = change.getAssignee(); @@ -120,7 +120,7 @@ public class DeleteAssignee } @Override - public void postUpdate(Context ctx) throws OrmException { + public void postUpdate(Context ctx) throws StorageException { assigneeChanged.fire(change, ctx.getAccount(), deletedAssignee, ctx.getWhen()); } } diff --git a/java/com/google/gerrit/server/restapi/change/DeleteChangeEdit.java b/java/com/google/gerrit/server/restapi/change/DeleteChangeEdit.java index d49a804b2e..9871489ebe 100644 --- a/java/com/google/gerrit/server/restapi/change/DeleteChangeEdit.java +++ b/java/com/google/gerrit/server/restapi/change/DeleteChangeEdit.java @@ -14,6 +14,7 @@ package com.google.gerrit.server.restapi.change; +import com.google.gerrit.exceptions.StorageException; import com.google.gerrit.extensions.common.Input; import com.google.gerrit.extensions.restapi.AuthException; import com.google.gerrit.extensions.restapi.ResourceNotFoundException; @@ -23,7 +24,6 @@ import com.google.gerrit.server.change.ChangeEditResource; import com.google.gerrit.server.change.ChangeResource; import com.google.gerrit.server.edit.ChangeEdit; import com.google.gerrit.server.edit.ChangeEditUtil; -import com.google.gwtorm.server.OrmException; import com.google.inject.Inject; import com.google.inject.Singleton; import java.io.IOException; @@ -41,7 +41,7 @@ public class DeleteChangeEdit @Override public Response apply(ChangeResource rsrc, Input input) - throws AuthException, ResourceNotFoundException, IOException, OrmException { + throws AuthException, ResourceNotFoundException, IOException, StorageException { Optional edit = editUtil.byChange(rsrc.getNotes(), rsrc.getUser()); if (edit.isPresent()) { editUtil.delete(edit.get()); diff --git a/java/com/google/gerrit/server/restapi/change/DeleteChangeMessage.java b/java/com/google/gerrit/server/restapi/change/DeleteChangeMessage.java index 5dcd1fac2d..310c290bcb 100644 --- a/java/com/google/gerrit/server/restapi/change/DeleteChangeMessage.java +++ b/java/com/google/gerrit/server/restapi/change/DeleteChangeMessage.java @@ -20,6 +20,7 @@ import static java.util.Objects.requireNonNull; import com.google.common.annotations.VisibleForTesting; import com.google.common.base.Strings; import com.google.gerrit.common.Nullable; +import com.google.gerrit.exceptions.StorageException; import com.google.gerrit.extensions.api.changes.DeleteChangeMessageInput; import com.google.gerrit.extensions.common.ChangeMessageInfo; import com.google.gerrit.extensions.common.Input; @@ -43,7 +44,6 @@ import com.google.gerrit.server.update.RetryHelper; import com.google.gerrit.server.update.RetryingRestModifyView; import com.google.gerrit.server.update.UpdateException; import com.google.gerrit.server.util.time.TimeUtil; -import com.google.gwtorm.server.OrmException; import com.google.inject.Inject; import com.google.inject.Provider; import com.google.inject.Singleton; @@ -83,7 +83,7 @@ public class DeleteChangeMessage BatchUpdate.Factory updateFactory, ChangeMessageResource resource, DeleteChangeMessageInput input) - throws RestApiException, PermissionBackendException, OrmException, UpdateException, + throws RestApiException, PermissionBackendException, StorageException, UpdateException, IOException { CurrentUser user = userProvider.get(); permissionBackend.user(user).check(GlobalPermission.ADMINISTRATE_SERVER); @@ -103,7 +103,7 @@ public class DeleteChangeMessage } private ChangeMessageInfo createUpdatedChangeMessageInfo(Change.Id id, int targetIdx) - throws OrmException, PermissionBackendException { + throws StorageException, PermissionBackendException { List messages = changeMessagesUtil.byChange(notesFactory.createChecked(id)); ChangeMessage updatedChangeMessage = messages.get(targetIdx); AccountLoader accountLoader = accountLoaderFactory.create(true); diff --git a/java/com/google/gerrit/server/restapi/change/DeleteComment.java b/java/com/google/gerrit/server/restapi/change/DeleteComment.java index e73c4f3dbe..3a0bcf13f8 100644 --- a/java/com/google/gerrit/server/restapi/change/DeleteComment.java +++ b/java/com/google/gerrit/server/restapi/change/DeleteComment.java @@ -15,6 +15,7 @@ package com.google.gerrit.server.restapi.change; import com.google.common.base.Strings; +import com.google.gerrit.exceptions.StorageException; import com.google.gerrit.extensions.api.changes.DeleteCommentInput; import com.google.gerrit.extensions.common.CommentInfo; import com.google.gerrit.extensions.restapi.ResourceConflictException; @@ -36,7 +37,6 @@ import com.google.gerrit.server.update.RetryHelper; import com.google.gerrit.server.update.RetryingRestModifyView; import com.google.gerrit.server.update.UpdateException; import com.google.gerrit.server.util.time.TimeUtil; -import com.google.gwtorm.server.OrmException; import com.google.inject.Inject; import com.google.inject.Provider; import com.google.inject.Singleton; @@ -74,7 +74,7 @@ public class DeleteComment @Override public CommentInfo applyImpl( BatchUpdate.Factory batchUpdateFactory, CommentResource rsrc, DeleteCommentInput input) - throws RestApiException, IOException, ConfigInvalidException, OrmException, + throws RestApiException, IOException, ConfigInvalidException, StorageException, PermissionBackendException, UpdateException { CurrentUser user = userProvider.get(); permissionBackend.user(user).check(GlobalPermission.ADMINISTRATE_SERVER); diff --git a/java/com/google/gerrit/server/restapi/change/DeleteDraftComment.java b/java/com/google/gerrit/server/restapi/change/DeleteDraftComment.java index bcff6e4fac..0c89d8fd26 100644 --- a/java/com/google/gerrit/server/restapi/change/DeleteDraftComment.java +++ b/java/com/google/gerrit/server/restapi/change/DeleteDraftComment.java @@ -16,6 +16,7 @@ package com.google.gerrit.server.restapi.change; import static com.google.gerrit.server.CommentsUtil.setCommentRevId; +import com.google.gerrit.exceptions.StorageException; import com.google.gerrit.extensions.common.CommentInfo; import com.google.gerrit.extensions.common.Input; import com.google.gerrit.extensions.restapi.ResourceNotFoundException; @@ -35,7 +36,6 @@ import com.google.gerrit.server.update.RetryHelper; import com.google.gerrit.server.update.RetryingRestModifyView; import com.google.gerrit.server.update.UpdateException; import com.google.gerrit.server.util.time.TimeUtil; -import com.google.gwtorm.server.OrmException; import com.google.inject.Inject; import com.google.inject.Singleton; import java.util.Collections; @@ -83,7 +83,7 @@ public class DeleteDraftComment @Override public boolean updateChange(ChangeContext ctx) - throws ResourceNotFoundException, OrmException, PatchListNotAvailableException { + throws ResourceNotFoundException, StorageException, PatchListNotAvailableException { Optional maybeComment = commentsUtil.getDraft(ctx.getNotes(), ctx.getIdentifiedUser(), key); if (!maybeComment.isPresent()) { diff --git a/java/com/google/gerrit/server/restapi/change/DeleteVote.java b/java/com/google/gerrit/server/restapi/change/DeleteVote.java index 3a167bf46c..f39249f9a3 100644 --- a/java/com/google/gerrit/server/restapi/change/DeleteVote.java +++ b/java/com/google/gerrit/server/restapi/change/DeleteVote.java @@ -19,6 +19,7 @@ import static java.util.Objects.requireNonNull; import com.google.common.flogger.FluentLogger; import com.google.gerrit.common.data.LabelTypes; +import com.google.gerrit.exceptions.StorageException; import com.google.gerrit.extensions.api.changes.DeleteVoteInput; import com.google.gerrit.extensions.api.changes.NotifyHandling; import com.google.gerrit.extensions.restapi.AuthException; @@ -56,7 +57,6 @@ import com.google.gerrit.server.update.RetryingRestModifyView; import com.google.gerrit.server.update.UpdateException; import com.google.gerrit.server.util.LabelVote; import com.google.gerrit.server.util.time.TimeUtil; -import com.google.gwtorm.server.OrmException; import com.google.inject.Inject; import com.google.inject.Singleton; import java.io.IOException; @@ -105,7 +105,8 @@ public class DeleteVote extends RetryingRestModifyView applyImpl( BatchUpdate.Factory updateFactory, VoteResource rsrc, DeleteVoteInput input) - throws RestApiException, UpdateException, IOException, OrmException, ConfigInvalidException { + throws RestApiException, UpdateException, IOException, StorageException, + ConfigInvalidException { if (input == null) { input = new DeleteVoteInput(); } @@ -163,7 +164,7 @@ public class DeleteVote extends RetryingRestModifyView { @Override public BinaryResult apply(FileResource rsrc) - throws ResourceNotFoundException, IOException, NoSuchChangeException, OrmException { + throws ResourceNotFoundException, IOException, NoSuchChangeException, StorageException { String path = rsrc.getPatchKey().get(); RevisionResource rev = rsrc.getRevision(); ObjectId revstr = ObjectId.fromString(rev.getPatchSet().getRevision().get()); diff --git a/java/com/google/gerrit/server/restapi/change/DraftComments.java b/java/com/google/gerrit/server/restapi/change/DraftComments.java index 9f06252d0f..3815b29556 100644 --- a/java/com/google/gerrit/server/restapi/change/DraftComments.java +++ b/java/com/google/gerrit/server/restapi/change/DraftComments.java @@ -14,6 +14,7 @@ package com.google.gerrit.server.restapi.change; +import com.google.gerrit.exceptions.StorageException; import com.google.gerrit.extensions.registration.DynamicMap; import com.google.gerrit.extensions.restapi.AuthException; import com.google.gerrit.extensions.restapi.ChildCollection; @@ -25,7 +26,6 @@ import com.google.gerrit.server.CommentsUtil; import com.google.gerrit.server.CurrentUser; import com.google.gerrit.server.change.DraftCommentResource; import com.google.gerrit.server.change.RevisionResource; -import com.google.gwtorm.server.OrmException; import com.google.inject.Inject; import com.google.inject.Provider; import com.google.inject.Singleton; @@ -62,7 +62,7 @@ public class DraftComments implements ChildCollection { @Override public Response apply(RevisionResource resource) - throws AuthException, BadRequestException, ResourceNotFoundException, OrmException, + throws AuthException, BadRequestException, ResourceNotFoundException, StorageException, RepositoryNotFoundException, IOException, PatchListNotAvailableException, PermissionBackendException { checkOptions(); @@ -224,7 +224,7 @@ public class Files implements ChildCollection { } private Collection reviewed(RevisionResource resource) - throws AuthException, OrmException { + throws AuthException, StorageException { CurrentUser user = self.get(); if (!(user.isIdentifiedUser())) { throw new AuthException("Authentication required"); @@ -235,7 +235,7 @@ public class Files implements ChildCollection { Optional o; o = accountPatchReviewStore.call( - s -> s.findReviewed(patchSetId.getId(), userId), OrmException.class); + s -> s.findReviewed(patchSetId.getId(), userId), StorageException.class); if (o.isPresent()) { PatchSetWithReviewedFiles res = o.get(); @@ -257,7 +257,7 @@ public class Files implements ChildCollection { private List copy( Set paths, PatchSet.Id old, RevisionResource resource, Account.Id userId) - throws IOException, PatchListNotAvailableException, OrmException { + throws IOException, PatchListNotAvailableException, StorageException { Project.NameKey project = resource.getChange().getProject(); try (Repository git = gitManager.openRepository(project); ObjectReader reader = git.newObjectReader(); @@ -319,7 +319,7 @@ public class Files implements ChildCollection { accountPatchReviewStore.run( s -> s.markReviewed(resource.getPatchSet().getId(), userId, pathList), - OrmException.class); + StorageException.class); return pathList; } } diff --git a/java/com/google/gerrit/server/restapi/change/Fixes.java b/java/com/google/gerrit/server/restapi/change/Fixes.java index 1d8726d0b9..35b2f8768b 100644 --- a/java/com/google/gerrit/server/restapi/change/Fixes.java +++ b/java/com/google/gerrit/server/restapi/change/Fixes.java @@ -14,6 +14,7 @@ package com.google.gerrit.server.restapi.change; +import com.google.gerrit.exceptions.StorageException; import com.google.gerrit.extensions.registration.DynamicMap; import com.google.gerrit.extensions.restapi.ChildCollection; import com.google.gerrit.extensions.restapi.IdString; @@ -25,7 +26,6 @@ import com.google.gerrit.server.CommentsUtil; import com.google.gerrit.server.change.FixResource; import com.google.gerrit.server.change.RevisionResource; import com.google.gerrit.server.notedb.ChangeNotes; -import com.google.gwtorm.server.OrmException; import com.google.inject.Inject; import com.google.inject.Singleton; import java.util.List; @@ -50,7 +50,7 @@ public class Fixes implements ChildCollection { @Override public FixResource parse(RevisionResource revisionResource, IdString id) - throws ResourceNotFoundException, OrmException { + throws ResourceNotFoundException, StorageException { String fixId = id.get(); ChangeNotes changeNotes = revisionResource.getNotes(); diff --git a/java/com/google/gerrit/server/restapi/change/GetAssignee.java b/java/com/google/gerrit/server/restapi/change/GetAssignee.java index e95f8d8408..667a57c001 100644 --- a/java/com/google/gerrit/server/restapi/change/GetAssignee.java +++ b/java/com/google/gerrit/server/restapi/change/GetAssignee.java @@ -14,6 +14,7 @@ package com.google.gerrit.server.restapi.change; +import com.google.gerrit.exceptions.StorageException; import com.google.gerrit.extensions.common.AccountInfo; import com.google.gerrit.extensions.restapi.Response; import com.google.gerrit.extensions.restapi.RestReadView; @@ -21,7 +22,6 @@ import com.google.gerrit.reviewdb.client.Account; import com.google.gerrit.server.account.AccountLoader; import com.google.gerrit.server.change.ChangeResource; import com.google.gerrit.server.permissions.PermissionBackendException; -import com.google.gwtorm.server.OrmException; import com.google.inject.Inject; import com.google.inject.Singleton; import java.util.Optional; @@ -37,7 +37,7 @@ public class GetAssignee implements RestReadView { @Override public Response apply(ChangeResource rsrc) - throws OrmException, PermissionBackendException { + throws StorageException, PermissionBackendException { Optional assignee = Optional.ofNullable(rsrc.getChange().getAssignee()); if (assignee.isPresent()) { return Response.ok(accountLoaderFactory.create(true).fillOne(assignee.get())); diff --git a/java/com/google/gerrit/server/restapi/change/GetBlame.java b/java/com/google/gerrit/server/restapi/change/GetBlame.java index c7a80156f0..079a86713c 100644 --- a/java/com/google/gerrit/server/restapi/change/GetBlame.java +++ b/java/com/google/gerrit/server/restapi/change/GetBlame.java @@ -16,6 +16,7 @@ package com.google.gerrit.server.restapi.change; import com.google.common.collect.ListMultimap; import com.google.common.collect.MultimapBuilder; +import com.google.gerrit.exceptions.StorageException; import com.google.gerrit.extensions.common.BlameInfo; import com.google.gerrit.extensions.common.RangeInfo; import com.google.gerrit.extensions.restapi.CacheControl; @@ -32,7 +33,6 @@ import com.google.gerrit.server.patch.AutoMerger; import com.google.gerrit.server.project.InvalidChangeOperationException; import com.google.gitiles.blame.cache.BlameCache; import com.google.gitiles.blame.cache.Region; -import com.google.gwtorm.server.OrmException; import com.google.inject.Inject; import java.io.IOException; import java.util.ArrayList; @@ -79,7 +79,7 @@ public class GetBlame implements RestReadView { @Override public Response> apply(FileResource resource) - throws RestApiException, OrmException, IOException, InvalidChangeOperationException { + throws RestApiException, StorageException, IOException, InvalidChangeOperationException { Project.NameKey project = resource.getRevision().getChange().getProject(); try (Repository repository = repoManager.openRepository(project); ObjectInserter ins = repository.newObjectInserter(); diff --git a/java/com/google/gerrit/server/restapi/change/GetChange.java b/java/com/google/gerrit/server/restapi/change/GetChange.java index c8641d5f38..29d35b2d2b 100644 --- a/java/com/google/gerrit/server/restapi/change/GetChange.java +++ b/java/com/google/gerrit/server/restapi/change/GetChange.java @@ -16,6 +16,7 @@ package com.google.gerrit.server.restapi.change; import com.google.common.collect.ImmutableList; import com.google.common.collect.Streams; +import com.google.gerrit.exceptions.StorageException; import com.google.gerrit.extensions.client.ListChangesOption; import com.google.gerrit.extensions.client.ListOption; import com.google.gerrit.extensions.common.ChangeInfo; @@ -31,7 +32,6 @@ import com.google.gerrit.server.change.ChangeResource; import com.google.gerrit.server.change.PluginDefinedAttributesFactories; import com.google.gerrit.server.change.RevisionResource; import com.google.gerrit.server.query.change.ChangeData; -import com.google.gwtorm.server.OrmException; import com.google.inject.Inject; import java.util.EnumSet; import java.util.HashMap; @@ -74,11 +74,11 @@ public class GetChange } @Override - public Response apply(ChangeResource rsrc) throws OrmException { + public Response apply(ChangeResource rsrc) throws StorageException { return Response.withMustRevalidate(newChangeJson().format(rsrc)); } - Response apply(RevisionResource rsrc) throws OrmException { + Response apply(RevisionResource rsrc) throws StorageException { return Response.withMustRevalidate(newChangeJson().format(rsrc)); } diff --git a/java/com/google/gerrit/server/restapi/change/GetComment.java b/java/com/google/gerrit/server/restapi/change/GetComment.java index d067dff449..790e3eef01 100644 --- a/java/com/google/gerrit/server/restapi/change/GetComment.java +++ b/java/com/google/gerrit/server/restapi/change/GetComment.java @@ -14,11 +14,11 @@ package com.google.gerrit.server.restapi.change; +import com.google.gerrit.exceptions.StorageException; import com.google.gerrit.extensions.common.CommentInfo; import com.google.gerrit.extensions.restapi.RestReadView; import com.google.gerrit.server.change.CommentResource; import com.google.gerrit.server.permissions.PermissionBackendException; -import com.google.gwtorm.server.OrmException; import com.google.inject.Inject; import com.google.inject.Provider; import com.google.inject.Singleton; @@ -34,7 +34,8 @@ public class GetComment implements RestReadView { } @Override - public CommentInfo apply(CommentResource rsrc) throws OrmException, PermissionBackendException { + public CommentInfo apply(CommentResource rsrc) + throws StorageException, PermissionBackendException { return commentJson.get().newCommentFormatter().format(rsrc.getComment()); } } diff --git a/java/com/google/gerrit/server/restapi/change/GetContent.java b/java/com/google/gerrit/server/restapi/change/GetContent.java index c133581bb3..f6455fea94 100644 --- a/java/com/google/gerrit/server/restapi/change/GetContent.java +++ b/java/com/google/gerrit/server/restapi/change/GetContent.java @@ -14,6 +14,7 @@ package com.google.gerrit.server.restapi.change; +import com.google.gerrit.exceptions.StorageException; import com.google.gerrit.extensions.restapi.BadRequestException; import com.google.gerrit.extensions.restapi.BinaryResult; import com.google.gerrit.extensions.restapi.ResourceNotFoundException; @@ -30,7 +31,6 @@ import com.google.gerrit.server.patch.ComparisonType; import com.google.gerrit.server.patch.Text; import com.google.gerrit.server.project.NoSuchChangeException; import com.google.gerrit.server.project.ProjectCache; -import com.google.gwtorm.server.OrmException; import com.google.inject.Inject; import java.io.IOException; import org.eclipse.jgit.errors.RepositoryNotFoundException; @@ -63,7 +63,7 @@ public class GetContent implements RestReadView { @Override public BinaryResult apply(FileResource rsrc) - throws ResourceNotFoundException, IOException, BadRequestException, OrmException { + throws ResourceNotFoundException, IOException, BadRequestException, StorageException { String path = rsrc.getPatchKey().get(); if (Patch.COMMIT_MSG.equals(path)) { String msg = getMessage(rsrc.getRevision().getChangeResource().getNotes()); @@ -83,7 +83,7 @@ public class GetContent implements RestReadView { parent); } - private String getMessage(ChangeNotes notes) throws OrmException, IOException { + private String getMessage(ChangeNotes notes) throws StorageException, IOException { Change.Id changeId = notes.getChangeId(); PatchSet ps = psUtil.current(notes); if (ps == null) { @@ -99,7 +99,7 @@ public class GetContent implements RestReadView { } } - private byte[] getMergeList(ChangeNotes notes) throws OrmException, IOException { + private byte[] getMergeList(ChangeNotes notes) throws StorageException, IOException { Change.Id changeId = notes.getChangeId(); PatchSet ps = psUtil.current(notes); if (ps == null) { diff --git a/java/com/google/gerrit/server/restapi/change/GetDetail.java b/java/com/google/gerrit/server/restapi/change/GetDetail.java index 06fdd99fd9..93277b6b39 100644 --- a/java/com/google/gerrit/server/restapi/change/GetDetail.java +++ b/java/com/google/gerrit/server/restapi/change/GetDetail.java @@ -14,6 +14,7 @@ package com.google.gerrit.server.restapi.change; +import com.google.gerrit.exceptions.StorageException; import com.google.gerrit.extensions.client.ListChangesOption; import com.google.gerrit.extensions.common.ChangeInfo; import com.google.gerrit.extensions.restapi.Response; @@ -21,7 +22,6 @@ import com.google.gerrit.extensions.restapi.RestReadView; import com.google.gerrit.server.DynamicOptions; import com.google.gerrit.server.DynamicOptions.DynamicBean; import com.google.gerrit.server.change.ChangeResource; -import com.google.gwtorm.server.OrmException; import com.google.inject.Inject; import org.kohsuke.args4j.Option; @@ -59,7 +59,7 @@ public class GetDetail implements RestReadView, DynamicOptions.B } @Override - public Response apply(ChangeResource rsrc) throws OrmException { + public Response apply(ChangeResource rsrc) throws StorageException { return delegate.apply(rsrc); } } diff --git a/java/com/google/gerrit/server/restapi/change/GetDiff.java b/java/com/google/gerrit/server/restapi/change/GetDiff.java index 1fae7391ae..f9823fb128 100644 --- a/java/com/google/gerrit/server/restapi/change/GetDiff.java +++ b/java/com/google/gerrit/server/restapi/change/GetDiff.java @@ -24,6 +24,7 @@ import com.google.common.collect.Lists; import com.google.common.collect.Maps; import com.google.gerrit.common.data.PatchScript; import com.google.gerrit.common.data.PatchScript.DisplayMethod; +import com.google.gerrit.exceptions.StorageException; import com.google.gerrit.extensions.client.DiffPreferencesInfo; import com.google.gerrit.extensions.client.DiffPreferencesInfo.Whitespace; import com.google.gerrit.extensions.common.ChangeType; @@ -56,7 +57,6 @@ import com.google.gerrit.server.project.InvalidChangeOperationException; import com.google.gerrit.server.project.NoSuchChangeException; import com.google.gerrit.server.project.ProjectCache; import com.google.gerrit.server.project.ProjectState; -import com.google.gwtorm.server.OrmException; import com.google.inject.Inject; import java.io.IOException; import java.util.List; @@ -126,7 +126,7 @@ public class GetDiff implements RestReadView { @Override public Response apply(FileResource resource) - throws ResourceConflictException, ResourceNotFoundException, OrmException, AuthException, + throws ResourceConflictException, ResourceNotFoundException, StorageException, AuthException, InvalidChangeOperationException, IOException, PermissionBackendException { DiffPreferencesInfo prefs = new DiffPreferencesInfo(); if (whitespace != null) { diff --git a/java/com/google/gerrit/server/restapi/change/GetDraftComment.java b/java/com/google/gerrit/server/restapi/change/GetDraftComment.java index 604960748d..df5ba3d3cc 100644 --- a/java/com/google/gerrit/server/restapi/change/GetDraftComment.java +++ b/java/com/google/gerrit/server/restapi/change/GetDraftComment.java @@ -14,11 +14,11 @@ package com.google.gerrit.server.restapi.change; +import com.google.gerrit.exceptions.StorageException; import com.google.gerrit.extensions.common.CommentInfo; import com.google.gerrit.extensions.restapi.RestReadView; import com.google.gerrit.server.change.DraftCommentResource; import com.google.gerrit.server.permissions.PermissionBackendException; -import com.google.gwtorm.server.OrmException; import com.google.inject.Inject; import com.google.inject.Provider; import com.google.inject.Singleton; @@ -35,7 +35,7 @@ public class GetDraftComment implements RestReadView { @Override public CommentInfo apply(DraftCommentResource rsrc) - throws OrmException, PermissionBackendException { + throws StorageException, PermissionBackendException { return commentJson.get().newCommentFormatter().format(rsrc.getComment()); } } diff --git a/java/com/google/gerrit/server/restapi/change/GetHashtags.java b/java/com/google/gerrit/server/restapi/change/GetHashtags.java index 8369acf207..6395edf1af 100644 --- a/java/com/google/gerrit/server/restapi/change/GetHashtags.java +++ b/java/com/google/gerrit/server/restapi/change/GetHashtags.java @@ -14,13 +14,13 @@ package com.google.gerrit.server.restapi.change; +import com.google.gerrit.exceptions.StorageException; import com.google.gerrit.extensions.restapi.AuthException; import com.google.gerrit.extensions.restapi.BadRequestException; import com.google.gerrit.extensions.restapi.Response; import com.google.gerrit.extensions.restapi.RestReadView; import com.google.gerrit.server.change.ChangeResource; import com.google.gerrit.server.notedb.ChangeNotes; -import com.google.gwtorm.server.OrmException; import com.google.inject.Singleton; import java.io.IOException; import java.util.Collections; @@ -30,7 +30,7 @@ import java.util.Set; public class GetHashtags implements RestReadView { @Override public Response> apply(ChangeResource req) - throws AuthException, OrmException, IOException, BadRequestException { + throws AuthException, StorageException, IOException, BadRequestException { ChangeNotes notes = req.getNotes().load(); Set hashtags = notes.getHashtags(); if (hashtags == null) { diff --git a/java/com/google/gerrit/server/restapi/change/GetPastAssignees.java b/java/com/google/gerrit/server/restapi/change/GetPastAssignees.java index 279cfe3b21..db29818464 100644 --- a/java/com/google/gerrit/server/restapi/change/GetPastAssignees.java +++ b/java/com/google/gerrit/server/restapi/change/GetPastAssignees.java @@ -16,6 +16,7 @@ package com.google.gerrit.server.restapi.change; import static java.util.stream.Collectors.toList; +import com.google.gerrit.exceptions.StorageException; import com.google.gerrit.extensions.common.AccountInfo; import com.google.gerrit.extensions.restapi.Response; import com.google.gerrit.extensions.restapi.RestReadView; @@ -23,7 +24,6 @@ import com.google.gerrit.reviewdb.client.Account; import com.google.gerrit.server.account.AccountLoader; import com.google.gerrit.server.change.ChangeResource; import com.google.gerrit.server.permissions.PermissionBackendException; -import com.google.gwtorm.server.OrmException; import com.google.inject.Inject; import com.google.inject.Singleton; import java.util.Collections; @@ -41,7 +41,7 @@ public class GetPastAssignees implements RestReadView { @Override public Response> apply(ChangeResource rsrc) - throws OrmException, PermissionBackendException { + throws StorageException, PermissionBackendException { Set pastAssignees = rsrc.getNotes().load().getPastAssignees(); if (pastAssignees == null) { diff --git a/java/com/google/gerrit/server/restapi/change/GetPureRevert.java b/java/com/google/gerrit/server/restapi/change/GetPureRevert.java index dcafe565be..aa333594dc 100644 --- a/java/com/google/gerrit/server/restapi/change/GetPureRevert.java +++ b/java/com/google/gerrit/server/restapi/change/GetPureRevert.java @@ -15,6 +15,7 @@ package com.google.gerrit.server.restapi.change; import com.google.gerrit.common.Nullable; +import com.google.gerrit.exceptions.StorageException; import com.google.gerrit.extensions.common.PureRevertInfo; import com.google.gerrit.extensions.restapi.AuthException; import com.google.gerrit.extensions.restapi.BadRequestException; @@ -22,7 +23,6 @@ import com.google.gerrit.extensions.restapi.ResourceConflictException; import com.google.gerrit.extensions.restapi.RestReadView; import com.google.gerrit.server.change.ChangeResource; import com.google.gerrit.server.change.PureRevert; -import com.google.gwtorm.server.OrmException; import com.google.inject.Inject; import java.io.IOException; import java.util.Optional; @@ -48,7 +48,7 @@ public class GetPureRevert implements RestReadView { @Override public PureRevertInfo apply(ChangeResource rsrc) - throws ResourceConflictException, IOException, BadRequestException, OrmException, + throws ResourceConflictException, IOException, BadRequestException, StorageException, AuthException { boolean isPureRevert = pureRevert.get(rsrc.getNotes(), Optional.ofNullable(claimedOriginal)); return new PureRevertInfo(isPureRevert); diff --git a/java/com/google/gerrit/server/restapi/change/GetRelated.java b/java/com/google/gerrit/server/restapi/change/GetRelated.java index 9a605c0aab..74af7ef205 100644 --- a/java/com/google/gerrit/server/restapi/change/GetRelated.java +++ b/java/com/google/gerrit/server/restapi/change/GetRelated.java @@ -19,6 +19,7 @@ import static java.util.stream.Collectors.toSet; import com.google.common.annotations.VisibleForTesting; import com.google.common.collect.Lists; import com.google.gerrit.common.Nullable; +import com.google.gerrit.exceptions.StorageException; import com.google.gerrit.extensions.api.changes.RelatedChangeAndCommitInfo; import com.google.gerrit.extensions.api.changes.RelatedChangesInfo; import com.google.gerrit.extensions.common.CommitInfo; @@ -36,7 +37,6 @@ import com.google.gerrit.server.permissions.PermissionBackendException; import com.google.gerrit.server.project.NoSuchProjectException; import com.google.gerrit.server.query.change.ChangeData; import com.google.gerrit.server.query.change.InternalChangeQuery; -import com.google.gwtorm.server.OrmException; import com.google.inject.Inject; import com.google.inject.Provider; import com.google.inject.Singleton; @@ -70,7 +70,7 @@ public class GetRelated implements RestReadView { @Override public RelatedChangesInfo apply(RevisionResource rsrc) - throws RepositoryNotFoundException, IOException, OrmException, NoSuchProjectException, + throws RepositoryNotFoundException, IOException, StorageException, NoSuchProjectException, PermissionBackendException { RelatedChangesInfo relatedChangesInfo = new RelatedChangesInfo(); relatedChangesInfo.changes = getRelated(rsrc); @@ -78,7 +78,7 @@ public class GetRelated implements RestReadView { } private List getRelated(RevisionResource rsrc) - throws OrmException, IOException, PermissionBackendException { + throws StorageException, IOException, PermissionBackendException { Set groups = getAllGroups(rsrc.getNotes(), psUtil); if (groups.isEmpty()) { return Collections.emptyList(); @@ -124,11 +124,12 @@ public class GetRelated implements RestReadView { @VisibleForTesting public static Set getAllGroups(ChangeNotes notes, PatchSetUtil psUtil) - throws OrmException { + throws StorageException { return psUtil.byChange(notes).stream().flatMap(ps -> ps.getGroups().stream()).collect(toSet()); } - private void reloadChangeIfStale(List cds, PatchSet wantedPs) throws OrmException { + private void reloadChangeIfStale(List cds, PatchSet wantedPs) + throws StorageException { for (ChangeData cd : cds) { if (cd.getId().equals(wantedPs.getId().getParentKey())) { if (cd.patchSet(wantedPs.getId()) == null) { diff --git a/java/com/google/gerrit/server/restapi/change/GetReview.java b/java/com/google/gerrit/server/restapi/change/GetReview.java index 40e132d504..8768573a82 100644 --- a/java/com/google/gerrit/server/restapi/change/GetReview.java +++ b/java/com/google/gerrit/server/restapi/change/GetReview.java @@ -14,12 +14,12 @@ package com.google.gerrit.server.restapi.change; +import com.google.gerrit.exceptions.StorageException; import com.google.gerrit.extensions.client.ListChangesOption; import com.google.gerrit.extensions.common.ChangeInfo; import com.google.gerrit.extensions.restapi.Response; import com.google.gerrit.extensions.restapi.RestReadView; import com.google.gerrit.server.change.RevisionResource; -import com.google.gwtorm.server.OrmException; import com.google.inject.Inject; import com.google.inject.Singleton; @@ -35,7 +35,7 @@ public class GetReview implements RestReadView { } @Override - public Response apply(RevisionResource rsrc) throws OrmException { + public Response apply(RevisionResource rsrc) throws StorageException { return delegate.apply(rsrc); } } diff --git a/java/com/google/gerrit/server/restapi/change/GetReviewer.java b/java/com/google/gerrit/server/restapi/change/GetReviewer.java index a11380bdc1..acec16609d 100644 --- a/java/com/google/gerrit/server/restapi/change/GetReviewer.java +++ b/java/com/google/gerrit/server/restapi/change/GetReviewer.java @@ -14,12 +14,12 @@ package com.google.gerrit.server.restapi.change; +import com.google.gerrit.exceptions.StorageException; import com.google.gerrit.extensions.api.changes.ReviewerInfo; import com.google.gerrit.extensions.restapi.RestReadView; import com.google.gerrit.server.change.ReviewerJson; import com.google.gerrit.server.change.ReviewerResource; import com.google.gerrit.server.permissions.PermissionBackendException; -import com.google.gwtorm.server.OrmException; import com.google.inject.Inject; import com.google.inject.Singleton; import java.util.List; @@ -35,7 +35,7 @@ public class GetReviewer implements RestReadView { @Override public List apply(ReviewerResource rsrc) - throws OrmException, PermissionBackendException { + throws StorageException, PermissionBackendException { return json.format(rsrc); } } diff --git a/java/com/google/gerrit/server/restapi/change/GetRevisionActions.java b/java/com/google/gerrit/server/restapi/change/GetRevisionActions.java index b0b49a34e6..b3209a5b55 100644 --- a/java/com/google/gerrit/server/restapi/change/GetRevisionActions.java +++ b/java/com/google/gerrit/server/restapi/change/GetRevisionActions.java @@ -16,6 +16,8 @@ package com.google.gerrit.server.restapi.change; import com.google.common.hash.Hasher; import com.google.common.hash.Hashing; +import com.google.gerrit.exceptions.StorageException; +import com.google.gerrit.exceptions.StorageRuntimeException; import com.google.gerrit.extensions.common.ActionInfo; import com.google.gerrit.extensions.restapi.ETagView; import com.google.gerrit.extensions.restapi.Response; @@ -28,8 +30,6 @@ import com.google.gerrit.server.permissions.PermissionBackendException; import com.google.gerrit.server.query.change.ChangeData; import com.google.gerrit.server.submit.ChangeSet; import com.google.gerrit.server.submit.MergeSuperSet; -import com.google.gwtorm.server.OrmException; -import com.google.gwtorm.server.OrmRuntimeException; import com.google.inject.Inject; import com.google.inject.Provider; import com.google.inject.Singleton; @@ -57,7 +57,7 @@ public class GetRevisionActions implements ETagView { } @Override - public Response> apply(RevisionResource rsrc) throws OrmException { + public Response> apply(RevisionResource rsrc) throws StorageException { return Response.withMustRevalidate(delegate.format(rsrc)); } @@ -73,8 +73,8 @@ public class GetRevisionActions implements ETagView { changeResourceFactory.create(cd.notes(), user).prepareETag(h, user); } h.putBoolean(cs.furtherHiddenChanges()); - } catch (IOException | OrmException | PermissionBackendException e) { - throw new OrmRuntimeException(e); + } catch (IOException | StorageException | PermissionBackendException e) { + throw new StorageRuntimeException(e); } return h.hash().toString(); } diff --git a/java/com/google/gerrit/server/restapi/change/GetRobotComment.java b/java/com/google/gerrit/server/restapi/change/GetRobotComment.java index 01970683ab..8465d8b724 100644 --- a/java/com/google/gerrit/server/restapi/change/GetRobotComment.java +++ b/java/com/google/gerrit/server/restapi/change/GetRobotComment.java @@ -14,11 +14,11 @@ package com.google.gerrit.server.restapi.change; +import com.google.gerrit.exceptions.StorageException; import com.google.gerrit.extensions.common.RobotCommentInfo; import com.google.gerrit.extensions.restapi.RestReadView; import com.google.gerrit.server.change.RobotCommentResource; import com.google.gerrit.server.permissions.PermissionBackendException; -import com.google.gwtorm.server.OrmException; import com.google.inject.Inject; import com.google.inject.Provider; import com.google.inject.Singleton; @@ -35,7 +35,7 @@ public class GetRobotComment implements RestReadView { @Override public RobotCommentInfo apply(RobotCommentResource rsrc) - throws OrmException, PermissionBackendException { + throws StorageException, PermissionBackendException { return commentJson.get().newRobotCommentFormatter().format(rsrc.getComment()); } } diff --git a/java/com/google/gerrit/server/restapi/change/Ignore.java b/java/com/google/gerrit/server/restapi/change/Ignore.java index e31945171a..46c3a473b0 100644 --- a/java/com/google/gerrit/server/restapi/change/Ignore.java +++ b/java/com/google/gerrit/server/restapi/change/Ignore.java @@ -15,6 +15,7 @@ package com.google.gerrit.server.restapi.change; import com.google.common.flogger.FluentLogger; +import com.google.gerrit.exceptions.StorageException; import com.google.gerrit.extensions.common.Input; import com.google.gerrit.extensions.restapi.BadRequestException; import com.google.gerrit.extensions.restapi.ResourceConflictException; @@ -26,7 +27,6 @@ import com.google.gerrit.server.StarredChangesUtil; import com.google.gerrit.server.StarredChangesUtil.IllegalLabelException; import com.google.gerrit.server.StarredChangesUtil.MutuallyExclusiveLabelsException; import com.google.gerrit.server.change.ChangeResource; -import com.google.gwtorm.server.OrmException; import com.google.inject.Inject; import com.google.inject.Singleton; @@ -51,7 +51,7 @@ public class Ignore implements RestModifyView, UiAction apply(ChangeResource rsrc, Input input) - throws RestApiException, OrmException, IllegalLabelException { + throws RestApiException, StorageException, IllegalLabelException { try { if (rsrc.isUserOwner()) { throw new BadRequestException("cannot ignore own change"); @@ -73,7 +73,7 @@ public class Ignore implements RestModifyView, UiAction applyImpl( BatchUpdate.Factory updateFactory, ChangeResource rsrc, Input input) - throws IOException, AuthException, OrmException, PermissionBackendException { + throws IOException, AuthException, StorageException, PermissionBackendException { permissionBackend.currentUser().check(GlobalPermission.MAINTAIN_SERVER); indexer.index(rsrc.getChange()); return Response.none(); diff --git a/java/com/google/gerrit/server/restapi/change/ListChangeComments.java b/java/com/google/gerrit/server/restapi/change/ListChangeComments.java index 902a67eb80..5828f7b9ba 100644 --- a/java/com/google/gerrit/server/restapi/change/ListChangeComments.java +++ b/java/com/google/gerrit/server/restapi/change/ListChangeComments.java @@ -14,6 +14,7 @@ package com.google.gerrit.server.restapi.change; +import com.google.gerrit.exceptions.StorageException; import com.google.gerrit.extensions.common.CommentInfo; import com.google.gerrit.extensions.restapi.AuthException; import com.google.gerrit.extensions.restapi.RestReadView; @@ -21,7 +22,6 @@ import com.google.gerrit.server.CommentsUtil; import com.google.gerrit.server.change.ChangeResource; import com.google.gerrit.server.permissions.PermissionBackendException; import com.google.gerrit.server.query.change.ChangeData; -import com.google.gwtorm.server.OrmException; import com.google.inject.Inject; import com.google.inject.Provider; import com.google.inject.Singleton; @@ -46,7 +46,7 @@ public class ListChangeComments implements RestReadView { @Override public Map> apply(ChangeResource rsrc) - throws AuthException, OrmException, PermissionBackendException { + throws AuthException, StorageException, PermissionBackendException { ChangeData cd = changeDataFactory.create(rsrc.getNotes()); return commentJson .get() diff --git a/java/com/google/gerrit/server/restapi/change/ListChangeDrafts.java b/java/com/google/gerrit/server/restapi/change/ListChangeDrafts.java index 7bdc1398d0..8377258c5f 100644 --- a/java/com/google/gerrit/server/restapi/change/ListChangeDrafts.java +++ b/java/com/google/gerrit/server/restapi/change/ListChangeDrafts.java @@ -14,6 +14,7 @@ package com.google.gerrit.server.restapi.change; +import com.google.gerrit.exceptions.StorageException; import com.google.gerrit.extensions.common.CommentInfo; import com.google.gerrit.extensions.restapi.AuthException; import com.google.gerrit.extensions.restapi.RestReadView; @@ -22,7 +23,6 @@ import com.google.gerrit.server.CommentsUtil; import com.google.gerrit.server.change.ChangeResource; import com.google.gerrit.server.permissions.PermissionBackendException; import com.google.gerrit.server.query.change.ChangeData; -import com.google.gwtorm.server.OrmException; import com.google.inject.Inject; import com.google.inject.Provider; import com.google.inject.Singleton; @@ -47,7 +47,7 @@ public class ListChangeDrafts implements RestReadView { @Override public Map> apply(ChangeResource rsrc) - throws AuthException, OrmException, PermissionBackendException { + throws AuthException, StorageException, PermissionBackendException { if (!rsrc.getUser().isIdentifiedUser()) { throw new AuthException("Authentication required"); } diff --git a/java/com/google/gerrit/server/restapi/change/ListChangeMessages.java b/java/com/google/gerrit/server/restapi/change/ListChangeMessages.java index c658fc407b..aa8511852d 100644 --- a/java/com/google/gerrit/server/restapi/change/ListChangeMessages.java +++ b/java/com/google/gerrit/server/restapi/change/ListChangeMessages.java @@ -16,6 +16,7 @@ package com.google.gerrit.server.restapi.change; import static com.google.gerrit.server.ChangeMessagesUtil.createChangeMessageInfo; +import com.google.gerrit.exceptions.StorageException; import com.google.gerrit.extensions.common.ChangeMessageInfo; import com.google.gerrit.extensions.restapi.RestReadView; import com.google.gerrit.reviewdb.client.ChangeMessage; @@ -23,7 +24,6 @@ import com.google.gerrit.server.ChangeMessagesUtil; import com.google.gerrit.server.account.AccountLoader; import com.google.gerrit.server.change.ChangeResource; import com.google.gerrit.server.permissions.PermissionBackendException; -import com.google.gwtorm.server.OrmException; import com.google.inject.Inject; import com.google.inject.Singleton; import java.util.List; @@ -43,7 +43,7 @@ public class ListChangeMessages implements RestReadView { @Override public List apply(ChangeResource resource) - throws OrmException, PermissionBackendException { + throws StorageException, PermissionBackendException { List messages = changeMessagesUtil.byChange(resource.getNotes()); List messageInfos = messages.stream() diff --git a/java/com/google/gerrit/server/restapi/change/ListChangeRobotComments.java b/java/com/google/gerrit/server/restapi/change/ListChangeRobotComments.java index 3ea2ac2aeb..ac6508af83 100644 --- a/java/com/google/gerrit/server/restapi/change/ListChangeRobotComments.java +++ b/java/com/google/gerrit/server/restapi/change/ListChangeRobotComments.java @@ -14,6 +14,7 @@ package com.google.gerrit.server.restapi.change; +import com.google.gerrit.exceptions.StorageException; import com.google.gerrit.extensions.common.RobotCommentInfo; import com.google.gerrit.extensions.restapi.AuthException; import com.google.gerrit.extensions.restapi.RestReadView; @@ -21,7 +22,6 @@ import com.google.gerrit.server.CommentsUtil; import com.google.gerrit.server.change.ChangeResource; import com.google.gerrit.server.permissions.PermissionBackendException; import com.google.gerrit.server.query.change.ChangeData; -import com.google.gwtorm.server.OrmException; import com.google.inject.Inject; import com.google.inject.Provider; import java.util.List; @@ -44,7 +44,7 @@ public class ListChangeRobotComments implements RestReadView { @Override public Map> apply(ChangeResource rsrc) - throws AuthException, OrmException, PermissionBackendException { + throws AuthException, StorageException, PermissionBackendException { ChangeData cd = changeDataFactory.create(rsrc.getNotes()); return commentJson .get() diff --git a/java/com/google/gerrit/server/restapi/change/ListReviewers.java b/java/com/google/gerrit/server/restapi/change/ListReviewers.java index 65c8d45063..57b351d896 100644 --- a/java/com/google/gerrit/server/restapi/change/ListReviewers.java +++ b/java/com/google/gerrit/server/restapi/change/ListReviewers.java @@ -14,6 +14,7 @@ package com.google.gerrit.server.restapi.change; +import com.google.gerrit.exceptions.StorageException; import com.google.gerrit.extensions.api.changes.ReviewerInfo; import com.google.gerrit.extensions.restapi.RestReadView; import com.google.gerrit.mail.Address; @@ -23,7 +24,6 @@ import com.google.gerrit.server.change.ChangeResource; import com.google.gerrit.server.change.ReviewerJson; import com.google.gerrit.server.change.ReviewerResource; import com.google.gerrit.server.permissions.PermissionBackendException; -import com.google.gwtorm.server.OrmException; import com.google.inject.Inject; import com.google.inject.Singleton; import java.util.LinkedHashMap; @@ -46,7 +46,7 @@ public class ListReviewers implements RestReadView { @Override public List apply(ChangeResource rsrc) - throws OrmException, PermissionBackendException { + throws StorageException, PermissionBackendException { Map reviewers = new LinkedHashMap<>(); for (Account.Id accountId : approvalsUtil.getReviewers(rsrc.getNotes()).all()) { if (!reviewers.containsKey(accountId.toString())) { diff --git a/java/com/google/gerrit/server/restapi/change/ListRevisionComments.java b/java/com/google/gerrit/server/restapi/change/ListRevisionComments.java index f10d92bb83..7cb62cea52 100644 --- a/java/com/google/gerrit/server/restapi/change/ListRevisionComments.java +++ b/java/com/google/gerrit/server/restapi/change/ListRevisionComments.java @@ -14,11 +14,11 @@ package com.google.gerrit.server.restapi.change; +import com.google.gerrit.exceptions.StorageException; import com.google.gerrit.reviewdb.client.Comment; import com.google.gerrit.server.CommentsUtil; import com.google.gerrit.server.change.RevisionResource; import com.google.gerrit.server.notedb.ChangeNotes; -import com.google.gwtorm.server.OrmException; import com.google.inject.Inject; import com.google.inject.Provider; import com.google.inject.Singleton; @@ -36,7 +36,7 @@ public class ListRevisionComments extends ListRevisionDrafts { } @Override - protected Iterable listComments(RevisionResource rsrc) throws OrmException { + protected Iterable listComments(RevisionResource rsrc) throws StorageException { ChangeNotes notes = rsrc.getNotes(); return commentsUtil.publishedByPatchSet(notes, rsrc.getPatchSet().getId()); } diff --git a/java/com/google/gerrit/server/restapi/change/ListRevisionDrafts.java b/java/com/google/gerrit/server/restapi/change/ListRevisionDrafts.java index 3df7e9c37c..d988990dc5 100644 --- a/java/com/google/gerrit/server/restapi/change/ListRevisionDrafts.java +++ b/java/com/google/gerrit/server/restapi/change/ListRevisionDrafts.java @@ -15,13 +15,13 @@ package com.google.gerrit.server.restapi.change; import com.google.common.collect.ImmutableList; +import com.google.gerrit.exceptions.StorageException; import com.google.gerrit.extensions.common.CommentInfo; import com.google.gerrit.extensions.restapi.RestReadView; import com.google.gerrit.reviewdb.client.Comment; import com.google.gerrit.server.CommentsUtil; import com.google.gerrit.server.change.RevisionResource; import com.google.gerrit.server.permissions.PermissionBackendException; -import com.google.gwtorm.server.OrmException; import com.google.inject.Inject; import com.google.inject.Provider; import com.google.inject.Singleton; @@ -39,7 +39,7 @@ public class ListRevisionDrafts implements RestReadView { this.commentsUtil = commentsUtil; } - protected Iterable listComments(RevisionResource rsrc) throws OrmException { + protected Iterable listComments(RevisionResource rsrc) throws StorageException { return commentsUtil.draftByPatchSetAuthor( rsrc.getPatchSet().getId(), rsrc.getAccountId(), rsrc.getNotes()); } @@ -50,7 +50,7 @@ public class ListRevisionDrafts implements RestReadView { @Override public Map> apply(RevisionResource rsrc) - throws OrmException, PermissionBackendException { + throws StorageException, PermissionBackendException { return commentJson .get() .setFillAccounts(includeAuthorInfo()) @@ -59,7 +59,7 @@ public class ListRevisionDrafts implements RestReadView { } public ImmutableList getComments(RevisionResource rsrc) - throws OrmException, PermissionBackendException { + throws StorageException, PermissionBackendException { return commentJson .get() .setFillAccounts(includeAuthorInfo()) diff --git a/java/com/google/gerrit/server/restapi/change/ListRevisionReviewers.java b/java/com/google/gerrit/server/restapi/change/ListRevisionReviewers.java index 6e7ffd9ece..a5bbbe34d1 100644 --- a/java/com/google/gerrit/server/restapi/change/ListRevisionReviewers.java +++ b/java/com/google/gerrit/server/restapi/change/ListRevisionReviewers.java @@ -14,6 +14,7 @@ package com.google.gerrit.server.restapi.change; +import com.google.gerrit.exceptions.StorageException; import com.google.gerrit.extensions.api.changes.ReviewerInfo; import com.google.gerrit.extensions.restapi.MethodNotAllowedException; import com.google.gerrit.extensions.restapi.RestReadView; @@ -24,7 +25,6 @@ import com.google.gerrit.server.change.ReviewerJson; import com.google.gerrit.server.change.ReviewerResource; import com.google.gerrit.server.change.RevisionResource; import com.google.gerrit.server.permissions.PermissionBackendException; -import com.google.gwtorm.server.OrmException; import com.google.inject.Inject; import com.google.inject.Singleton; import java.util.LinkedHashMap; @@ -47,7 +47,7 @@ class ListRevisionReviewers implements RestReadView { @Override public List apply(RevisionResource rsrc) - throws OrmException, MethodNotAllowedException, PermissionBackendException { + throws StorageException, MethodNotAllowedException, PermissionBackendException { if (!rsrc.isCurrent()) { throw new MethodNotAllowedException("Cannot list reviewers on non-current patch set"); } diff --git a/java/com/google/gerrit/server/restapi/change/ListRobotComments.java b/java/com/google/gerrit/server/restapi/change/ListRobotComments.java index c13b1e74b9..20c9bc1c02 100644 --- a/java/com/google/gerrit/server/restapi/change/ListRobotComments.java +++ b/java/com/google/gerrit/server/restapi/change/ListRobotComments.java @@ -15,13 +15,13 @@ package com.google.gerrit.server.restapi.change; import com.google.common.collect.ImmutableList; +import com.google.gerrit.exceptions.StorageException; import com.google.gerrit.extensions.common.RobotCommentInfo; import com.google.gerrit.extensions.restapi.RestReadView; import com.google.gerrit.reviewdb.client.RobotComment; import com.google.gerrit.server.CommentsUtil; import com.google.gerrit.server.change.RevisionResource; import com.google.gerrit.server.permissions.PermissionBackendException; -import com.google.gwtorm.server.OrmException; import com.google.inject.Inject; import com.google.inject.Provider; import com.google.inject.Singleton; @@ -41,7 +41,7 @@ public class ListRobotComments implements RestReadView { @Override public Map> apply(RevisionResource rsrc) - throws OrmException, PermissionBackendException { + throws StorageException, PermissionBackendException { return commentJson .get() .setFillAccounts(true) @@ -50,7 +50,7 @@ public class ListRobotComments implements RestReadView { } public ImmutableList getComments(RevisionResource rsrc) - throws OrmException, PermissionBackendException { + throws StorageException, PermissionBackendException { return commentJson .get() .setFillAccounts(true) @@ -58,7 +58,7 @@ public class ListRobotComments implements RestReadView { .formatAsList(listComments(rsrc)); } - private Iterable listComments(RevisionResource rsrc) throws OrmException { + private Iterable listComments(RevisionResource rsrc) throws StorageException { return commentsUtil.robotCommentsByPatchSet(rsrc.getNotes(), rsrc.getPatchSet().getId()); } } diff --git a/java/com/google/gerrit/server/restapi/change/MarkAsReviewed.java b/java/com/google/gerrit/server/restapi/change/MarkAsReviewed.java index 49c8fb650d..7c024b6e0e 100644 --- a/java/com/google/gerrit/server/restapi/change/MarkAsReviewed.java +++ b/java/com/google/gerrit/server/restapi/change/MarkAsReviewed.java @@ -15,6 +15,7 @@ package com.google.gerrit.server.restapi.change; import com.google.common.flogger.FluentLogger; +import com.google.gerrit.exceptions.StorageException; import com.google.gerrit.extensions.common.Input; import com.google.gerrit.extensions.restapi.Response; import com.google.gerrit.extensions.restapi.RestApiException; @@ -24,7 +25,6 @@ import com.google.gerrit.server.StarredChangesUtil; import com.google.gerrit.server.StarredChangesUtil.IllegalLabelException; import com.google.gerrit.server.change.ChangeResource; import com.google.gerrit.server.query.change.ChangeData; -import com.google.gwtorm.server.OrmException; import com.google.inject.Inject; import com.google.inject.Singleton; @@ -52,7 +52,7 @@ public class MarkAsReviewed @Override public Response apply(ChangeResource rsrc, Input input) - throws RestApiException, OrmException, IllegalLabelException { + throws RestApiException, StorageException, IllegalLabelException { stars.markAsReviewed(rsrc); return Response.ok(""); } @@ -62,7 +62,7 @@ public class MarkAsReviewed return changeDataFactory .create(rsrc.getNotes()) .isReviewedBy(rsrc.getUser().asIdentifiedUser().getAccountId()); - } catch (OrmException e) { + } catch (StorageException e) { logger.atSevere().withCause(e).log("failed to check if change is reviewed"); } return false; diff --git a/java/com/google/gerrit/server/restapi/change/MarkAsUnreviewed.java b/java/com/google/gerrit/server/restapi/change/MarkAsUnreviewed.java index 0651e7b037..0a1bac8d63 100644 --- a/java/com/google/gerrit/server/restapi/change/MarkAsUnreviewed.java +++ b/java/com/google/gerrit/server/restapi/change/MarkAsUnreviewed.java @@ -15,6 +15,7 @@ package com.google.gerrit.server.restapi.change; import com.google.common.flogger.FluentLogger; +import com.google.gerrit.exceptions.StorageException; import com.google.gerrit.extensions.common.Input; import com.google.gerrit.extensions.restapi.Response; import com.google.gerrit.extensions.restapi.RestModifyView; @@ -23,7 +24,6 @@ import com.google.gerrit.server.StarredChangesUtil; import com.google.gerrit.server.StarredChangesUtil.IllegalLabelException; import com.google.gerrit.server.change.ChangeResource; import com.google.gerrit.server.query.change.ChangeData; -import com.google.gwtorm.server.OrmException; import com.google.inject.Inject; import com.google.inject.Singleton; @@ -51,7 +51,7 @@ public class MarkAsUnreviewed @Override public Response apply(ChangeResource rsrc, Input input) - throws OrmException, IllegalLabelException { + throws StorageException, IllegalLabelException { stars.markAsUnreviewed(rsrc); return Response.ok(""); } @@ -61,7 +61,7 @@ public class MarkAsUnreviewed return changeDataFactory .create(rsrc.getNotes()) .isReviewedBy(rsrc.getUser().asIdentifiedUser().getAccountId()); - } catch (OrmException e) { + } catch (StorageException e) { logger.atSevere().withCause(e).log("failed to check if change is reviewed"); } return false; diff --git a/java/com/google/gerrit/server/restapi/change/Mergeable.java b/java/com/google/gerrit/server/restapi/change/Mergeable.java index 44413978ee..c5634ccbcd 100644 --- a/java/com/google/gerrit/server/restapi/change/Mergeable.java +++ b/java/com/google/gerrit/server/restapi/change/Mergeable.java @@ -16,6 +16,7 @@ package com.google.gerrit.server.restapi.change; import com.google.common.flogger.FluentLogger; import com.google.gerrit.common.data.SubmitTypeRecord; +import com.google.gerrit.exceptions.StorageException; import com.google.gerrit.extensions.client.SubmitType; import com.google.gerrit.extensions.common.MergeableInfo; import com.google.gerrit.extensions.restapi.AuthException; @@ -36,7 +37,6 @@ import com.google.gerrit.server.project.ProjectState; import com.google.gerrit.server.project.SubmitRuleEvaluator; import com.google.gerrit.server.project.SubmitRuleOptions; import com.google.gerrit.server.query.change.ChangeData; -import com.google.gwtorm.server.OrmException; import com.google.inject.Inject; import java.io.IOException; import java.util.ArrayList; @@ -90,7 +90,7 @@ public class Mergeable implements RestReadView { @Override public MergeableInfo apply(RevisionResource resource) - throws AuthException, ResourceConflictException, BadRequestException, OrmException, + throws AuthException, ResourceConflictException, BadRequestException, StorageException, IOException { Change change = resource.getChange(); PatchSet ps = resource.getPatchSet(); @@ -136,10 +136,10 @@ public class Mergeable implements RestReadView { return result; } - private SubmitType getSubmitType(ChangeData cd) throws OrmException { + private SubmitType getSubmitType(ChangeData cd) throws StorageException { SubmitTypeRecord rec = submitRuleEvaluator.getSubmitType(cd); if (rec.status != SubmitTypeRecord.Status.OK) { - throw new OrmException("Submit type rule failed: " + rec); + throw new StorageException("Submit type rule failed: " + rec); } return rec.type; } diff --git a/java/com/google/gerrit/server/restapi/change/Move.java b/java/com/google/gerrit/server/restapi/change/Move.java index 36f91bbb63..3d9d54fe14 100644 --- a/java/com/google/gerrit/server/restapi/change/Move.java +++ b/java/com/google/gerrit/server/restapi/change/Move.java @@ -23,6 +23,7 @@ import com.google.common.base.Strings; import com.google.common.flogger.FluentLogger; import com.google.gerrit.common.Nullable; import com.google.gerrit.common.data.LabelType; +import com.google.gerrit.exceptions.StorageException; import com.google.gerrit.extensions.api.changes.MoveInput; import com.google.gerrit.extensions.common.ChangeInfo; import com.google.gerrit.extensions.restapi.AuthException; @@ -61,7 +62,6 @@ import com.google.gerrit.server.update.RetryHelper; import com.google.gerrit.server.update.RetryingRestModifyView; import com.google.gerrit.server.update.UpdateException; import com.google.gerrit.server.util.time.TimeUtil; -import com.google.gwtorm.server.OrmException; import com.google.inject.Inject; import com.google.inject.Provider; import com.google.inject.Singleton; @@ -116,7 +116,7 @@ public class Move extends RetryingRestModifyView approvals = new ArrayList<>(); for (PatchSetApproval psa : approvalsUtil.byPatchSet( @@ -310,7 +310,7 @@ public class Move extends RetryingRestModifyView applyImpl( BatchUpdate.Factory updateFactory, RevisionResource revision, ReviewInput input) - throws RestApiException, UpdateException, OrmException, IOException, + throws RestApiException, UpdateException, StorageException, IOException, PermissionBackendException, ConfigInvalidException, PatchListNotAvailableException { return apply(updateFactory, revision, input, TimeUtil.nowTs()); } public Response apply( BatchUpdate.Factory updateFactory, RevisionResource revision, ReviewInput input, Timestamp ts) - throws RestApiException, UpdateException, OrmException, IOException, + throws RestApiException, UpdateException, StorageException, IOException, PermissionBackendException, ConfigInvalidException, PatchListNotAvailableException { // Respect timestamp, but truncate at change created-on time. ts = Ordering.natural().max(ts, revision.getChange().getCreatedOn()); @@ -438,7 +438,7 @@ public class PostReview } private RevisionResource onBehalfOf(RevisionResource rev, LabelTypes labelTypes, ReviewInput in) - throws BadRequestException, AuthException, UnprocessableEntityException, OrmException, + throws BadRequestException, AuthException, UnprocessableEntityException, StorageException, PermissionBackendException, IOException, ConfigInvalidException { if (in.labels == null || in.labels.isEmpty()) { throw new AuthException( @@ -854,8 +854,8 @@ public class PostReview @Override public boolean updateChange(ChangeContext ctx) - throws OrmException, ResourceConflictException, UnprocessableEntityException, IOException, - PatchListNotAvailableException { + throws StorageException, ResourceConflictException, UnprocessableEntityException, + IOException, PatchListNotAvailableException { user = ctx.getIdentifiedUser(); notes = ctx.getNotes(); ps = psUtil.get(ctx.getNotes(), psId); @@ -868,7 +868,7 @@ public class PostReview } @Override - public void postUpdate(Context ctx) throws OrmException { + public void postUpdate(Context ctx) throws StorageException { if (message == null) { return; } @@ -889,7 +889,7 @@ public class PostReview } private boolean insertComments(ChangeContext ctx) - throws OrmException, UnprocessableEntityException, PatchListNotAvailableException { + throws StorageException, UnprocessableEntityException, PatchListNotAvailableException { Map> map = in.comments; if (map == null) { map = Collections.emptyMap(); @@ -950,7 +950,7 @@ public class PostReview } private boolean insertRobotComments(ChangeContext ctx) - throws OrmException, PatchListNotAvailableException { + throws StorageException, PatchListNotAvailableException { if (in.robotComments == null) { return false; } @@ -962,7 +962,7 @@ public class PostReview } private List getNewRobotComments(ChangeContext ctx) - throws OrmException, PatchListNotAvailableException { + throws StorageException, PatchListNotAvailableException { List toAdd = new ArrayList<>(in.robotComments.size()); Set existingIds = @@ -1031,19 +1031,20 @@ public class PostReview return new FixReplacement(fixReplacementInfo.path, range, fixReplacementInfo.replacement); } - private Set readExistingComments(ChangeContext ctx) throws OrmException { + private Set readExistingComments(ChangeContext ctx) throws StorageException { return commentsUtil.publishedByChange(ctx.getNotes()).stream() .map(CommentSetEntry::create) .collect(toSet()); } - private Set readExistingRobotComments(ChangeContext ctx) throws OrmException { + private Set readExistingRobotComments(ChangeContext ctx) + throws StorageException { return commentsUtil.robotCommentsByChange(ctx.getNotes()).stream() .map(CommentSetEntry::create) .collect(toSet()); } - private Map changeDrafts(ChangeContext ctx) throws OrmException { + private Map changeDrafts(ChangeContext ctx) throws StorageException { Map drafts = new HashMap<>(); for (Comment c : commentsUtil.draftByChangeAuthor(ctx.getNotes(), user.getAccountId())) { c.tag = in.tag; @@ -1052,7 +1053,7 @@ public class PostReview return drafts; } - private Map patchSetDrafts(ChangeContext ctx) throws OrmException { + private Map patchSetDrafts(ChangeContext ctx) throws StorageException { Map drafts = new HashMap<>(); for (Comment c : commentsUtil.draftByPatchSetAuthor(psId, user.getAccountId(), ctx.getNotes())) { @@ -1100,7 +1101,7 @@ public class PostReview return previous; } - private boolean isReviewer(ChangeContext ctx) throws OrmException { + private boolean isReviewer(ChangeContext ctx) throws StorageException { if (ctx.getAccountId().equals(ctx.getChange().getOwner())) { return true; } @@ -1113,7 +1114,7 @@ public class PostReview } private boolean updateLabels(ProjectState projectState, ChangeContext ctx) - throws OrmException, ResourceConflictException, IOException { + throws StorageException, ResourceConflictException, IOException { Map inLabels = firstNonNull(in.labels, Collections.emptyMap()); // If no labels were modified and change is closed, abort early. @@ -1297,7 +1298,7 @@ public class PostReview private Map scanLabels( ProjectState projectState, ChangeContext ctx, List del) - throws OrmException, IOException { + throws StorageException, IOException { LabelTypes labelTypes = projectState.getLabelTypes(ctx.getNotes()); Map current = new HashMap<>(); diff --git a/java/com/google/gerrit/server/restapi/change/PostReviewers.java b/java/com/google/gerrit/server/restapi/change/PostReviewers.java index 4aeb07fc78..13fad2dc9d 100644 --- a/java/com/google/gerrit/server/restapi/change/PostReviewers.java +++ b/java/com/google/gerrit/server/restapi/change/PostReviewers.java @@ -14,6 +14,7 @@ package com.google.gerrit.server.restapi.change; +import com.google.gerrit.exceptions.StorageException; import com.google.gerrit.extensions.api.changes.AddReviewerInput; import com.google.gerrit.extensions.api.changes.AddReviewerResult; import com.google.gerrit.extensions.api.changes.NotifyHandling; @@ -32,7 +33,6 @@ import com.google.gerrit.server.update.RetryHelper; import com.google.gerrit.server.update.RetryingRestCollectionModifyView; import com.google.gerrit.server.update.UpdateException; import com.google.gerrit.server.util.time.TimeUtil; -import com.google.gwtorm.server.OrmException; import com.google.inject.Inject; import com.google.inject.Singleton; import java.io.IOException; @@ -62,7 +62,7 @@ public class PostReviewers @Override protected AddReviewerResult applyImpl( BatchUpdate.Factory updateFactory, ChangeResource rsrc, AddReviewerInput input) - throws IOException, OrmException, RestApiException, UpdateException, + throws IOException, StorageException, RestApiException, UpdateException, PermissionBackendException, ConfigInvalidException { if (input.reviewer == null) { throw new BadRequestException("missing reviewer field"); @@ -86,7 +86,7 @@ public class PostReviewers } private NotifyResolver.Result resolveNotify(ChangeResource rsrc, AddReviewerInput input) - throws BadRequestException, OrmException, ConfigInvalidException, IOException { + throws BadRequestException, StorageException, ConfigInvalidException, IOException { NotifyHandling notifyHandling = input.notify; if (notifyHandling == null) { notifyHandling = diff --git a/java/com/google/gerrit/server/restapi/change/PreviewSubmit.java b/java/com/google/gerrit/server/restapi/change/PreviewSubmit.java index 08d86da097..9270bd5670 100644 --- a/java/com/google/gerrit/server/restapi/change/PreviewSubmit.java +++ b/java/com/google/gerrit/server/restapi/change/PreviewSubmit.java @@ -15,6 +15,7 @@ package com.google.gerrit.server.restapi.change; import com.google.common.base.Strings; +import com.google.gerrit.exceptions.StorageException; import com.google.gerrit.extensions.api.changes.SubmitInput; import com.google.gerrit.extensions.restapi.BadRequestException; import com.google.gerrit.extensions.restapi.BinaryResult; @@ -39,7 +40,6 @@ import com.google.gerrit.server.submit.MergeOp; import com.google.gerrit.server.submit.MergeOpRepoManager; import com.google.gerrit.server.submit.MergeOpRepoManager.OpenRepo; import com.google.gerrit.server.update.UpdateException; -import com.google.gwtorm.server.OrmException; import com.google.inject.Inject; import com.google.inject.Provider; import com.google.inject.Singleton; @@ -82,8 +82,8 @@ public class PreviewSubmit implements RestReadView { @Override public BinaryResult apply(RevisionResource rsrc) - throws OrmException, RestApiException, UpdateException, IOException, ConfigInvalidException, - PermissionBackendException { + throws StorageException, RestApiException, UpdateException, IOException, + ConfigInvalidException, PermissionBackendException { if (Strings.isNullOrEmpty(format)) { throw new BadRequestException("format is not specified"); } @@ -110,8 +110,8 @@ public class PreviewSubmit implements RestReadView { } private BinaryResult getBundles(RevisionResource rsrc, ArchiveFormat f) - throws OrmException, RestApiException, UpdateException, IOException, ConfigInvalidException, - PermissionBackendException { + throws StorageException, RestApiException, UpdateException, IOException, + ConfigInvalidException, PermissionBackendException { IdentifiedUser caller = rsrc.getUser().asIdentifiedUser(); Change change = rsrc.getChange(); @@ -124,7 +124,7 @@ public class PreviewSubmit implements RestReadView { .setContentType(f.getMimeType()) .setAttachmentName("submit-preview-" + change.getChangeId() + "." + format); return bin; - } catch (OrmException + } catch (StorageException | RestApiException | UpdateException | IOException diff --git a/java/com/google/gerrit/server/restapi/change/PublishChangeEdit.java b/java/com/google/gerrit/server/restapi/change/PublishChangeEdit.java index b0cad84d08..f07aa7a0b5 100644 --- a/java/com/google/gerrit/server/restapi/change/PublishChangeEdit.java +++ b/java/com/google/gerrit/server/restapi/change/PublishChangeEdit.java @@ -16,6 +16,7 @@ package com.google.gerrit.server.restapi.change; import static com.google.common.base.MoreObjects.firstNonNull; +import com.google.gerrit.exceptions.StorageException; import com.google.gerrit.extensions.api.changes.NotifyHandling; import com.google.gerrit.extensions.api.changes.PublishChangeEditInput; import com.google.gerrit.extensions.restapi.ResourceConflictException; @@ -31,7 +32,6 @@ import com.google.gerrit.server.update.BatchUpdate; import com.google.gerrit.server.update.RetryHelper; import com.google.gerrit.server.update.RetryingRestModifyView; import com.google.gerrit.server.update.UpdateException; -import com.google.gwtorm.server.OrmException; import com.google.inject.Inject; import com.google.inject.Singleton; import java.io.IOException; @@ -60,8 +60,8 @@ public class PublishChangeEdit @Override protected Response applyImpl( BatchUpdate.Factory updateFactory, ChangeResource rsrc, PublishChangeEditInput in) - throws IOException, OrmException, RestApiException, UpdateException, ConfigInvalidException, - NoSuchProjectException { + throws IOException, StorageException, RestApiException, UpdateException, + ConfigInvalidException, NoSuchProjectException { contributorAgreementsChecker.check(rsrc.getProject(), rsrc.getUser()); Optional edit = editUtil.byChange(rsrc.getNotes(), rsrc.getUser()); if (!edit.isPresent()) { diff --git a/java/com/google/gerrit/server/restapi/change/PutAssignee.java b/java/com/google/gerrit/server/restapi/change/PutAssignee.java index a7dcc12e46..873716f3d5 100644 --- a/java/com/google/gerrit/server/restapi/change/PutAssignee.java +++ b/java/com/google/gerrit/server/restapi/change/PutAssignee.java @@ -15,6 +15,7 @@ package com.google.gerrit.server.restapi.change; import com.google.common.base.Strings; +import com.google.gerrit.exceptions.StorageException; import com.google.gerrit.extensions.api.changes.AddReviewerInput; import com.google.gerrit.extensions.api.changes.AssigneeInput; import com.google.gerrit.extensions.api.changes.NotifyHandling; @@ -39,7 +40,6 @@ import com.google.gerrit.server.update.RetryHelper; import com.google.gerrit.server.update.RetryingRestModifyView; import com.google.gerrit.server.update.UpdateException; import com.google.gerrit.server.util.time.TimeUtil; -import com.google.gwtorm.server.OrmException; import com.google.inject.Inject; import com.google.inject.Singleton; import java.io.IOException; @@ -74,7 +74,7 @@ public class PutAssignee extends RetryingRestModifyView applyImpl( BatchUpdate.Factory updateFactory, DraftCommentResource rsrc, DraftInput in) - throws RestApiException, UpdateException, OrmException, PermissionBackendException { + throws RestApiException, UpdateException, StorageException, PermissionBackendException { if (in == null || in.message == null || in.message.trim().isEmpty()) { return delete.applyImpl(updateFactory, rsrc, null); } else if (in.id != null && !rsrc.getId().equals(in.id)) { @@ -111,7 +111,7 @@ public class PutDraftComment @Override public boolean updateChange(ChangeContext ctx) - throws ResourceNotFoundException, OrmException, PatchListNotAvailableException { + throws ResourceNotFoundException, StorageException, PatchListNotAvailableException { Optional maybeComment = commentsUtil.getDraft(ctx.getNotes(), ctx.getIdentifiedUser(), key); if (!maybeComment.isPresent()) { diff --git a/java/com/google/gerrit/server/restapi/change/PutMessage.java b/java/com/google/gerrit/server/restapi/change/PutMessage.java index 39dfc7f7cb..1b4c5590f3 100644 --- a/java/com/google/gerrit/server/restapi/change/PutMessage.java +++ b/java/com/google/gerrit/server/restapi/change/PutMessage.java @@ -15,6 +15,7 @@ package com.google.gerrit.server.restapi.change; import com.google.gerrit.common.FooterConstants; +import com.google.gerrit.exceptions.StorageException; import com.google.gerrit.extensions.api.changes.NotifyHandling; import com.google.gerrit.extensions.common.CommitMessageInput; import com.google.gerrit.extensions.restapi.AuthException; @@ -43,7 +44,6 @@ import com.google.gerrit.server.update.RetryingRestModifyView; import com.google.gerrit.server.update.UpdateException; import com.google.gerrit.server.util.CommitMessageUtil; import com.google.gerrit.server.util.time.TimeUtil; -import com.google.gwtorm.server.OrmException; import com.google.inject.Inject; import com.google.inject.Provider; import com.google.inject.Singleton; @@ -100,7 +100,7 @@ public class PutMessage protected Response applyImpl( BatchUpdate.Factory updateFactory, ChangeResource resource, CommitMessageInput input) throws IOException, RestApiException, UpdateException, PermissionBackendException, - OrmException, ConfigInvalidException { + StorageException, ConfigInvalidException { PatchSet ps = psUtil.current(resource.getNotes()); if (ps == null) { throw new ResourceConflictException("current revision is missing"); @@ -149,7 +149,7 @@ public class PutMessage } private NotifyResolver.Result resolveNotify(CommitMessageInput input, ChangeResource resource) - throws BadRequestException, OrmException, ConfigInvalidException, IOException { + throws BadRequestException, StorageException, ConfigInvalidException, IOException { NotifyHandling notifyHandling = input.notify; if (notifyHandling == null) { notifyHandling = @@ -177,7 +177,7 @@ public class PutMessage private void ensureCanEditCommitMessage(ChangeNotes changeNotes) throws AuthException, PermissionBackendException, IOException, ResourceConflictException, - OrmException { + StorageException { if (!userProvider.get().isIdentifiedUser()) { throw new AuthException("Authentication required"); } diff --git a/java/com/google/gerrit/server/restapi/change/PutTopic.java b/java/com/google/gerrit/server/restapi/change/PutTopic.java index bc272e95ef..0624bccbaa 100644 --- a/java/com/google/gerrit/server/restapi/change/PutTopic.java +++ b/java/com/google/gerrit/server/restapi/change/PutTopic.java @@ -15,6 +15,7 @@ package com.google.gerrit.server.restapi.change; import com.google.common.base.Strings; +import com.google.gerrit.exceptions.StorageException; import com.google.gerrit.extensions.api.changes.TopicInput; import com.google.gerrit.extensions.restapi.BadRequestException; import com.google.gerrit.extensions.restapi.Response; @@ -37,7 +38,6 @@ import com.google.gerrit.server.update.RetryHelper; import com.google.gerrit.server.update.RetryingRestModifyView; import com.google.gerrit.server.update.UpdateException; import com.google.gerrit.server.util.time.TimeUtil; -import com.google.gwtorm.server.OrmException; import com.google.inject.Inject; import com.google.inject.Singleton; @@ -93,7 +93,7 @@ public class PutTopic extends RetryingRestModifyView, DynamicOpti @Override public List apply(TopLevelResource rsrc) - throws BadRequestException, AuthException, OrmException, PermissionBackendException { + throws BadRequestException, AuthException, StorageException, PermissionBackendException { List> out; try { out = query(); @@ -129,7 +129,7 @@ public class QueryChanges implements RestReadView, DynamicOpti } private List> query() - throws OrmException, QueryParseException, PermissionBackendException { + throws StorageException, QueryParseException, PermissionBackendException { if (imp.isDisabled()) { throw new QueryParseException("query disabled"); } diff --git a/java/com/google/gerrit/server/restapi/change/Rebase.java b/java/com/google/gerrit/server/restapi/change/Rebase.java index afb674b155..67675255d6 100644 --- a/java/com/google/gerrit/server/restapi/change/Rebase.java +++ b/java/com/google/gerrit/server/restapi/change/Rebase.java @@ -17,6 +17,7 @@ package com.google.gerrit.server.restapi.change; import com.google.common.collect.ImmutableSet; import com.google.common.collect.Sets; import com.google.common.flogger.FluentLogger; +import com.google.gerrit.exceptions.StorageException; import com.google.gerrit.extensions.api.changes.RebaseInput; import com.google.gerrit.extensions.client.ListChangesOption; import com.google.gerrit.extensions.common.ChangeInfo; @@ -48,7 +49,6 @@ import com.google.gerrit.server.update.RetryHelper; import com.google.gerrit.server.update.RetryingRestModifyView; import com.google.gerrit.server.update.UpdateException; import com.google.gerrit.server.util.time.TimeUtil; -import com.google.gwtorm.server.OrmException; import com.google.inject.Inject; import com.google.inject.Singleton; import java.io.IOException; @@ -99,7 +99,7 @@ public class Rebase extends RetryingRestModifyView applyImpl(BatchUpdate.Factory updateFactory, ChangeResource rsrc, Input in) - throws AuthException, ResourceConflictException, IOException, OrmException, + throws AuthException, ResourceConflictException, IOException, StorageException, PermissionBackendException { Project.NameKey project = rsrc.getProject(); try (Repository repository = repositoryManager.openRepository(project)) { diff --git a/java/com/google/gerrit/server/restapi/change/RelatedChangesSorter.java b/java/com/google/gerrit/server/restapi/change/RelatedChangesSorter.java index 8634e1d474..34bd7e3f68 100644 --- a/java/com/google/gerrit/server/restapi/change/RelatedChangesSorter.java +++ b/java/com/google/gerrit/server/restapi/change/RelatedChangesSorter.java @@ -24,6 +24,7 @@ import com.google.common.collect.ListMultimap; import com.google.common.collect.Lists; import com.google.common.collect.Maps; import com.google.common.collect.MultimapBuilder; +import com.google.gerrit.exceptions.StorageException; import com.google.gerrit.extensions.restapi.AuthException; import com.google.gerrit.reviewdb.client.Change; import com.google.gerrit.reviewdb.client.PatchSet; @@ -35,7 +36,6 @@ import com.google.gerrit.server.permissions.PermissionBackendException; import com.google.gerrit.server.project.ProjectCache; import com.google.gerrit.server.project.ProjectState; import com.google.gerrit.server.query.change.ChangeData; -import com.google.gwtorm.server.OrmException; import com.google.inject.Inject; import com.google.inject.Singleton; import java.io.IOException; @@ -72,7 +72,7 @@ class RelatedChangesSorter { } public List sort(List in, PatchSet startPs) - throws OrmException, IOException, PermissionBackendException { + throws StorageException, IOException, PermissionBackendException { checkArgument(!in.isEmpty(), "Input may not be empty"); // Map of all patch sets, keyed by commit SHA-1. Map byId = collectById(in); @@ -114,7 +114,7 @@ class RelatedChangesSorter { } private Map collectById(List in) - throws OrmException, IOException { + throws StorageException, IOException { Project.NameKey project = in.get(0).change().getProject(); Map result = Maps.newHashMapWithExpectedSize(in.size() * 3); try (Repository repo = repoManager.openRepository(project); diff --git a/java/com/google/gerrit/server/restapi/change/Restore.java b/java/com/google/gerrit/server/restapi/change/Restore.java index 40ef8676cd..acf35bcf76 100644 --- a/java/com/google/gerrit/server/restapi/change/Restore.java +++ b/java/com/google/gerrit/server/restapi/change/Restore.java @@ -16,6 +16,7 @@ package com.google.gerrit.server.restapi.change; import com.google.common.base.Strings; import com.google.common.flogger.FluentLogger; +import com.google.gerrit.exceptions.StorageException; import com.google.gerrit.extensions.api.changes.RestoreInput; import com.google.gerrit.extensions.common.ChangeInfo; import com.google.gerrit.extensions.restapi.ResourceConflictException; @@ -45,7 +46,6 @@ import com.google.gerrit.server.update.RetryHelper; import com.google.gerrit.server.update.RetryingRestModifyView; import com.google.gerrit.server.update.UpdateException; import com.google.gerrit.server.util.time.TimeUtil; -import com.google.gwtorm.server.OrmException; import com.google.inject.Inject; import com.google.inject.Singleton; import java.io.IOException; @@ -83,7 +83,7 @@ public class Restore extends RetryingRestModifyView apply(FileResource resource, Input input) throws OrmException { + public Response apply(FileResource resource, Input input) throws StorageException { boolean reviewFlagUpdated = accountPatchReviewStore.call( s -> @@ -44,7 +44,7 @@ public class Reviewed { resource.getPatchKey().getParentKey(), resource.getAccountId(), resource.getPatchKey().getFileName()), - OrmException.class); + StorageException.class); return reviewFlagUpdated ? Response.created("") : Response.ok(""); } } @@ -59,14 +59,14 @@ public class Reviewed { } @Override - public Response apply(FileResource resource, Input input) throws OrmException { + public Response apply(FileResource resource, Input input) throws StorageException { accountPatchReviewStore.run( s -> s.clearReviewed( resource.getPatchKey().getParentKey(), resource.getAccountId(), resource.getPatchKey().getFileName()), - OrmException.class); + StorageException.class); return Response.none(); } } diff --git a/java/com/google/gerrit/server/restapi/change/ReviewerRecommender.java b/java/com/google/gerrit/server/restapi/change/ReviewerRecommender.java index 1d4d4dd0a4..1c4dfc10e6 100644 --- a/java/com/google/gerrit/server/restapi/change/ReviewerRecommender.java +++ b/java/com/google/gerrit/server/restapi/change/ReviewerRecommender.java @@ -23,6 +23,7 @@ import com.google.common.collect.ImmutableMap; import com.google.common.flogger.FluentLogger; import com.google.gerrit.common.Nullable; import com.google.gerrit.common.data.LabelType; +import com.google.gerrit.exceptions.StorageException; import com.google.gerrit.index.query.Predicate; import com.google.gerrit.index.query.QueryParseException; import com.google.gerrit.reviewdb.client.Account; @@ -39,7 +40,6 @@ import com.google.gerrit.server.project.ProjectState; import com.google.gerrit.server.query.change.ChangeData; import com.google.gerrit.server.query.change.ChangeQueryBuilder; import com.google.gerrit.server.query.change.InternalChangeQuery; -import com.google.gwtorm.server.OrmException; import com.google.inject.Inject; import com.google.inject.Provider; import java.io.IOException; @@ -101,7 +101,7 @@ public class ReviewerRecommender { SuggestReviewers suggestReviewers, ProjectState projectState, List candidateList) - throws OrmException, IOException, ConfigInvalidException { + throws StorageException, IOException, ConfigInvalidException { logger.atFine().log("Candidates %s", candidateList); String query = suggestReviewers.getQuery(); @@ -198,7 +198,7 @@ public class ReviewerRecommender { } private Map baseRankingForEmptyQuery(double baseWeight) - throws OrmException, IOException, ConfigInvalidException { + throws StorageException, IOException, ConfigInvalidException { // Get the user's last 25 changes, check approvals try { List result = @@ -228,7 +228,7 @@ public class ReviewerRecommender { private Map baseRankingForCandidateList( List candidates, ProjectState projectState, double baseWeight) - throws OrmException, IOException, ConfigInvalidException { + throws StorageException, IOException, ConfigInvalidException { // Get each reviewer's activity based on number of applied labels // (weighted 10d), number of comments (weighted 0.5d) and number of owned // changes (weighted 1d). diff --git a/java/com/google/gerrit/server/restapi/change/Reviewers.java b/java/com/google/gerrit/server/restapi/change/Reviewers.java index cf69080273..7225a0e89c 100644 --- a/java/com/google/gerrit/server/restapi/change/Reviewers.java +++ b/java/com/google/gerrit/server/restapi/change/Reviewers.java @@ -14,6 +14,7 @@ package com.google.gerrit.server.restapi.change; +import com.google.gerrit.exceptions.StorageException; import com.google.gerrit.extensions.registration.DynamicMap; import com.google.gerrit.extensions.restapi.AuthException; import com.google.gerrit.extensions.restapi.ChildCollection; @@ -27,7 +28,6 @@ import com.google.gerrit.server.ApprovalsUtil; import com.google.gerrit.server.change.ChangeResource; import com.google.gerrit.server.change.ReviewerResource; import com.google.gerrit.server.restapi.account.AccountsCollection; -import com.google.gwtorm.server.OrmException; import com.google.inject.Inject; import com.google.inject.Singleton; import java.io.IOException; @@ -68,7 +68,7 @@ public class Reviewers implements ChildCollection fetchAccountIds(ChangeResource rsrc) throws OrmException { + private Collection fetchAccountIds(ChangeResource rsrc) throws StorageException { return approvalsUtil.getReviewers(rsrc.getNotes()).all(); } } diff --git a/java/com/google/gerrit/server/restapi/change/ReviewersUtil.java b/java/com/google/gerrit/server/restapi/change/ReviewersUtil.java index 343afc3bde..88ab5db7bc 100644 --- a/java/com/google/gerrit/server/restapi/change/ReviewersUtil.java +++ b/java/com/google/gerrit/server/restapi/change/ReviewersUtil.java @@ -26,6 +26,7 @@ import com.google.common.collect.Sets; import com.google.common.flogger.FluentLogger; import com.google.gerrit.common.Nullable; import com.google.gerrit.common.data.GroupReference; +import com.google.gerrit.exceptions.StorageException; import com.google.gerrit.extensions.common.GroupBaseInfo; import com.google.gerrit.extensions.common.SuggestedReviewerInfo; import com.google.gerrit.extensions.restapi.Url; @@ -57,7 +58,6 @@ import com.google.gerrit.server.project.NoSuchProjectException; import com.google.gerrit.server.project.ProjectState; import com.google.gerrit.server.query.account.AccountPredicates; import com.google.gerrit.server.query.account.AccountQueryBuilder; -import com.google.gwtorm.server.OrmException; import com.google.inject.Inject; import com.google.inject.Provider; import com.google.inject.Singleton; @@ -156,7 +156,7 @@ public class ReviewersUtil { } public interface VisibilityControl { - boolean isVisibleTo(Account.Id account) throws OrmException; + boolean isVisibleTo(Account.Id account) throws StorageException; } public List suggestReviewers( @@ -165,7 +165,7 @@ public class ReviewersUtil { ProjectState projectState, VisibilityControl visibilityControl, boolean excludeGroups) - throws IOException, OrmException, ConfigInvalidException, PermissionBackendException { + throws IOException, StorageException, ConfigInvalidException, PermissionBackendException { CurrentUser currentUser = self.get(); if (changeNotes != null) { logger.atFine().log( @@ -224,7 +224,8 @@ public class ReviewersUtil { return suggestedReviewers; } - private List suggestAccounts(SuggestReviewers suggestReviewers) throws OrmException { + private List suggestAccounts(SuggestReviewers suggestReviewers) + throws StorageException { try (Timer0.Context ctx = metrics.queryAccountsLatency.start()) { try { // For performance reasons we don't use AccountQueryProvider as it would always load the @@ -264,7 +265,7 @@ public class ReviewersUtil { VisibilityControl visibilityControl, boolean excludeGroups, List filteredRecommendations) - throws OrmException, PermissionBackendException, IOException { + throws StorageException, PermissionBackendException, IOException { List suggestedReviewers = loadAccounts(filteredRecommendations); int limit = suggestReviewers.getLimit(); @@ -293,7 +294,7 @@ public class ReviewersUtil { SuggestReviewers suggestReviewers, ProjectState projectState, List candidateList) - throws OrmException, IOException, ConfigInvalidException { + throws StorageException, IOException, ConfigInvalidException { try (Timer0.Context ctx = metrics.recommendAccountsLatency.start()) { return reviewerRecommender.suggestReviewers( changeNotes, suggestReviewers, projectState, candidateList); @@ -329,7 +330,7 @@ public class ReviewersUtil { ProjectState projectState, VisibilityControl visibilityControl, int limit) - throws OrmException, IOException { + throws StorageException, IOException { try (Timer0.Context ctx = metrics.queryGroupsLatency.start()) { List groups = new ArrayList<>(); for (GroupReference g : suggestAccountGroups(suggestReviewers, projectState)) { @@ -375,7 +376,7 @@ public class ReviewersUtil { Project project, GroupReference group, VisibilityControl visibilityControl) - throws OrmException, IOException { + throws StorageException, IOException { GroupAsReviewer result = new GroupAsReviewer(); int maxAllowed = suggestReviewers.getMaxAllowed(); int maxAllowedWithoutConfirmation = suggestReviewers.getMaxAllowedWithoutConfirmation(); diff --git a/java/com/google/gerrit/server/restapi/change/RevisionReviewers.java b/java/com/google/gerrit/server/restapi/change/RevisionReviewers.java index 60c9a54e43..3e071cb510 100644 --- a/java/com/google/gerrit/server/restapi/change/RevisionReviewers.java +++ b/java/com/google/gerrit/server/restapi/change/RevisionReviewers.java @@ -14,6 +14,7 @@ package com.google.gerrit.server.restapi.change; +import com.google.gerrit.exceptions.StorageException; import com.google.gerrit.extensions.registration.DynamicMap; import com.google.gerrit.extensions.restapi.AuthException; import com.google.gerrit.extensions.restapi.ChildCollection; @@ -28,7 +29,6 @@ import com.google.gerrit.server.ApprovalsUtil; import com.google.gerrit.server.change.ReviewerResource; import com.google.gerrit.server.change.RevisionResource; import com.google.gerrit.server.restapi.account.AccountsCollection; -import com.google.gwtorm.server.OrmException; import com.google.inject.Inject; import com.google.inject.Singleton; import java.io.IOException; @@ -69,7 +69,7 @@ public class RevisionReviewers implements ChildCollection find(ChangeResource change, String id) - throws OrmException, IOException, AuthException { + throws StorageException, IOException, AuthException { if (id.equals("0") || id.equals("edit")) { return loadEdit(change, null); } else if (id.length() < 6 && id.matches("^[1-9][0-9]{0,4}$")) { @@ -143,7 +143,7 @@ public class Revisions implements ChildCollection byLegacyPatchSetId(ChangeResource change, String id) - throws OrmException { + throws StorageException { PatchSet ps = psUtil.get(change.getNotes(), new PatchSet.Id(change.getId(), Integer.parseInt(id))); if (ps != null) { diff --git a/java/com/google/gerrit/server/restapi/change/RobotComments.java b/java/com/google/gerrit/server/restapi/change/RobotComments.java index 6570ae0d97..26e02232d8 100644 --- a/java/com/google/gerrit/server/restapi/change/RobotComments.java +++ b/java/com/google/gerrit/server/restapi/change/RobotComments.java @@ -14,6 +14,7 @@ package com.google.gerrit.server.restapi.change; +import com.google.gerrit.exceptions.StorageException; import com.google.gerrit.extensions.registration.DynamicMap; import com.google.gerrit.extensions.restapi.ChildCollection; import com.google.gerrit.extensions.restapi.IdString; @@ -24,7 +25,6 @@ import com.google.gerrit.server.CommentsUtil; import com.google.gerrit.server.change.RevisionResource; import com.google.gerrit.server.change.RobotCommentResource; import com.google.gerrit.server.notedb.ChangeNotes; -import com.google.gwtorm.server.OrmException; import com.google.inject.Inject; import com.google.inject.Singleton; @@ -56,7 +56,7 @@ public class RobotComments implements ChildCollection c.getId().toString()).collect(joining(", ")); } - } catch (PermissionBackendException | OrmException | IOException e) { + } catch (PermissionBackendException | StorageException | IOException e) { logger.atSevere().withCause(e).log("Error checking if change is submittable"); - throw new OrmRuntimeException("Could not determine problems for the change", e); + throw new StorageRuntimeException("Could not determine problems for the change", e); } return null; } @@ -313,7 +313,7 @@ public class Submit } } catch (IOException e) { logger.atSevere().withCause(e).log("Error checking if change is submittable"); - throw new OrmRuntimeException("Could not determine problems for the change", e); + throw new StorageRuntimeException("Could not determine problems for the change", e); } ChangeData cd = changeDataFactory.create(resource.getNotes()); @@ -321,16 +321,16 @@ public class Submit MergeOp.checkSubmitRule(cd, false); } catch (ResourceConflictException e) { return null; // submit not visible - } catch (OrmException e) { + } catch (StorageException e) { logger.atSevere().withCause(e).log("Error checking if change is submittable"); - throw new OrmRuntimeException("Could not determine problems for the change", e); + throw new StorageRuntimeException("Could not determine problems for the change", e); } ChangeSet cs; try { cs = mergeSuperSet.get().completeChangeSet(cd.change(), resource.getUser()); - } catch (OrmException | IOException | PermissionBackendException e) { - throw new OrmRuntimeException( + } catch (StorageException | IOException | PermissionBackendException e) { + throw new StorageRuntimeException( "Could not determine complete set of changes to be submitted", e); } @@ -354,8 +354,8 @@ public class Submit // problemsForSubmittingChangeset, so now it is safe to read from // the cache, as it yields the same result. enabled = cd.isMergeable(); - } catch (OrmException e) { - throw new OrmRuntimeException("Could not determine mergeability", e); + } catch (StorageException e) { + throw new StorageRuntimeException("Could not determine mergeability", e); } if (submitProblems != null) { @@ -392,7 +392,8 @@ public class Submit .setEnabled(Boolean.TRUE.equals(enabled)); } - public Collection unmergeableChanges(ChangeSet cs) throws OrmException, IOException { + public Collection unmergeableChanges(ChangeSet cs) + throws StorageException, IOException { Set mergeabilityMap = new HashSet<>(); for (ChangeData change : cs.changes()) { mergeabilityMap.add(change); @@ -441,7 +442,8 @@ public class Submit } private HashMap findCommits( - Collection changes, Project.NameKey project) throws IOException, OrmException { + Collection changes, Project.NameKey project) + throws IOException, StorageException { HashMap commits = new HashMap<>(); try (Repository repo = repoManager.openRepository(project); RevWalk walk = new RevWalk(repo)) { @@ -456,8 +458,8 @@ public class Submit } private IdentifiedUser onBehalfOf(RevisionResource rsrc, SubmitInput in) - throws AuthException, UnprocessableEntityException, OrmException, PermissionBackendException, - IOException, ConfigInvalidException { + throws AuthException, UnprocessableEntityException, StorageException, + PermissionBackendException, IOException, ConfigInvalidException { PermissionBackend.ForChange perm = rsrc.permissions(); perm.check(ChangePermission.SUBMIT); perm.check(ChangePermission.SUBMIT_AS); @@ -477,8 +479,8 @@ public class Submit private List getChangesByTopic(String topic) { try { return queryProvider.get().byTopicOpen(topic); - } catch (OrmException e) { - throw new OrmRuntimeException(e); + } catch (StorageException e) { + throw new StorageRuntimeException(e); } } @@ -496,7 +498,7 @@ public class Submit @Override public ChangeInfo apply(ChangeResource rsrc, SubmitInput input) - throws RestApiException, RepositoryNotFoundException, IOException, OrmException, + throws RestApiException, RepositoryNotFoundException, IOException, StorageException, PermissionBackendException, UpdateException, ConfigInvalidException { PatchSet ps = psUtil.current(rsrc.getNotes()); if (ps == null) { diff --git a/java/com/google/gerrit/server/restapi/change/SubmittedTogether.java b/java/com/google/gerrit/server/restapi/change/SubmittedTogether.java index 39413b6339..9b23e550c6 100644 --- a/java/com/google/gerrit/server/restapi/change/SubmittedTogether.java +++ b/java/com/google/gerrit/server/restapi/change/SubmittedTogether.java @@ -19,6 +19,7 @@ import static java.util.Collections.reverseOrder; import static java.util.stream.Collectors.toList; import com.google.common.flogger.FluentLogger; +import com.google.gerrit.exceptions.StorageException; import com.google.gerrit.extensions.api.changes.SubmittedTogetherInfo; import com.google.gerrit.extensions.api.changes.SubmittedTogetherOption; import com.google.gerrit.extensions.client.ListChangesOption; @@ -36,7 +37,6 @@ import com.google.gerrit.server.query.change.ChangeData; import com.google.gerrit.server.query.change.InternalChangeQuery; import com.google.gerrit.server.submit.ChangeSet; import com.google.gerrit.server.submit.MergeSuperSet; -import com.google.gwtorm.server.OrmException; import com.google.inject.Inject; import com.google.inject.Provider; import java.io.IOException; @@ -108,7 +108,7 @@ public class SubmittedTogether implements RestReadView { @Override public Object apply(ChangeResource resource) throws AuthException, BadRequestException, ResourceConflictException, IOException, - OrmException, PermissionBackendException { + StorageException, PermissionBackendException { SubmittedTogetherInfo info = applyInfo(resource); if (options.isEmpty()) { return info.changes; @@ -117,7 +117,7 @@ public class SubmittedTogether implements RestReadView { } public SubmittedTogetherInfo applyInfo(ChangeResource resource) - throws AuthException, IOException, OrmException, PermissionBackendException { + throws AuthException, IOException, StorageException, PermissionBackendException { Change c = resource.getChange(); try { List cds; @@ -144,13 +144,14 @@ public class SubmittedTogether implements RestReadView { info.changes = json.create(jsonOpt).format(cds); info.nonVisibleChanges = hidden; return info; - } catch (OrmException | IOException e) { + } catch (StorageException | IOException e) { logger.atSevere().withCause(e).log("Error on getting a ChangeSet"); throw e; } } - private List sort(List cds, int hidden) throws OrmException, IOException { + private List sort(List cds, int hidden) + throws StorageException, IOException { if (cds.size() <= 1 && hidden == 0) { // Skip sorting for singleton lists, to avoid WalkSorter opening the // repo just to fill out the commit field in PatchSetData. @@ -176,7 +177,7 @@ public class SubmittedTogether implements RestReadView { } private static List ensureRequiredDataIsLoaded(List cds) - throws OrmException { + throws StorageException { // TODO(hiesel): Instead of calling these manually, either implement a helper that brings a // database-backed change on-par with an index-backed change in terms of the populated fields in // ChangeData or check if any of the ChangeDatas was loaded from the database and allow diff --git a/java/com/google/gerrit/server/restapi/change/SuggestChangeReviewers.java b/java/com/google/gerrit/server/restapi/change/SuggestChangeReviewers.java index 708d91450d..bb416c575e 100644 --- a/java/com/google/gerrit/server/restapi/change/SuggestChangeReviewers.java +++ b/java/com/google/gerrit/server/restapi/change/SuggestChangeReviewers.java @@ -14,6 +14,7 @@ package com.google.gerrit.server.restapi.change; +import com.google.gerrit.exceptions.StorageException; import com.google.gerrit.extensions.common.AccountVisibility; import com.google.gerrit.extensions.common.SuggestedReviewerInfo; import com.google.gerrit.extensions.restapi.AuthException; @@ -27,7 +28,6 @@ import com.google.gerrit.server.permissions.PermissionBackendException; import com.google.gerrit.server.permissions.RefPermission; import com.google.gerrit.server.project.ProjectCache; import com.google.gerrit.server.restapi.change.ReviewersUtil.VisibilityControl; -import com.google.gwtorm.server.OrmException; import com.google.inject.Inject; import com.google.inject.Provider; import java.io.IOException; @@ -65,8 +65,8 @@ public class SuggestChangeReviewers extends SuggestReviewers @Override public List apply(ChangeResource rsrc) - throws AuthException, BadRequestException, OrmException, IOException, ConfigInvalidException, - PermissionBackendException { + throws AuthException, BadRequestException, StorageException, IOException, + ConfigInvalidException, PermissionBackendException { if (!self.get().isIdentifiedUser()) { throw new AuthException("Authentication required"); } diff --git a/java/com/google/gerrit/server/restapi/change/TestSubmitRule.java b/java/com/google/gerrit/server/restapi/change/TestSubmitRule.java index 7cba8e7762..f3b88819d6 100644 --- a/java/com/google/gerrit/server/restapi/change/TestSubmitRule.java +++ b/java/com/google/gerrit/server/restapi/change/TestSubmitRule.java @@ -18,6 +18,7 @@ import com.google.common.base.MoreObjects; import com.google.common.collect.ImmutableList; import com.google.common.collect.Lists; import com.google.gerrit.common.data.SubmitRecord; +import com.google.gerrit.exceptions.StorageException; import com.google.gerrit.extensions.common.AccountInfo; import com.google.gerrit.extensions.common.TestSubmitRuleInfo; import com.google.gerrit.extensions.common.TestSubmitRuleInput; @@ -35,7 +36,6 @@ import com.google.gerrit.server.query.change.ChangeData; import com.google.gerrit.server.rules.DefaultSubmitRule; import com.google.gerrit.server.rules.PrologRule; import com.google.gerrit.server.rules.RulesCache; -import com.google.gwtorm.server.OrmException; import com.google.inject.Inject; import java.util.LinkedHashMap; import java.util.List; @@ -70,7 +70,7 @@ public class TestSubmitRule implements RestModifyView apply(RevisionResource rsrc, TestSubmitRuleInput input) - throws AuthException, OrmException, PermissionBackendException, BadRequestException { + throws AuthException, StorageException, PermissionBackendException, BadRequestException { if (input == null) { input = new TestSubmitRuleInput(); } diff --git a/java/com/google/gerrit/server/restapi/change/TestSubmitType.java b/java/com/google/gerrit/server/restapi/change/TestSubmitType.java index 684d22f380..91daee8459 100644 --- a/java/com/google/gerrit/server/restapi/change/TestSubmitType.java +++ b/java/com/google/gerrit/server/restapi/change/TestSubmitType.java @@ -16,6 +16,7 @@ package com.google.gerrit.server.restapi.change; import com.google.common.base.MoreObjects; import com.google.gerrit.common.data.SubmitTypeRecord; +import com.google.gerrit.exceptions.StorageException; import com.google.gerrit.extensions.client.SubmitType; import com.google.gerrit.extensions.common.TestSubmitRuleInput; import com.google.gerrit.extensions.common.TestSubmitRuleInput.Filters; @@ -28,7 +29,6 @@ import com.google.gerrit.server.project.SubmitRuleEvaluator; import com.google.gerrit.server.project.SubmitRuleOptions; import com.google.gerrit.server.query.change.ChangeData; import com.google.gerrit.server.rules.RulesCache; -import com.google.gwtorm.server.OrmException; import com.google.inject.Inject; import org.kohsuke.args4j.Option; @@ -52,7 +52,7 @@ public class TestSubmitType implements RestModifyView, UiAction @Override public Response apply(ChangeResource rsrc, Input input) - throws OrmException, IllegalLabelException { + throws StorageException, IllegalLabelException { if (isIgnored(rsrc)) { stars.unignore(rsrc); } @@ -57,7 +57,7 @@ public class Unignore implements RestModifyView, UiAction private boolean isIgnored(ChangeResource rsrc) { try { return stars.isIgnored(rsrc); - } catch (OrmException e) { + } catch (StorageException e) { logger.atSevere().withCause(e).log("failed to check ignored star"); } return false; diff --git a/java/com/google/gerrit/server/restapi/change/Votes.java b/java/com/google/gerrit/server/restapi/change/Votes.java index a5d77e9084..5cfb5a6f51 100644 --- a/java/com/google/gerrit/server/restapi/change/Votes.java +++ b/java/com/google/gerrit/server/restapi/change/Votes.java @@ -14,6 +14,7 @@ package com.google.gerrit.server.restapi.change; +import com.google.gerrit.exceptions.StorageException; import com.google.gerrit.extensions.registration.DynamicMap; import com.google.gerrit.extensions.restapi.AuthException; import com.google.gerrit.extensions.restapi.ChildCollection; @@ -26,7 +27,6 @@ import com.google.gerrit.reviewdb.client.PatchSetApproval; import com.google.gerrit.server.ApprovalsUtil; import com.google.gerrit.server.change.ReviewerResource; import com.google.gerrit.server.change.VoteResource; -import com.google.gwtorm.server.OrmException; import com.google.inject.Inject; import com.google.inject.Singleton; import java.util.Map; @@ -55,7 +55,7 @@ public class Votes implements ChildCollection { @Override public VoteResource parse(ReviewerResource reviewer, IdString id) - throws ResourceNotFoundException, OrmException, AuthException, MethodNotAllowedException { + throws ResourceNotFoundException, StorageException, AuthException, MethodNotAllowedException { if (reviewer.getRevisionResource() != null && !reviewer.getRevisionResource().isCurrent()) { throw new MethodNotAllowedException("Cannot access on non-current patch set"); } @@ -73,7 +73,7 @@ public class Votes implements ChildCollection { @Override public Map apply(ReviewerResource rsrc) - throws OrmException, MethodNotAllowedException { + throws StorageException, MethodNotAllowedException { if (rsrc.getRevisionResource() != null && !rsrc.getRevisionResource().isCurrent()) { throw new MethodNotAllowedException("Cannot list votes on non-current patch set"); } diff --git a/java/com/google/gerrit/server/restapi/config/AgreementJson.java b/java/com/google/gerrit/server/restapi/config/AgreementJson.java index 05cf7e5139..d5c085b98a 100644 --- a/java/com/google/gerrit/server/restapi/config/AgreementJson.java +++ b/java/com/google/gerrit/server/restapi/config/AgreementJson.java @@ -18,6 +18,7 @@ import com.google.common.flogger.FluentLogger; import com.google.gerrit.common.data.ContributorAgreement; import com.google.gerrit.common.data.GroupReference; import com.google.gerrit.exceptions.NoSuchGroupException; +import com.google.gerrit.exceptions.StorageException; import com.google.gerrit.extensions.common.AgreementInfo; import com.google.gerrit.server.CurrentUser; import com.google.gerrit.server.IdentifiedUser; @@ -25,7 +26,6 @@ import com.google.gerrit.server.account.GroupControl; import com.google.gerrit.server.group.GroupResource; import com.google.gerrit.server.permissions.PermissionBackendException; import com.google.gerrit.server.restapi.group.GroupJson; -import com.google.gwtorm.server.OrmException; import com.google.inject.Inject; import com.google.inject.Provider; @@ -61,7 +61,7 @@ public class AgreementJson { GroupControl gc = genericGroupControlFactory.controlFor(user, autoVerifyGroup.getUUID()); GroupResource group = new GroupResource(gc); info.autoVerifyGroup = groupJson.format(group); - } catch (NoSuchGroupException | OrmException e) { + } catch (NoSuchGroupException | StorageException e) { logger.atWarning().log( "autoverify group \"%s\" does not exist, referenced in CLA \"%s\"", autoVerifyGroup.getName(), ca.getName()); diff --git a/java/com/google/gerrit/server/restapi/config/CheckConsistency.java b/java/com/google/gerrit/server/restapi/config/CheckConsistency.java index a16736bc16..7d50142669 100644 --- a/java/com/google/gerrit/server/restapi/config/CheckConsistency.java +++ b/java/com/google/gerrit/server/restapi/config/CheckConsistency.java @@ -14,6 +14,7 @@ package com.google.gerrit.server.restapi.config; +import com.google.gerrit.exceptions.StorageException; import com.google.gerrit.extensions.api.config.ConsistencyCheckInfo; import com.google.gerrit.extensions.api.config.ConsistencyCheckInfo.CheckAccountExternalIdsResultInfo; import com.google.gerrit.extensions.api.config.ConsistencyCheckInfo.CheckAccountsResultInfo; @@ -29,7 +30,6 @@ import com.google.gerrit.server.group.db.GroupsConsistencyChecker; import com.google.gerrit.server.permissions.GlobalPermission; import com.google.gerrit.server.permissions.PermissionBackend; import com.google.gerrit.server.permissions.PermissionBackendException; -import com.google.gwtorm.server.OrmException; import com.google.inject.Inject; import com.google.inject.Singleton; import java.io.IOException; @@ -56,7 +56,7 @@ public class CheckConsistency implements RestModifyView { @Override public Response apply(ConfigResource rsrc, Input input) - throws AuthException, UnprocessableEntityException, OrmException, IOException, + throws AuthException, UnprocessableEntityException, StorageException, IOException, ConfigInvalidException { CurrentUser user = self.get(); if (!user.isIdentifiedUser()) { diff --git a/java/com/google/gerrit/server/restapi/group/AddMembers.java b/java/com/google/gerrit/server/restapi/group/AddMembers.java index 423145a1b4..197317c344 100644 --- a/java/com/google/gerrit/server/restapi/group/AddMembers.java +++ b/java/com/google/gerrit/server/restapi/group/AddMembers.java @@ -19,6 +19,7 @@ import com.google.common.collect.Lists; import com.google.common.collect.Sets; import com.google.gerrit.common.data.GroupDescription; import com.google.gerrit.exceptions.NoSuchGroupException; +import com.google.gerrit.exceptions.StorageException; import com.google.gerrit.extensions.client.AuthType; import com.google.gerrit.extensions.common.AccountInfo; import com.google.gerrit.extensions.restapi.AuthException; @@ -49,7 +50,6 @@ import com.google.gerrit.server.group.db.GroupsUpdate; import com.google.gerrit.server.group.db.InternalGroupUpdate; import com.google.gerrit.server.permissions.PermissionBackendException; import com.google.gerrit.server.restapi.group.AddMembers.Input; -import com.google.gwtorm.server.OrmException; import com.google.inject.Inject; import com.google.inject.Provider; import com.google.inject.Singleton; @@ -113,8 +113,8 @@ public class AddMembers implements RestModifyView { @Override public List apply(GroupResource resource, Input input) - throws AuthException, NotInternalGroupException, UnprocessableEntityException, OrmException, - IOException, ConfigInvalidException, ResourceNotFoundException, + throws AuthException, NotInternalGroupException, UnprocessableEntityException, + StorageException, IOException, ConfigInvalidException, ResourceNotFoundException, PermissionBackendException { GroupDescription.Internal internalGroup = resource.asInternalGroup().orElseThrow(NotInternalGroupException::new); @@ -145,7 +145,7 @@ public class AddMembers implements RestModifyView { } Account findAccount(String nameOrEmailOrId) - throws UnprocessableEntityException, OrmException, IOException, ConfigInvalidException { + throws UnprocessableEntityException, StorageException, IOException, ConfigInvalidException { AccountResolver.Result result = accountResolver.resolve(nameOrEmailOrId); try { return result.asUnique().getAccount(); @@ -177,7 +177,7 @@ public class AddMembers implements RestModifyView { } public void addMembers(AccountGroup.UUID groupUuid, Set newMemberIds) - throws OrmException, IOException, NoSuchGroupException, ConfigInvalidException { + throws StorageException, IOException, NoSuchGroupException, ConfigInvalidException { InternalGroupUpdate groupUpdate = InternalGroupUpdate.builder() .setMemberModification(memberIds -> Sets.union(memberIds, newMemberIds)) @@ -224,8 +224,8 @@ public class AddMembers implements RestModifyView { @Override public AccountInfo apply(GroupResource resource, IdString id, Input input) - throws AuthException, MethodNotAllowedException, ResourceNotFoundException, OrmException, - IOException, ConfigInvalidException, PermissionBackendException { + throws AuthException, MethodNotAllowedException, ResourceNotFoundException, + StorageException, IOException, ConfigInvalidException, PermissionBackendException { AddMembers.Input in = new AddMembers.Input(); in._oneMember = id.get(); try { @@ -251,7 +251,7 @@ public class AddMembers implements RestModifyView { @Override public AccountInfo apply(MemberResource resource, Input input) - throws OrmException, PermissionBackendException { + throws StorageException, PermissionBackendException { // Do nothing, the user is already a member. return get.apply(resource); } diff --git a/java/com/google/gerrit/server/restapi/group/AddSubgroups.java b/java/com/google/gerrit/server/restapi/group/AddSubgroups.java index 5942db80cc..184effe6ad 100644 --- a/java/com/google/gerrit/server/restapi/group/AddSubgroups.java +++ b/java/com/google/gerrit/server/restapi/group/AddSubgroups.java @@ -20,6 +20,7 @@ import com.google.common.collect.Lists; import com.google.common.collect.Sets; import com.google.gerrit.common.data.GroupDescription; import com.google.gerrit.exceptions.NoSuchGroupException; +import com.google.gerrit.exceptions.StorageException; import com.google.gerrit.extensions.common.GroupInfo; import com.google.gerrit.extensions.restapi.AuthException; import com.google.gerrit.extensions.restapi.DefaultInput; @@ -39,7 +40,6 @@ import com.google.gerrit.server.group.db.GroupsUpdate; import com.google.gerrit.server.group.db.InternalGroupUpdate; import com.google.gerrit.server.permissions.PermissionBackendException; import com.google.gerrit.server.restapi.group.AddSubgroups.Input; -import com.google.gwtorm.server.OrmException; import com.google.inject.Inject; import com.google.inject.Provider; import com.google.inject.Singleton; @@ -93,8 +93,8 @@ public class AddSubgroups implements RestModifyView { @Override public List apply(GroupResource resource, Input input) - throws NotInternalGroupException, AuthException, UnprocessableEntityException, OrmException, - ResourceNotFoundException, IOException, ConfigInvalidException, + throws NotInternalGroupException, AuthException, UnprocessableEntityException, + StorageException, ResourceNotFoundException, IOException, ConfigInvalidException, PermissionBackendException { GroupDescription.Internal group = resource.asInternalGroup().orElseThrow(NotInternalGroupException::new); @@ -124,7 +124,7 @@ public class AddSubgroups implements RestModifyView { private void addSubgroups( AccountGroup.UUID parentGroupUuid, Set newSubgroupUuids) - throws OrmException, NoSuchGroupException, IOException, ConfigInvalidException { + throws StorageException, NoSuchGroupException, IOException, ConfigInvalidException { InternalGroupUpdate groupUpdate = InternalGroupUpdate.builder() .setSubgroupModification(subgroupUuids -> Sets.union(subgroupUuids, newSubgroupUuids)) @@ -144,8 +144,8 @@ public class AddSubgroups implements RestModifyView { @Override public GroupInfo apply(GroupResource resource, IdString id, Input input) - throws AuthException, MethodNotAllowedException, ResourceNotFoundException, OrmException, - IOException, ConfigInvalidException, PermissionBackendException { + throws AuthException, MethodNotAllowedException, ResourceNotFoundException, + StorageException, IOException, ConfigInvalidException, PermissionBackendException { AddSubgroups.Input in = new AddSubgroups.Input(); in.groups = ImmutableList.of(id.get()); try { @@ -171,7 +171,7 @@ public class AddSubgroups implements RestModifyView { @Override public GroupInfo apply(SubgroupResource resource, Input input) - throws OrmException, PermissionBackendException { + throws StorageException, PermissionBackendException { // Do nothing, the group is already included. return get.get().apply(resource); } diff --git a/java/com/google/gerrit/server/restapi/group/CreateGroup.java b/java/com/google/gerrit/server/restapi/group/CreateGroup.java index e6bd791d66..a4b772a980 100644 --- a/java/com/google/gerrit/server/restapi/group/CreateGroup.java +++ b/java/com/google/gerrit/server/restapi/group/CreateGroup.java @@ -19,6 +19,8 @@ import com.google.common.base.Strings; import com.google.common.collect.ImmutableSet; import com.google.gerrit.common.data.GlobalCapability; import com.google.gerrit.common.data.GroupDescription; +import com.google.gerrit.exceptions.DuplicateKeyException; +import com.google.gerrit.exceptions.StorageException; import com.google.gerrit.extensions.annotations.RequiresCapability; import com.google.gerrit.extensions.api.groups.GroupInput; import com.google.gerrit.extensions.client.ListGroupsOption; @@ -54,8 +56,6 @@ import com.google.gerrit.server.permissions.PermissionBackendException; import com.google.gerrit.server.plugincontext.PluginSetContext; import com.google.gerrit.server.validators.GroupCreationValidationListener; import com.google.gerrit.server.validators.ValidationException; -import com.google.gwtorm.server.OrmDuplicateKeyException; -import com.google.gwtorm.server.OrmException; import com.google.inject.Inject; import com.google.inject.Provider; import com.google.inject.Singleton; @@ -125,7 +125,7 @@ public class CreateGroup @Override public GroupInfo apply(TopLevelResource resource, IdString id, GroupInput input) throws AuthException, BadRequestException, UnprocessableEntityException, - ResourceConflictException, OrmException, IOException, ConfigInvalidException, + ResourceConflictException, StorageException, IOException, ConfigInvalidException, ResourceNotFoundException, PermissionBackendException { String name = id.get(); if (input == null) { @@ -178,7 +178,7 @@ public class CreateGroup } private InternalGroup createGroup(CreateGroupArgs createGroupArgs) - throws OrmException, ResourceConflictException, IOException, ConfigInvalidException { + throws StorageException, ResourceConflictException, IOException, ConfigInvalidException { String nameLower = createGroupArgs.getGroupName().toLowerCase(Locale.US); @@ -218,7 +218,7 @@ public class CreateGroup members -> ImmutableSet.copyOf(createGroupArgs.initialMembers)); try { return groupsUpdateProvider.get().createGroup(groupCreation, groupUpdateBuilder.build()); - } catch (OrmDuplicateKeyException e) { + } catch (DuplicateKeyException e) { throw new ResourceConflictException( "group '" + createGroupArgs.getGroupName() + "' already exists"); } diff --git a/java/com/google/gerrit/server/restapi/group/DeleteMembers.java b/java/com/google/gerrit/server/restapi/group/DeleteMembers.java index b552524083..27827a2345 100644 --- a/java/com/google/gerrit/server/restapi/group/DeleteMembers.java +++ b/java/com/google/gerrit/server/restapi/group/DeleteMembers.java @@ -17,6 +17,7 @@ package com.google.gerrit.server.restapi.group; import com.google.common.collect.Sets; import com.google.gerrit.common.data.GroupDescription; import com.google.gerrit.exceptions.NoSuchGroupException; +import com.google.gerrit.exceptions.StorageException; import com.google.gerrit.extensions.restapi.AuthException; import com.google.gerrit.extensions.restapi.MethodNotAllowedException; import com.google.gerrit.extensions.restapi.ResourceNotFoundException; @@ -33,7 +34,6 @@ import com.google.gerrit.server.group.MemberResource; import com.google.gerrit.server.group.db.GroupsUpdate; import com.google.gerrit.server.group.db.InternalGroupUpdate; import com.google.gerrit.server.restapi.group.AddMembers.Input; -import com.google.gwtorm.server.OrmException; import com.google.inject.Inject; import com.google.inject.Provider; import com.google.inject.Singleton; @@ -56,8 +56,8 @@ public class DeleteMembers implements RestModifyView { @Override public Response apply(GroupResource resource, Input input) - throws AuthException, NotInternalGroupException, UnprocessableEntityException, OrmException, - IOException, ConfigInvalidException, ResourceNotFoundException { + throws AuthException, NotInternalGroupException, UnprocessableEntityException, + StorageException, IOException, ConfigInvalidException, ResourceNotFoundException { GroupDescription.Internal internalGroup = resource.asInternalGroup().orElseThrow(NotInternalGroupException::new); input = Input.init(input); @@ -82,7 +82,7 @@ public class DeleteMembers implements RestModifyView { } private void removeGroupMembers(AccountGroup.UUID groupUuid, Set accountIds) - throws OrmException, IOException, NoSuchGroupException, ConfigInvalidException { + throws StorageException, IOException, NoSuchGroupException, ConfigInvalidException { InternalGroupUpdate groupUpdate = InternalGroupUpdate.builder() .setMemberModification(memberIds -> Sets.difference(memberIds, accountIds)) @@ -102,8 +102,8 @@ public class DeleteMembers implements RestModifyView { @Override public Response apply(MemberResource resource, Input input) - throws AuthException, MethodNotAllowedException, UnprocessableEntityException, OrmException, - IOException, ConfigInvalidException, ResourceNotFoundException { + throws AuthException, MethodNotAllowedException, UnprocessableEntityException, + StorageException, IOException, ConfigInvalidException, ResourceNotFoundException { AddMembers.Input in = new AddMembers.Input(); in._oneMember = resource.getMember().getAccountId().toString(); return delete.get().apply(resource, in); diff --git a/java/com/google/gerrit/server/restapi/group/DeleteSubgroups.java b/java/com/google/gerrit/server/restapi/group/DeleteSubgroups.java index 687e4ea0b8..de0916962f 100644 --- a/java/com/google/gerrit/server/restapi/group/DeleteSubgroups.java +++ b/java/com/google/gerrit/server/restapi/group/DeleteSubgroups.java @@ -18,6 +18,7 @@ import com.google.common.collect.ImmutableList; import com.google.common.collect.Sets; import com.google.gerrit.common.data.GroupDescription; import com.google.gerrit.exceptions.NoSuchGroupException; +import com.google.gerrit.exceptions.StorageException; import com.google.gerrit.extensions.restapi.AuthException; import com.google.gerrit.extensions.restapi.MethodNotAllowedException; import com.google.gerrit.extensions.restapi.ResourceNotFoundException; @@ -33,7 +34,6 @@ import com.google.gerrit.server.group.SubgroupResource; import com.google.gerrit.server.group.db.GroupsUpdate; import com.google.gerrit.server.group.db.InternalGroupUpdate; import com.google.gerrit.server.restapi.group.AddSubgroups.Input; -import com.google.gwtorm.server.OrmException; import com.google.inject.Inject; import com.google.inject.Provider; import com.google.inject.Singleton; @@ -56,8 +56,8 @@ public class DeleteSubgroups implements RestModifyView { @Override public Response apply(GroupResource resource, Input input) - throws AuthException, NotInternalGroupException, UnprocessableEntityException, OrmException, - ResourceNotFoundException, IOException, ConfigInvalidException { + throws AuthException, NotInternalGroupException, UnprocessableEntityException, + StorageException, ResourceNotFoundException, IOException, ConfigInvalidException { GroupDescription.Internal internalGroup = resource.asInternalGroup().orElseThrow(NotInternalGroupException::new); input = Input.init(input); @@ -86,7 +86,7 @@ public class DeleteSubgroups implements RestModifyView { private void removeSubgroups( AccountGroup.UUID parentGroupUuid, Set removedSubgroupUuids) - throws OrmException, NoSuchGroupException, IOException, ConfigInvalidException { + throws StorageException, NoSuchGroupException, IOException, ConfigInvalidException { InternalGroupUpdate groupUpdate = InternalGroupUpdate.builder() .setSubgroupModification( @@ -107,8 +107,8 @@ public class DeleteSubgroups implements RestModifyView { @Override public Response apply(SubgroupResource resource, Input input) - throws AuthException, MethodNotAllowedException, UnprocessableEntityException, OrmException, - ResourceNotFoundException, IOException, ConfigInvalidException { + throws AuthException, MethodNotAllowedException, UnprocessableEntityException, + StorageException, ResourceNotFoundException, IOException, ConfigInvalidException { AddSubgroups.Input in = new AddSubgroups.Input(); in.groups = ImmutableList.of(resource.getMember().get()); return delete.get().apply(resource, in); diff --git a/java/com/google/gerrit/server/restapi/group/GetAuditLog.java b/java/com/google/gerrit/server/restapi/group/GetAuditLog.java index dcdd8a8802..be63bb2c76 100644 --- a/java/com/google/gerrit/server/restapi/group/GetAuditLog.java +++ b/java/com/google/gerrit/server/restapi/group/GetAuditLog.java @@ -17,6 +17,7 @@ package com.google.gerrit.server.restapi.group; import static java.util.Comparator.comparing; import com.google.gerrit.common.data.GroupDescription; +import com.google.gerrit.exceptions.StorageException; import com.google.gerrit.extensions.common.AccountInfo; import com.google.gerrit.extensions.common.GroupAuditEventInfo; import com.google.gerrit.extensions.common.GroupInfo; @@ -36,7 +37,6 @@ import com.google.gerrit.server.group.InternalGroup; import com.google.gerrit.server.group.InternalGroupDescription; import com.google.gerrit.server.group.db.Groups; import com.google.gerrit.server.permissions.PermissionBackendException; -import com.google.gwtorm.server.OrmException; import com.google.inject.Inject; import com.google.inject.Singleton; import java.io.IOException; @@ -76,7 +76,7 @@ public class GetAuditLog implements RestReadView { @Override public List apply(GroupResource rsrc) - throws AuthException, NotInternalGroupException, OrmException, IOException, + throws AuthException, NotInternalGroupException, StorageException, IOException, ConfigInvalidException, PermissionBackendException { GroupDescription.Internal group = rsrc.asInternalGroup().orElseThrow(NotInternalGroupException::new); diff --git a/java/com/google/gerrit/server/restapi/group/GetDetail.java b/java/com/google/gerrit/server/restapi/group/GetDetail.java index 75d1e34c84..7d41fb1b4a 100644 --- a/java/com/google/gerrit/server/restapi/group/GetDetail.java +++ b/java/com/google/gerrit/server/restapi/group/GetDetail.java @@ -14,12 +14,12 @@ package com.google.gerrit.server.restapi.group; +import com.google.gerrit.exceptions.StorageException; import com.google.gerrit.extensions.client.ListGroupsOption; import com.google.gerrit.extensions.common.GroupInfo; import com.google.gerrit.extensions.restapi.RestReadView; import com.google.gerrit.server.group.GroupResource; import com.google.gerrit.server.permissions.PermissionBackendException; -import com.google.gwtorm.server.OrmException; import com.google.inject.Inject; import com.google.inject.Singleton; @@ -33,7 +33,7 @@ public class GetDetail implements RestReadView { } @Override - public GroupInfo apply(GroupResource rsrc) throws OrmException, PermissionBackendException { + public GroupInfo apply(GroupResource rsrc) throws StorageException, PermissionBackendException { return json.format(rsrc); } } diff --git a/java/com/google/gerrit/server/restapi/group/GetGroup.java b/java/com/google/gerrit/server/restapi/group/GetGroup.java index c6cddb6196..28d53034c8 100644 --- a/java/com/google/gerrit/server/restapi/group/GetGroup.java +++ b/java/com/google/gerrit/server/restapi/group/GetGroup.java @@ -14,11 +14,11 @@ package com.google.gerrit.server.restapi.group; +import com.google.gerrit.exceptions.StorageException; import com.google.gerrit.extensions.common.GroupInfo; import com.google.gerrit.extensions.restapi.RestReadView; import com.google.gerrit.server.group.GroupResource; import com.google.gerrit.server.permissions.PermissionBackendException; -import com.google.gwtorm.server.OrmException; import com.google.inject.Inject; import com.google.inject.Singleton; @@ -32,7 +32,8 @@ public class GetGroup implements RestReadView { } @Override - public GroupInfo apply(GroupResource resource) throws OrmException, PermissionBackendException { + public GroupInfo apply(GroupResource resource) + throws StorageException, PermissionBackendException { return json.format(resource.getGroup()); } } diff --git a/java/com/google/gerrit/server/restapi/group/GetMember.java b/java/com/google/gerrit/server/restapi/group/GetMember.java index 95063de867..b74587b3d9 100644 --- a/java/com/google/gerrit/server/restapi/group/GetMember.java +++ b/java/com/google/gerrit/server/restapi/group/GetMember.java @@ -14,12 +14,12 @@ package com.google.gerrit.server.restapi.group; +import com.google.gerrit.exceptions.StorageException; import com.google.gerrit.extensions.common.AccountInfo; import com.google.gerrit.extensions.restapi.RestReadView; import com.google.gerrit.server.account.AccountLoader; import com.google.gerrit.server.group.MemberResource; import com.google.gerrit.server.permissions.PermissionBackendException; -import com.google.gwtorm.server.OrmException; import com.google.inject.Inject; import com.google.inject.Singleton; @@ -33,7 +33,8 @@ public class GetMember implements RestReadView { } @Override - public AccountInfo apply(MemberResource rsrc) throws OrmException, PermissionBackendException { + public AccountInfo apply(MemberResource rsrc) + throws StorageException, PermissionBackendException { AccountLoader loader = infoFactory.create(true); AccountInfo info = loader.get(rsrc.getMember().getAccountId()); loader.fill(); diff --git a/java/com/google/gerrit/server/restapi/group/GetOwner.java b/java/com/google/gerrit/server/restapi/group/GetOwner.java index 4e8c219530..800616d9b0 100644 --- a/java/com/google/gerrit/server/restapi/group/GetOwner.java +++ b/java/com/google/gerrit/server/restapi/group/GetOwner.java @@ -16,13 +16,13 @@ package com.google.gerrit.server.restapi.group; import com.google.gerrit.common.data.GroupDescription; import com.google.gerrit.exceptions.NoSuchGroupException; +import com.google.gerrit.exceptions.StorageException; import com.google.gerrit.extensions.common.GroupInfo; import com.google.gerrit.extensions.restapi.ResourceNotFoundException; import com.google.gerrit.extensions.restapi.RestReadView; import com.google.gerrit.server.account.GroupControl; import com.google.gerrit.server.group.GroupResource; import com.google.gerrit.server.permissions.PermissionBackendException; -import com.google.gwtorm.server.OrmException; import com.google.inject.Inject; import com.google.inject.Singleton; @@ -40,7 +40,7 @@ public class GetOwner implements RestReadView { @Override public GroupInfo apply(GroupResource resource) - throws NotInternalGroupException, ResourceNotFoundException, OrmException, + throws NotInternalGroupException, ResourceNotFoundException, StorageException, PermissionBackendException { GroupDescription.Internal group = resource.asInternalGroup().orElseThrow(NotInternalGroupException::new); diff --git a/java/com/google/gerrit/server/restapi/group/GetSubgroup.java b/java/com/google/gerrit/server/restapi/group/GetSubgroup.java index 16e27396a2..be5263a712 100644 --- a/java/com/google/gerrit/server/restapi/group/GetSubgroup.java +++ b/java/com/google/gerrit/server/restapi/group/GetSubgroup.java @@ -14,11 +14,11 @@ package com.google.gerrit.server.restapi.group; +import com.google.gerrit.exceptions.StorageException; import com.google.gerrit.extensions.common.GroupInfo; import com.google.gerrit.extensions.restapi.RestReadView; import com.google.gerrit.server.group.SubgroupResource; import com.google.gerrit.server.permissions.PermissionBackendException; -import com.google.gwtorm.server.OrmException; import com.google.inject.Inject; import com.google.inject.Singleton; @@ -32,7 +32,8 @@ public class GetSubgroup implements RestReadView { } @Override - public GroupInfo apply(SubgroupResource rsrc) throws OrmException, PermissionBackendException { + public GroupInfo apply(SubgroupResource rsrc) + throws StorageException, PermissionBackendException { return json.format(rsrc.getMemberDescription()); } } diff --git a/java/com/google/gerrit/server/restapi/group/GroupJson.java b/java/com/google/gerrit/server/restapi/group/GroupJson.java index a51fad24bb..bcdf79d970 100644 --- a/java/com/google/gerrit/server/restapi/group/GroupJson.java +++ b/java/com/google/gerrit/server/restapi/group/GroupJson.java @@ -20,6 +20,7 @@ import static com.google.gerrit.extensions.client.ListGroupsOption.MEMBERS; import com.google.common.base.Strings; import com.google.common.base.Suppliers; import com.google.gerrit.common.data.GroupDescription; +import com.google.gerrit.exceptions.StorageException; import com.google.gerrit.extensions.client.ListGroupsOption; import com.google.gerrit.extensions.common.GroupInfo; import com.google.gerrit.extensions.common.GroupOptionsInfo; @@ -29,7 +30,6 @@ import com.google.gerrit.server.account.GroupBackend; import com.google.gerrit.server.account.GroupControl; import com.google.gerrit.server.group.GroupResource; import com.google.gerrit.server.permissions.PermissionBackendException; -import com.google.gwtorm.server.OrmException; import com.google.inject.Inject; import com.google.inject.Provider; import java.util.Collection; @@ -76,18 +76,18 @@ public class GroupJson { return this; } - public GroupInfo format(GroupResource rsrc) throws OrmException, PermissionBackendException { + public GroupInfo format(GroupResource rsrc) throws StorageException, PermissionBackendException { return createGroupInfo(rsrc.getGroup(), rsrc::getControl); } public GroupInfo format(GroupDescription.Basic group) - throws OrmException, PermissionBackendException { + throws StorageException, PermissionBackendException { return createGroupInfo(group, Suppliers.memoize(() -> groupControlFactory.controlFor(group))); } private GroupInfo createGroupInfo( GroupDescription.Basic group, Supplier groupControlSupplier) - throws OrmException, PermissionBackendException { + throws StorageException, PermissionBackendException { GroupInfo info = createBasicGroupInfo(group); if (group instanceof GroupDescription.Internal) { @@ -110,7 +110,7 @@ public class GroupJson { GroupInfo info, GroupDescription.Internal internalGroup, Supplier groupControlSupplier) - throws OrmException, PermissionBackendException { + throws StorageException, PermissionBackendException { info.description = Strings.emptyToNull(internalGroup.getDescription()); info.groupId = internalGroup.getId().get(); diff --git a/java/com/google/gerrit/server/restapi/group/ListGroups.java b/java/com/google/gerrit/server/restapi/group/ListGroups.java index 982a5f3e8a..eaeac3ca22 100644 --- a/java/com/google/gerrit/server/restapi/group/ListGroups.java +++ b/java/com/google/gerrit/server/restapi/group/ListGroups.java @@ -24,6 +24,7 @@ import com.google.common.collect.Streams; import com.google.gerrit.common.data.GroupDescription; import com.google.gerrit.common.data.GroupReference; import com.google.gerrit.exceptions.NoSuchGroupException; +import com.google.gerrit.exceptions.StorageException; import com.google.gerrit.extensions.client.ListGroupsOption; import com.google.gerrit.extensions.client.ListOption; import com.google.gerrit.extensions.common.GroupInfo; @@ -46,7 +47,6 @@ import com.google.gerrit.server.group.db.Groups; import com.google.gerrit.server.permissions.PermissionBackendException; import com.google.gerrit.server.project.ProjectState; import com.google.gerrit.server.restapi.account.GetGroups; -import com.google.gwtorm.server.OrmException; import com.google.inject.Inject; import com.google.inject.Provider; import java.io.IOException; @@ -249,7 +249,7 @@ public class ListGroups implements RestReadView { @Override public SortedMap apply(TopLevelResource resource) - throws OrmException, RestApiException, IOException, ConfigInvalidException, + throws StorageException, RestApiException, IOException, ConfigInvalidException, PermissionBackendException { SortedMap output = new TreeMap<>(); for (GroupInfo info : get()) { @@ -260,7 +260,7 @@ public class ListGroups implements RestReadView { } public List get() - throws OrmException, RestApiException, IOException, ConfigInvalidException, + throws StorageException, RestApiException, IOException, ConfigInvalidException, PermissionBackendException { if (!Strings.isNullOrEmpty(suggest)) { return suggestGroups(); @@ -286,7 +286,7 @@ public class ListGroups implements RestReadView { } private List getAllGroups() - throws OrmException, IOException, ConfigInvalidException, PermissionBackendException { + throws StorageException, IOException, ConfigInvalidException, PermissionBackendException { Pattern pattern = getRegexPattern(); Stream existingGroups = getAllExistingGroups() @@ -318,7 +318,7 @@ public class ListGroups implements RestReadView { } private List suggestGroups() - throws OrmException, BadRequestException, PermissionBackendException { + throws StorageException, BadRequestException, PermissionBackendException { if (conflictingSuggestParameters()) { throw new BadRequestException( "You should only have no more than one --project and -n with --suggest"); @@ -374,7 +374,7 @@ public class ListGroups implements RestReadView { } private List filterGroupsOwnedBy(Predicate filter) - throws OrmException, IOException, ConfigInvalidException, PermissionBackendException { + throws StorageException, IOException, ConfigInvalidException, PermissionBackendException { Pattern pattern = getRegexPattern(); Stream foundGroups = groups @@ -402,14 +402,14 @@ public class ListGroups implements RestReadView { } private List getGroupsOwnedBy(String id) - throws OrmException, RestApiException, IOException, ConfigInvalidException, + throws StorageException, RestApiException, IOException, ConfigInvalidException, PermissionBackendException { String uuid = groupResolver.parse(id).getGroupUUID().get(); return filterGroupsOwnedBy(group -> group.getOwnerGroupUUID().get().equals(uuid)); } private List getGroupsOwnedBy(IdentifiedUser user) - throws OrmException, IOException, ConfigInvalidException, PermissionBackendException { + throws StorageException, IOException, ConfigInvalidException, PermissionBackendException { return filterGroupsOwnedBy(group -> isOwner(user, group)); } diff --git a/java/com/google/gerrit/server/restapi/group/ListMembers.java b/java/com/google/gerrit/server/restapi/group/ListMembers.java index 4742644720..f0506fc4d7 100644 --- a/java/com/google/gerrit/server/restapi/group/ListMembers.java +++ b/java/com/google/gerrit/server/restapi/group/ListMembers.java @@ -21,6 +21,7 @@ import com.google.common.collect.ImmutableList; import com.google.common.collect.ImmutableSet; import com.google.common.collect.Sets; import com.google.gerrit.common.data.GroupDescription; +import com.google.gerrit.exceptions.StorageException; import com.google.gerrit.extensions.common.AccountInfo; import com.google.gerrit.extensions.restapi.RestReadView; import com.google.gerrit.reviewdb.client.Account; @@ -33,7 +34,6 @@ import com.google.gerrit.server.group.GroupResource; import com.google.gerrit.server.group.InternalGroup; import com.google.gerrit.server.group.InternalGroupDescription; import com.google.gerrit.server.permissions.PermissionBackendException; -import com.google.gwtorm.server.OrmException; import com.google.inject.Inject; import java.util.ArrayList; import java.util.HashSet; @@ -67,7 +67,7 @@ public class ListMembers implements RestReadView { @Override public List apply(GroupResource resource) - throws NotInternalGroupException, OrmException, PermissionBackendException { + throws NotInternalGroupException, StorageException, PermissionBackendException { GroupDescription.Internal group = resource.asInternalGroup().orElseThrow(NotInternalGroupException::new); if (recursive) { diff --git a/java/com/google/gerrit/server/restapi/group/ListSubgroups.java b/java/com/google/gerrit/server/restapi/group/ListSubgroups.java index 0f547dc0c3..cff467eba6 100644 --- a/java/com/google/gerrit/server/restapi/group/ListSubgroups.java +++ b/java/com/google/gerrit/server/restapi/group/ListSubgroups.java @@ -20,13 +20,13 @@ import static java.util.Comparator.comparing; import com.google.common.flogger.FluentLogger; import com.google.gerrit.common.data.GroupDescription; import com.google.gerrit.exceptions.NoSuchGroupException; +import com.google.gerrit.exceptions.StorageException; import com.google.gerrit.extensions.common.GroupInfo; import com.google.gerrit.extensions.restapi.RestReadView; import com.google.gerrit.reviewdb.client.AccountGroup; import com.google.gerrit.server.account.GroupControl; import com.google.gerrit.server.group.GroupResource; import com.google.gerrit.server.permissions.PermissionBackendException; -import com.google.gwtorm.server.OrmException; import com.google.inject.Inject; import com.google.inject.Singleton; import java.util.ArrayList; @@ -47,7 +47,7 @@ public class ListSubgroups implements RestReadView { @Override public List apply(GroupResource rsrc) - throws NotInternalGroupException, OrmException, PermissionBackendException { + throws NotInternalGroupException, StorageException, PermissionBackendException { GroupDescription.Internal group = rsrc.asInternalGroup().orElseThrow(NotInternalGroupException::new); @@ -56,7 +56,7 @@ public class ListSubgroups implements RestReadView { public List getDirectSubgroups( GroupDescription.Internal group, GroupControl groupControl) - throws OrmException, PermissionBackendException { + throws StorageException, PermissionBackendException { boolean ownerOfParent = groupControl.isOwner(); List included = new ArrayList<>(); for (AccountGroup.UUID subgroupUuid : group.getSubgroups()) { diff --git a/java/com/google/gerrit/server/restapi/group/MembersCollection.java b/java/com/google/gerrit/server/restapi/group/MembersCollection.java index fec14436fe..58b17b3c47 100644 --- a/java/com/google/gerrit/server/restapi/group/MembersCollection.java +++ b/java/com/google/gerrit/server/restapi/group/MembersCollection.java @@ -15,6 +15,7 @@ package com.google.gerrit.server.restapi.group; import com.google.gerrit.common.data.GroupDescription; +import com.google.gerrit.exceptions.StorageException; import com.google.gerrit.extensions.registration.DynamicMap; import com.google.gerrit.extensions.restapi.AuthException; import com.google.gerrit.extensions.restapi.ChildCollection; @@ -26,7 +27,6 @@ import com.google.gerrit.server.IdentifiedUser; import com.google.gerrit.server.group.GroupResource; import com.google.gerrit.server.group.MemberResource; import com.google.gerrit.server.restapi.account.AccountsCollection; -import com.google.gwtorm.server.OrmException; import com.google.inject.Inject; import com.google.inject.Provider; import com.google.inject.Singleton; @@ -56,7 +56,7 @@ public class MembersCollection implements ChildCollection apply(GroupResource resource, DescriptionInput input) - throws AuthException, NotInternalGroupException, ResourceNotFoundException, OrmException, + throws AuthException, NotInternalGroupException, ResourceNotFoundException, StorageException, IOException, ConfigInvalidException { if (input == null) { input = new DescriptionInput(); // Delete would set description to null. diff --git a/java/com/google/gerrit/server/restapi/group/PutName.java b/java/com/google/gerrit/server/restapi/group/PutName.java index a1fa6134b5..319dc45050 100644 --- a/java/com/google/gerrit/server/restapi/group/PutName.java +++ b/java/com/google/gerrit/server/restapi/group/PutName.java @@ -16,6 +16,7 @@ package com.google.gerrit.server.restapi.group; import com.google.common.base.Strings; import com.google.gerrit.common.data.GroupDescription; +import com.google.gerrit.exceptions.DuplicateKeyException; import com.google.gerrit.exceptions.NoSuchGroupException; import com.google.gerrit.extensions.common.NameInput; import com.google.gerrit.extensions.restapi.AuthException; @@ -28,7 +29,6 @@ import com.google.gerrit.server.UserInitiated; import com.google.gerrit.server.group.GroupResource; import com.google.gerrit.server.group.db.GroupsUpdate; import com.google.gerrit.server.group.db.InternalGroupUpdate; -import com.google.gwtorm.server.OrmDuplicateKeyException; import com.google.inject.Inject; import com.google.inject.Provider; import com.google.inject.Singleton; @@ -79,7 +79,7 @@ public class PutName implements RestModifyView { groupsUpdateProvider.get().updateGroup(groupUuid, groupUpdate); } catch (NoSuchGroupException e) { throw new ResourceNotFoundException(String.format("Group %s not found", groupUuid)); - } catch (OrmDuplicateKeyException e) { + } catch (DuplicateKeyException e) { throw new ResourceConflictException("group with name " + newName + " already exists"); } } diff --git a/java/com/google/gerrit/server/restapi/group/PutOptions.java b/java/com/google/gerrit/server/restapi/group/PutOptions.java index d074c283cb..0c6c303499 100644 --- a/java/com/google/gerrit/server/restapi/group/PutOptions.java +++ b/java/com/google/gerrit/server/restapi/group/PutOptions.java @@ -16,6 +16,7 @@ package com.google.gerrit.server.restapi.group; import com.google.gerrit.common.data.GroupDescription; import com.google.gerrit.exceptions.NoSuchGroupException; +import com.google.gerrit.exceptions.StorageException; import com.google.gerrit.extensions.common.GroupOptionsInfo; import com.google.gerrit.extensions.restapi.AuthException; import com.google.gerrit.extensions.restapi.BadRequestException; @@ -26,7 +27,6 @@ import com.google.gerrit.server.UserInitiated; import com.google.gerrit.server.group.GroupResource; import com.google.gerrit.server.group.db.GroupsUpdate; import com.google.gerrit.server.group.db.InternalGroupUpdate; -import com.google.gwtorm.server.OrmException; import com.google.inject.Inject; import com.google.inject.Provider; import com.google.inject.Singleton; @@ -45,7 +45,7 @@ public class PutOptions implements RestModifyView { @Override public GroupInfo apply(GroupResource resource, OwnerInput input) throws ResourceNotFoundException, NotInternalGroupException, AuthException, - BadRequestException, UnprocessableEntityException, OrmException, IOException, + BadRequestException, UnprocessableEntityException, StorageException, IOException, ConfigInvalidException, PermissionBackendException { GroupDescription.Internal internalGroup = resource.asInternalGroup().orElseThrow(NotInternalGroupException::new); diff --git a/java/com/google/gerrit/server/restapi/group/QueryGroups.java b/java/com/google/gerrit/server/restapi/group/QueryGroups.java index 6a7262b47a..b677250e37 100644 --- a/java/com/google/gerrit/server/restapi/group/QueryGroups.java +++ b/java/com/google/gerrit/server/restapi/group/QueryGroups.java @@ -16,6 +16,7 @@ package com.google.gerrit.server.restapi.group; import com.google.common.base.Strings; import com.google.common.collect.Lists; +import com.google.gerrit.exceptions.StorageException; import com.google.gerrit.extensions.client.ListGroupsOption; import com.google.gerrit.extensions.client.ListOption; import com.google.gerrit.extensions.common.GroupInfo; @@ -30,7 +31,6 @@ import com.google.gerrit.server.group.InternalGroupDescription; import com.google.gerrit.server.permissions.PermissionBackendException; import com.google.gerrit.server.query.group.GroupQueryBuilder; import com.google.gerrit.server.query.group.GroupQueryProcessor; -import com.google.gwtorm.server.OrmException; import com.google.inject.Inject; import java.util.ArrayList; import java.util.EnumSet; @@ -96,7 +96,7 @@ public class QueryGroups implements RestReadView { @Override public List apply(TopLevelResource resource) - throws BadRequestException, MethodNotAllowedException, OrmException, + throws BadRequestException, MethodNotAllowedException, StorageException, PermissionBackendException { if (Strings.isNullOrEmpty(query)) { throw new BadRequestException("missing query field"); diff --git a/java/com/google/gerrit/server/restapi/project/CheckAccess.java b/java/com/google/gerrit/server/restapi/project/CheckAccess.java index 51e0304ea9..24d8bec31c 100644 --- a/java/com/google/gerrit/server/restapi/project/CheckAccess.java +++ b/java/com/google/gerrit/server/restapi/project/CheckAccess.java @@ -17,6 +17,7 @@ package com.google.gerrit.server.restapi.project; import static com.google.gerrit.reviewdb.client.RefNames.REFS_HEADS; import com.google.common.base.Strings; +import com.google.gerrit.exceptions.StorageException; import com.google.gerrit.extensions.api.config.AccessCheckInfo; import com.google.gerrit.extensions.api.config.AccessCheckInput; import com.google.gerrit.extensions.restapi.AuthException; @@ -34,7 +35,6 @@ import com.google.gerrit.server.permissions.PermissionBackendException; import com.google.gerrit.server.permissions.ProjectPermission; import com.google.gerrit.server.permissions.RefPermission; import com.google.gerrit.server.project.ProjectResource; -import com.google.gwtorm.server.OrmException; import com.google.inject.Inject; import com.google.inject.Singleton; import java.io.IOException; @@ -61,7 +61,7 @@ public class CheckAccess implements RestModifyView { @Override public AccessCheckInfo apply(ProjectResource rsrc) - throws OrmException, PermissionBackendException, RestApiException, IOException, + throws StorageException, PermissionBackendException, RestApiException, IOException, ConfigInvalidException { AccessCheckInput input = new AccessCheckInput(); diff --git a/java/com/google/gerrit/server/restapi/project/CheckMergeability.java b/java/com/google/gerrit/server/restapi/project/CheckMergeability.java index 3dafb39a05..cd9210243b 100644 --- a/java/com/google/gerrit/server/restapi/project/CheckMergeability.java +++ b/java/com/google/gerrit/server/restapi/project/CheckMergeability.java @@ -14,6 +14,7 @@ package com.google.gerrit.server.restapi.project; +import com.google.gerrit.exceptions.StorageException; import com.google.gerrit.extensions.client.SubmitType; import com.google.gerrit.extensions.common.MergeableInfo; import com.google.gerrit.extensions.restapi.BadRequestException; @@ -24,7 +25,6 @@ import com.google.gerrit.server.git.GitRepositoryManager; import com.google.gerrit.server.git.InMemoryInserter; import com.google.gerrit.server.git.MergeUtil; import com.google.gerrit.server.project.BranchResource; -import com.google.gwtorm.server.OrmException; import com.google.inject.Inject; import java.io.IOException; import org.eclipse.jgit.lib.Config; @@ -77,7 +77,7 @@ public class CheckMergeability implements RestReadView { @Override public MergeableInfo apply(BranchResource resource) - throws IOException, OrmException, BadRequestException, ResourceNotFoundException { + throws IOException, StorageException, BadRequestException, ResourceNotFoundException { if (!(submitType.equals(SubmitType.MERGE_ALWAYS) || submitType.equals(SubmitType.MERGE_IF_NECESSARY))) { throw new BadRequestException("Submit type: " + submitType + " is not supported"); diff --git a/java/com/google/gerrit/server/restapi/project/CommitIncludedIn.java b/java/com/google/gerrit/server/restapi/project/CommitIncludedIn.java index 3855b7842a..09c351a279 100644 --- a/java/com/google/gerrit/server/restapi/project/CommitIncludedIn.java +++ b/java/com/google/gerrit/server/restapi/project/CommitIncludedIn.java @@ -14,13 +14,13 @@ package com.google.gerrit.server.restapi.project; +import com.google.gerrit.exceptions.StorageException; import com.google.gerrit.extensions.api.changes.IncludedInInfo; import com.google.gerrit.extensions.restapi.RestApiException; import com.google.gerrit.extensions.restapi.RestReadView; import com.google.gerrit.reviewdb.client.Project; import com.google.gerrit.server.change.IncludedIn; import com.google.gerrit.server.project.CommitResource; -import com.google.gwtorm.server.OrmException; import com.google.inject.Inject; import com.google.inject.Singleton; import java.io.IOException; @@ -37,7 +37,7 @@ public class CommitIncludedIn implements RestReadView { @Override public IncludedInInfo apply(CommitResource rsrc) - throws RestApiException, OrmException, IOException { + throws RestApiException, StorageException, IOException { RevCommit commit = rsrc.getCommit(); Project.NameKey project = rsrc.getProjectState().getNameKey(); return includedIn.apply(project, commit.getId().getName()); diff --git a/java/com/google/gerrit/server/restapi/project/CommitsCollection.java b/java/com/google/gerrit/server/restapi/project/CommitsCollection.java index e8a12bc041..13a9cddb92 100644 --- a/java/com/google/gerrit/server/restapi/project/CommitsCollection.java +++ b/java/com/google/gerrit/server/restapi/project/CommitsCollection.java @@ -16,6 +16,7 @@ package com.google.gerrit.server.restapi.project; import static com.google.common.collect.ImmutableList.toImmutableList; +import com.google.gerrit.exceptions.StorageException; import com.google.gerrit.extensions.registration.DynamicMap; import com.google.gerrit.extensions.restapi.ChildCollection; import com.google.gerrit.extensions.restapi.IdString; @@ -32,7 +33,6 @@ import com.google.gerrit.server.project.ProjectState; import com.google.gerrit.server.project.Reachable; import com.google.gerrit.server.query.change.ChangeData; import com.google.gerrit.server.query.change.InternalChangeQuery; -import com.google.gwtorm.server.OrmException; import com.google.inject.Inject; import com.google.inject.Provider; import com.google.inject.Singleton; @@ -75,7 +75,7 @@ public class CommitsCollection implements ChildCollection apply(ProjectResource rsrc, ProjectAccessInput input) throws PermissionBackendException, AuthException, IOException, ConfigInvalidException, - OrmException, InvalidNameException, UpdateException, RestApiException { + StorageException, InvalidNameException, UpdateException, RestApiException { PermissionBackend.ForProject forProject = permissionBackend.user(rsrc.getUser()).project(rsrc.getNameKey()); if (!check(forProject, ProjectPermission.READ_CONFIG)) { diff --git a/java/com/google/gerrit/server/restapi/project/DeleteBranch.java b/java/com/google/gerrit/server/restapi/project/DeleteBranch.java index 0134ce3fca..16466ba5be 100644 --- a/java/com/google/gerrit/server/restapi/project/DeleteBranch.java +++ b/java/com/google/gerrit/server/restapi/project/DeleteBranch.java @@ -17,6 +17,7 @@ package com.google.gerrit.server.restapi.project; import static com.google.gerrit.reviewdb.client.RefNames.isConfigRef; import static org.eclipse.jgit.lib.Constants.R_HEADS; +import com.google.gerrit.exceptions.StorageException; import com.google.gerrit.extensions.common.Input; import com.google.gerrit.extensions.restapi.MethodNotAllowedException; import com.google.gerrit.extensions.restapi.ResourceConflictException; @@ -26,7 +27,6 @@ import com.google.gerrit.extensions.restapi.RestModifyView; import com.google.gerrit.server.permissions.PermissionBackendException; import com.google.gerrit.server.project.BranchResource; import com.google.gerrit.server.query.change.InternalChangeQuery; -import com.google.gwtorm.server.OrmException; import com.google.inject.Inject; import com.google.inject.Provider; import com.google.inject.Singleton; @@ -46,7 +46,7 @@ public class DeleteBranch implements RestModifyView { @Override public Response apply(BranchResource rsrc, Input input) - throws RestApiException, OrmException, IOException, PermissionBackendException { + throws RestApiException, StorageException, IOException, PermissionBackendException { if (isConfigRef(rsrc.getBranchKey().get())) { // Never allow to delete the meta config branch. throw new MethodNotAllowedException( diff --git a/java/com/google/gerrit/server/restapi/project/DeleteBranches.java b/java/com/google/gerrit/server/restapi/project/DeleteBranches.java index 6e60193f8b..a7468ec85e 100644 --- a/java/com/google/gerrit/server/restapi/project/DeleteBranches.java +++ b/java/com/google/gerrit/server/restapi/project/DeleteBranches.java @@ -17,6 +17,7 @@ package com.google.gerrit.server.restapi.project; import static org.eclipse.jgit.lib.Constants.R_HEADS; import com.google.common.collect.ImmutableSet; +import com.google.gerrit.exceptions.StorageException; import com.google.gerrit.extensions.api.projects.DeleteBranchesInput; import com.google.gerrit.extensions.restapi.BadRequestException; import com.google.gerrit.extensions.restapi.Response; @@ -24,7 +25,6 @@ import com.google.gerrit.extensions.restapi.RestApiException; import com.google.gerrit.extensions.restapi.RestModifyView; import com.google.gerrit.server.permissions.PermissionBackendException; import com.google.gerrit.server.project.ProjectResource; -import com.google.gwtorm.server.OrmException; import com.google.inject.Inject; import com.google.inject.Singleton; import java.io.IOException; @@ -40,7 +40,7 @@ public class DeleteBranches implements RestModifyView apply(ProjectResource project, DeleteBranchesInput input) - throws OrmException, IOException, RestApiException, PermissionBackendException { + throws StorageException, IOException, RestApiException, PermissionBackendException { if (input == null || input.branches == null || input.branches.isEmpty()) { throw new BadRequestException("branches must be specified"); } diff --git a/java/com/google/gerrit/server/restapi/project/DeleteRef.java b/java/com/google/gerrit/server/restapi/project/DeleteRef.java index 5df102c074..8fa095344b 100644 --- a/java/com/google/gerrit/server/restapi/project/DeleteRef.java +++ b/java/com/google/gerrit/server/restapi/project/DeleteRef.java @@ -25,6 +25,7 @@ import com.google.common.collect.ImmutableSet; import com.google.common.collect.Iterables; import com.google.common.flogger.FluentLogger; import com.google.gerrit.common.Nullable; +import com.google.gerrit.exceptions.StorageException; import com.google.gerrit.extensions.restapi.AuthException; import com.google.gerrit.extensions.restapi.ResourceConflictException; import com.google.gerrit.reviewdb.client.Branch; @@ -38,7 +39,6 @@ import com.google.gerrit.server.permissions.RefPermission; import com.google.gerrit.server.project.ProjectState; import com.google.gerrit.server.project.RefValidationHelper; import com.google.gerrit.server.query.change.InternalChangeQuery; -import com.google.gwtorm.server.OrmException; import com.google.inject.Inject; import com.google.inject.Provider; import com.google.inject.Singleton; @@ -180,14 +180,14 @@ public class DeleteRef { * @param projectState the {@code ProjectState} of the project whose refs are to be deleted. * @param refsToDelete the refs to be deleted. * @param prefix the prefix of the refs. - * @throws OrmException + * @throws StorageException * @throws IOException * @throws ResourceConflictException * @throws PermissionBackendException */ public void deleteMultipleRefs( ProjectState projectState, ImmutableSet refsToDelete, String prefix) - throws OrmException, IOException, ResourceConflictException, PermissionBackendException, + throws StorageException, IOException, ResourceConflictException, PermissionBackendException, AuthException { if (refsToDelete.isEmpty()) { return; @@ -229,7 +229,7 @@ public class DeleteRef { private ReceiveCommand createDeleteCommand( ProjectState projectState, Repository r, String refName) - throws OrmException, IOException, ResourceConflictException, PermissionBackendException { + throws StorageException, IOException, ResourceConflictException, PermissionBackendException { Ref ref = r.getRefDatabase().getRef(refName); ReceiveCommand command; if (ref == null) { diff --git a/java/com/google/gerrit/server/restapi/project/DeleteTag.java b/java/com/google/gerrit/server/restapi/project/DeleteTag.java index f7cce11024..5405bfdf94 100644 --- a/java/com/google/gerrit/server/restapi/project/DeleteTag.java +++ b/java/com/google/gerrit/server/restapi/project/DeleteTag.java @@ -16,6 +16,7 @@ package com.google.gerrit.server.restapi.project; import static com.google.gerrit.reviewdb.client.RefNames.isConfigRef; +import com.google.gerrit.exceptions.StorageException; import com.google.gerrit.extensions.common.Input; import com.google.gerrit.extensions.restapi.MethodNotAllowedException; import com.google.gerrit.extensions.restapi.Response; @@ -24,7 +25,6 @@ import com.google.gerrit.extensions.restapi.RestModifyView; import com.google.gerrit.server.permissions.PermissionBackendException; import com.google.gerrit.server.project.RefUtil; import com.google.gerrit.server.project.TagResource; -import com.google.gwtorm.server.OrmException; import com.google.inject.Inject; import com.google.inject.Singleton; import java.io.IOException; @@ -41,7 +41,7 @@ public class DeleteTag implements RestModifyView { @Override public Response apply(TagResource resource, Input input) - throws OrmException, RestApiException, IOException, PermissionBackendException { + throws StorageException, RestApiException, IOException, PermissionBackendException { String tag = RefUtil.normalizeTagRef(resource.getTagInfo().ref); if (isConfigRef(tag)) { diff --git a/java/com/google/gerrit/server/restapi/project/DeleteTags.java b/java/com/google/gerrit/server/restapi/project/DeleteTags.java index bf2c5242c5..883373a63b 100644 --- a/java/com/google/gerrit/server/restapi/project/DeleteTags.java +++ b/java/com/google/gerrit/server/restapi/project/DeleteTags.java @@ -17,6 +17,7 @@ package com.google.gerrit.server.restapi.project; import static org.eclipse.jgit.lib.Constants.R_TAGS; import com.google.common.collect.ImmutableSet; +import com.google.gerrit.exceptions.StorageException; import com.google.gerrit.extensions.api.projects.DeleteTagsInput; import com.google.gerrit.extensions.restapi.BadRequestException; import com.google.gerrit.extensions.restapi.Response; @@ -24,7 +25,6 @@ import com.google.gerrit.extensions.restapi.RestApiException; import com.google.gerrit.extensions.restapi.RestModifyView; import com.google.gerrit.server.permissions.PermissionBackendException; import com.google.gerrit.server.project.ProjectResource; -import com.google.gwtorm.server.OrmException; import com.google.inject.Inject; import com.google.inject.Singleton; import java.io.IOException; @@ -40,7 +40,7 @@ public class DeleteTags implements RestModifyView apply(ProjectResource project, DeleteTagsInput input) - throws OrmException, RestApiException, IOException, PermissionBackendException { + throws StorageException, RestApiException, IOException, PermissionBackendException { if (input == null || input.tags == null || input.tags.isEmpty()) { throw new BadRequestException("tags must be specified"); } diff --git a/java/com/google/gerrit/server/restapi/project/GetHead.java b/java/com/google/gerrit/server/restapi/project/GetHead.java index 5b10120c74..bb62bb62e0 100644 --- a/java/com/google/gerrit/server/restapi/project/GetHead.java +++ b/java/com/google/gerrit/server/restapi/project/GetHead.java @@ -14,6 +14,7 @@ package com.google.gerrit.server.restapi.project; +import com.google.gerrit.exceptions.StorageException; import com.google.gerrit.extensions.restapi.AuthException; import com.google.gerrit.extensions.restapi.ResourceNotFoundException; import com.google.gerrit.extensions.restapi.RestReadView; @@ -23,7 +24,6 @@ import com.google.gerrit.server.permissions.PermissionBackendException; import com.google.gerrit.server.permissions.ProjectPermission; import com.google.gerrit.server.permissions.RefPermission; import com.google.gerrit.server.project.ProjectResource; -import com.google.gwtorm.server.OrmException; import com.google.inject.Inject; import com.google.inject.Singleton; import java.io.IOException; @@ -54,7 +54,7 @@ public class GetHead implements RestReadView { @Override public String apply(ProjectResource rsrc) - throws AuthException, ResourceNotFoundException, IOException, OrmException, + throws AuthException, ResourceNotFoundException, IOException, StorageException, PermissionBackendException { rsrc.getProjectState().statePermitsRead(); try (Repository repo = repoManager.openRepository(rsrc.getNameKey())) { diff --git a/java/com/google/gerrit/server/restapi/project/Index.java b/java/com/google/gerrit/server/restapi/project/Index.java index a346aedb0e..43d4bc3724 100644 --- a/java/com/google/gerrit/server/restapi/project/Index.java +++ b/java/com/google/gerrit/server/restapi/project/Index.java @@ -19,6 +19,7 @@ import static com.google.gerrit.server.git.QueueProvider.QueueType.BATCH; import com.google.common.flogger.FluentLogger; import com.google.common.util.concurrent.ListeningExecutorService; import com.google.gerrit.common.data.GlobalCapability; +import com.google.gerrit.exceptions.StorageException; import com.google.gerrit.extensions.annotations.RequiresCapability; import com.google.gerrit.extensions.api.projects.IndexProjectInput; import com.google.gerrit.extensions.common.ProjectInfo; @@ -30,7 +31,6 @@ import com.google.gerrit.reviewdb.client.Project; import com.google.gerrit.server.index.IndexExecutor; import com.google.gerrit.server.permissions.PermissionBackendException; import com.google.gerrit.server.project.ProjectResource; -import com.google.gwtorm.server.OrmException; import com.google.inject.Inject; import com.google.inject.Provider; import com.google.inject.Singleton; @@ -58,7 +58,7 @@ public class Index implements RestModifyView @Override public Response.Accepted apply(ProjectResource rsrc, IndexProjectInput input) - throws IOException, OrmException, PermissionBackendException, RestApiException { + throws IOException, StorageException, PermissionBackendException, RestApiException { String response = "Project " + rsrc.getName() + " submitted for reindexing"; reindex(rsrc.getNameKey(), input.async); diff --git a/java/com/google/gerrit/server/restapi/project/ListChildProjects.java b/java/com/google/gerrit/server/restapi/project/ListChildProjects.java index ea54a4a217..6291baab88 100644 --- a/java/com/google/gerrit/server/restapi/project/ListChildProjects.java +++ b/java/com/google/gerrit/server/restapi/project/ListChildProjects.java @@ -16,6 +16,7 @@ package com.google.gerrit.server.restapi.project; import static java.util.stream.Collectors.toList; +import com.google.gerrit.exceptions.StorageException; import com.google.gerrit.extensions.common.ProjectInfo; import com.google.gerrit.extensions.restapi.BadRequestException; import com.google.gerrit.extensions.restapi.ResourceConflictException; @@ -27,7 +28,6 @@ import com.google.gerrit.server.permissions.PermissionBackendException; import com.google.gerrit.server.permissions.ProjectPermission; import com.google.gerrit.server.project.ChildProjects; import com.google.gerrit.server.project.ProjectResource; -import com.google.gwtorm.server.OrmException; import com.google.inject.Inject; import com.google.inject.Provider; import java.util.List; @@ -67,7 +67,7 @@ public class ListChildProjects implements RestReadView { @Override public List apply(ProjectResource rsrc) - throws PermissionBackendException, OrmException, RestApiException { + throws PermissionBackendException, StorageException, RestApiException { if (limit < 0) { throw new BadRequestException("limit must be a positive number"); } @@ -83,7 +83,7 @@ public class ListChildProjects implements RestReadView { } private List directChildProjects(Project.NameKey parent) - throws OrmException, RestApiException { + throws StorageException, RestApiException { PermissionBackend.WithUser currentUser = permissionBackend.currentUser(); return queryProvider.get().withQuery("parent:" + parent.get()).withLimit(limit).apply().stream() .filter( diff --git a/java/com/google/gerrit/server/restapi/project/ListProjects.java b/java/com/google/gerrit/server/restapi/project/ListProjects.java index b4a9001022..cf32926601 100644 --- a/java/com/google/gerrit/server/restapi/project/ListProjects.java +++ b/java/com/google/gerrit/server/restapi/project/ListProjects.java @@ -28,6 +28,7 @@ import com.google.common.flogger.FluentLogger; import com.google.gerrit.common.Nullable; import com.google.gerrit.common.data.GroupReference; import com.google.gerrit.exceptions.NoSuchGroupException; +import com.google.gerrit.exceptions.StorageException; import com.google.gerrit.extensions.common.ProjectInfo; import com.google.gerrit.extensions.common.WebLinkInfo; import com.google.gerrit.extensions.restapi.AuthException; @@ -57,7 +58,6 @@ import com.google.gerrit.server.project.ProjectCache; import com.google.gerrit.server.project.ProjectState; import com.google.gerrit.server.util.TreeFormatter; import com.google.gson.reflect.TypeToken; -import com.google.gwtorm.server.OrmException; import com.google.inject.Inject; import com.google.inject.Provider; import java.io.BufferedWriter; @@ -358,7 +358,7 @@ public class ListProjects implements RestReadView { .collect( ImmutableSortedMap.toImmutableSortedMap( natural(), p -> p.name, p -> showDescription ? p : nullifyDescription(p))); - } catch (OrmException | MethodNotAllowedException e) { + } catch (StorageException | MethodNotAllowedException e) { logger.atWarning().withCause(e).log( "Internal error while processing the query '%s' request", query); throw new BadRequestException("Internal error while processing the query request"); @@ -378,7 +378,7 @@ public class ListProjects implements RestReadView { newProjectsNamesStream(query).forEach(out::println); } out.flush(); - } catch (OrmException | MethodNotAllowedException e) { + } catch (StorageException | MethodNotAllowedException e) { logger.atWarning().withCause(e).log( "Internal error while processing the query '%s' request", query); throw new BadRequestException("Internal error while processing the query request"); @@ -386,7 +386,7 @@ public class ListProjects implements RestReadView { } private Stream newProjectsNamesStream(String query) - throws OrmException, MethodNotAllowedException, BadRequestException { + throws StorageException, MethodNotAllowedException, BadRequestException { Stream projects = queryProjectsProvider.get().withQuery(query).apply().stream().map(p -> p.name).skip(start); if (limit > 0) { diff --git a/java/com/google/gerrit/server/restapi/project/QueryProjects.java b/java/com/google/gerrit/server/restapi/project/QueryProjects.java index 44432aaf51..dea5492e23 100644 --- a/java/com/google/gerrit/server/restapi/project/QueryProjects.java +++ b/java/com/google/gerrit/server/restapi/project/QueryProjects.java @@ -16,6 +16,7 @@ package com.google.gerrit.server.restapi.project; import com.google.common.base.Strings; import com.google.common.collect.Lists; +import com.google.gerrit.exceptions.StorageException; import com.google.gerrit.extensions.common.ProjectInfo; import com.google.gerrit.extensions.restapi.BadRequestException; import com.google.gerrit.extensions.restapi.MethodNotAllowedException; @@ -29,7 +30,6 @@ import com.google.gerrit.index.query.QueryResult; import com.google.gerrit.server.project.ProjectJson; import com.google.gerrit.server.query.project.ProjectQueryBuilder; import com.google.gerrit.server.query.project.ProjectQueryProcessor; -import com.google.gwtorm.server.OrmException; import com.google.inject.Inject; import java.util.ArrayList; import java.util.List; @@ -88,12 +88,12 @@ public class QueryProjects implements RestReadView { @Override public List apply(TopLevelResource resource) - throws BadRequestException, MethodNotAllowedException, OrmException { + throws BadRequestException, MethodNotAllowedException, StorageException { return apply(); } public List apply() - throws BadRequestException, MethodNotAllowedException, OrmException { + throws BadRequestException, MethodNotAllowedException, StorageException { if (Strings.isNullOrEmpty(query)) { throw new BadRequestException("missing query field"); } diff --git a/java/com/google/gerrit/server/restapi/project/SetAccess.java b/java/com/google/gerrit/server/restapi/project/SetAccess.java index 25ab42be4e..c053ce574c 100644 --- a/java/com/google/gerrit/server/restapi/project/SetAccess.java +++ b/java/com/google/gerrit/server/restapi/project/SetAccess.java @@ -18,6 +18,7 @@ import com.google.common.base.Strings; import com.google.common.collect.Iterables; import com.google.gerrit.common.data.AccessSection; import com.google.gerrit.exceptions.InvalidNameException; +import com.google.gerrit.exceptions.StorageException; import com.google.gerrit.extensions.api.access.ProjectAccessInfo; import com.google.gerrit.extensions.api.access.ProjectAccessInput; import com.google.gerrit.extensions.restapi.AuthException; @@ -38,7 +39,6 @@ import com.google.gerrit.server.permissions.RefPermission; import com.google.gerrit.server.project.ProjectCache; import com.google.gerrit.server.project.ProjectConfig; import com.google.gerrit.server.project.ProjectResource; -import com.google.gwtorm.server.OrmException; import com.google.inject.Inject; import com.google.inject.Provider; import com.google.inject.Singleton; @@ -83,7 +83,7 @@ public class SetAccess implements RestModifyView paths) - throws OrmException { + throws StorageException { if (paths == null || paths.isEmpty()) { return; } @@ -255,8 +255,8 @@ public abstract class JdbcAccountPatchReviewStore } stmt.executeBatch(); } catch (SQLException e) { - OrmException ormException = convertError("insert", e); - if (ormException instanceof OrmDuplicateKeyException) { + StorageException ormException = convertError("insert", e); + if (ormException instanceof DuplicateKeyException) { return; } throw ormException; @@ -265,7 +265,7 @@ public abstract class JdbcAccountPatchReviewStore @Override public void clearReviewed(PatchSet.Id psId, Account.Id accountId, String path) - throws OrmException { + throws StorageException { try (Connection con = ds.getConnection(); PreparedStatement stmt = con.prepareStatement( @@ -283,7 +283,7 @@ public abstract class JdbcAccountPatchReviewStore } @Override - public void clearReviewed(PatchSet.Id psId) throws OrmException { + public void clearReviewed(PatchSet.Id psId) throws StorageException { try (Connection con = ds.getConnection(); PreparedStatement stmt = con.prepareStatement( @@ -299,7 +299,7 @@ public abstract class JdbcAccountPatchReviewStore @Override public Optional findReviewed(PatchSet.Id psId, Account.Id accountId) - throws OrmException { + throws StorageException { try (Connection con = ds.getConnection(); PreparedStatement stmt = con.prepareStatement( @@ -331,11 +331,11 @@ public abstract class JdbcAccountPatchReviewStore } } - public OrmException convertError(String op, SQLException err) { + public StorageException convertError(String op, SQLException err) { if (err.getCause() == null && err.getNextException() != null) { err.initCause(err.getNextException()); } - return new OrmException(op + " failure on account_patch_reviews", err); + return new StorageException(op + " failure on account_patch_reviews", err); } private static String getSQLState(SQLException err) { diff --git a/java/com/google/gerrit/server/schema/MariaDBAccountPatchReviewStore.java b/java/com/google/gerrit/server/schema/MariaDBAccountPatchReviewStore.java index aa05a0878f..b0a3370fe1 100644 --- a/java/com/google/gerrit/server/schema/MariaDBAccountPatchReviewStore.java +++ b/java/com/google/gerrit/server/schema/MariaDBAccountPatchReviewStore.java @@ -14,11 +14,11 @@ package com.google.gerrit.server.schema; +import com.google.gerrit.exceptions.DuplicateKeyException; +import com.google.gerrit.exceptions.StorageException; import com.google.gerrit.server.config.GerritServerConfig; import com.google.gerrit.server.config.SitePaths; import com.google.gerrit.server.config.ThreadSettingsConfig; -import com.google.gwtorm.server.OrmDuplicateKeyException; -import com.google.gwtorm.server.OrmException; import com.google.inject.Inject; import com.google.inject.Singleton; import java.sql.SQLException; @@ -36,18 +36,18 @@ public class MariaDBAccountPatchReviewStore extends JdbcAccountPatchReviewStore } @Override - public OrmException convertError(String op, SQLException err) { + public StorageException convertError(String op, SQLException err) { switch (getSQLStateInt(err)) { case 1022: // ER_DUP_KEY case 1062: // ER_DUP_ENTRY case 1169: // ER_DUP_UNIQUE; - return new OrmDuplicateKeyException("ACCOUNT_PATCH_REVIEWS", err); + return new DuplicateKeyException("ACCOUNT_PATCH_REVIEWS", err); default: if (err.getCause() == null && err.getNextException() != null) { err.initCause(err.getNextException()); } - return new OrmException(op + " failure on ACCOUNT_PATCH_REVIEWS", err); + return new StorageException(op + " failure on ACCOUNT_PATCH_REVIEWS", err); } } } diff --git a/java/com/google/gerrit/server/schema/MysqlAccountPatchReviewStore.java b/java/com/google/gerrit/server/schema/MysqlAccountPatchReviewStore.java index d648ed0672..35bf2cb7e5 100644 --- a/java/com/google/gerrit/server/schema/MysqlAccountPatchReviewStore.java +++ b/java/com/google/gerrit/server/schema/MysqlAccountPatchReviewStore.java @@ -14,11 +14,11 @@ package com.google.gerrit.server.schema; +import com.google.gerrit.exceptions.DuplicateKeyException; +import com.google.gerrit.exceptions.StorageException; import com.google.gerrit.server.config.GerritServerConfig; import com.google.gerrit.server.config.SitePaths; import com.google.gerrit.server.config.ThreadSettingsConfig; -import com.google.gwtorm.server.OrmDuplicateKeyException; -import com.google.gwtorm.server.OrmException; import com.google.inject.Inject; import com.google.inject.Singleton; import java.sql.SQLException; @@ -37,18 +37,18 @@ public class MysqlAccountPatchReviewStore extends JdbcAccountPatchReviewStore { } @Override - public OrmException convertError(String op, SQLException err) { + public StorageException convertError(String op, SQLException err) { switch (getSQLStateInt(err)) { case 1022: // ER_DUP_KEY case 1062: // ER_DUP_ENTRY case 1169: // ER_DUP_UNIQUE; - return new OrmDuplicateKeyException("ACCOUNT_PATCH_REVIEWS", err); + return new DuplicateKeyException("ACCOUNT_PATCH_REVIEWS", err); default: if (err.getCause() == null && err.getNextException() != null) { err.initCause(err.getNextException()); } - return new OrmException(op + " failure on ACCOUNT_PATCH_REVIEWS", err); + return new StorageException(op + " failure on ACCOUNT_PATCH_REVIEWS", err); } } diff --git a/java/com/google/gerrit/server/schema/NoteDbSchemaUpdater.java b/java/com/google/gerrit/server/schema/NoteDbSchemaUpdater.java index f8a9cf7439..8164f1e6a6 100644 --- a/java/com/google/gerrit/server/schema/NoteDbSchemaUpdater.java +++ b/java/com/google/gerrit/server/schema/NoteDbSchemaUpdater.java @@ -20,12 +20,12 @@ import com.google.common.annotations.VisibleForTesting; import com.google.common.collect.ImmutableList; import com.google.common.collect.ImmutableSortedMap; import com.google.common.collect.ImmutableSortedSet; +import com.google.gerrit.exceptions.StorageException; import com.google.gerrit.reviewdb.client.RefNames; import com.google.gerrit.server.config.AllUsersName; import com.google.gerrit.server.config.GerritServerConfig; import com.google.gerrit.server.git.GitRepositoryManager; import com.google.gerrit.server.notedb.Sequences; -import com.google.gwtorm.server.OrmException; import com.google.inject.Inject; import java.io.IOException; import java.util.stream.IntStream; @@ -77,7 +77,7 @@ public class NoteDbSchemaUpdater { this.schemaVersions = schemaVersions; } - public void update(UpdateUI ui) throws OrmException { + public void update(UpdateUI ui) throws StorageException { ensureSchemaCreated(); int currentVersion = versionManager.read(); @@ -94,17 +94,17 @@ public class NoteDbSchemaUpdater { NoteDbSchemaVersions.get(schemaVersions, nextVersion).upgrade(args, ui); versionManager.increment(nextVersion - 1); } catch (Exception e) { - throw new OrmException( + throw new StorageException( String.format("Failed to upgrade to schema version %d", nextVersion), e); } } } - private void ensureSchemaCreated() throws OrmException { + private void ensureSchemaCreated() throws StorageException { try { schemaCreator.ensureCreated(); } catch (IOException | ConfigInvalidException e) { - throw new OrmException("Cannot initialize Gerrit site"); + throw new StorageException("Cannot initialize Gerrit site"); } } @@ -114,7 +114,7 @@ public class NoteDbSchemaUpdater { NOTE_DB } - private void checkNoteDbConfigFor216() throws OrmException { + private void checkNoteDbConfigFor216() throws StorageException { // Check that the NoteDb migration config matches what we expect from a site that both: // * Completed the change migration to NoteDB. // * Ran schema upgrades from a 2.16 final release. @@ -125,7 +125,7 @@ public class NoteDbSchemaUpdater { "noteDb", "changes", "primaryStorage", PrimaryStorageFor216Compatibility.REVIEW_DB) != PrimaryStorageFor216Compatibility.NOTE_DB || !cfg.getBoolean("noteDb", "changes", "disableReviewDb", false)) { - throw new OrmException( + throw new StorageException( "You appear to be upgrading from a 2.x site, but the NoteDb change migration was" + " not completed. See documentation:\n" + "https://gerrit-review.googlesource.com/Documentation/note-db.html#migration"); @@ -149,24 +149,24 @@ public class NoteDbSchemaUpdater { // this and get 2.16 running rather than abandoning 2.16 and jumping to 3.0 at this point. try (Repository allUsers = repoManager.openRepository(allUsersName)) { if (allUsers.exactRef(RefNames.REFS_SEQUENCES + Sequences.NAME_GROUPS) == null) { - throw new OrmException( + throw new StorageException( "You appear to be upgrading to 3.x from a version prior to 2.16; you must upgrade to" + " 2.16.x first"); } } catch (IOException e) { - throw new OrmException("Failed to check NoteDb migration state", e); + throw new StorageException("Failed to check NoteDb migration state", e); } } @VisibleForTesting static ImmutableList requiredUpgrades( - int currentVersion, ImmutableSortedSet allVersions) throws OrmException { + int currentVersion, ImmutableSortedSet allVersions) throws StorageException { int firstVersion = allVersions.first(); int latestVersion = allVersions.last(); if (currentVersion == latestVersion) { return ImmutableList.of(); } else if (currentVersion > latestVersion) { - throw new OrmException( + throw new StorageException( String.format( "Cannot downgrade NoteDb schema from version %d to %d", currentVersion, latestVersion)); @@ -178,7 +178,7 @@ public class NoteDbSchemaUpdater { firstUpgradeVersion = firstVersion; } else { if (currentVersion < firstVersion - 1) { - throw new OrmException( + throw new StorageException( String.format( "Cannot skip NoteDb schema from version %d to %d", currentVersion, firstVersion)); } diff --git a/java/com/google/gerrit/server/schema/NoteDbSchemaVersionCheck.java b/java/com/google/gerrit/server/schema/NoteDbSchemaVersionCheck.java index 63bffec4eb..33534fc0a6 100644 --- a/java/com/google/gerrit/server/schema/NoteDbSchemaVersionCheck.java +++ b/java/com/google/gerrit/server/schema/NoteDbSchemaVersionCheck.java @@ -14,10 +14,10 @@ package com.google.gerrit.server.schema; +import com.google.gerrit.exceptions.StorageException; import com.google.gerrit.extensions.events.LifecycleListener; import com.google.gerrit.lifecycle.LifecycleModule; import com.google.gerrit.server.config.SitePaths; -import com.google.gwtorm.server.OrmException; import com.google.inject.Inject; import com.google.inject.Module; import com.google.inject.ProvisionException; @@ -65,7 +65,7 @@ public class NoteDbSchemaVersionCheck implements LifecycleListener { "Unsupported schema version %d; expected schema version %d. %s", current, expected, advice)); } - } catch (OrmException e) { + } catch (StorageException e) { throw new ProvisionException("Failed to read NoteDb schema version", e); } } diff --git a/java/com/google/gerrit/server/schema/NoteDbSchemaVersionManager.java b/java/com/google/gerrit/server/schema/NoteDbSchemaVersionManager.java index da5f7b95e9..86d7eb43d3 100644 --- a/java/com/google/gerrit/server/schema/NoteDbSchemaVersionManager.java +++ b/java/com/google/gerrit/server/schema/NoteDbSchemaVersionManager.java @@ -17,11 +17,11 @@ package com.google.gerrit.server.schema; import static com.google.gerrit.reviewdb.client.RefNames.REFS_VERSION; import com.google.common.annotations.VisibleForTesting; +import com.google.gerrit.exceptions.StorageException; import com.google.gerrit.server.config.AllProjectsName; import com.google.gerrit.server.extensions.events.GitReferenceUpdated; import com.google.gerrit.server.git.GitRepositoryManager; import com.google.gerrit.server.notedb.IntBlob; -import com.google.gwtorm.server.OrmException; import com.google.inject.Inject; import java.io.IOException; import java.util.Optional; @@ -45,20 +45,20 @@ public class NoteDbSchemaVersionManager { this.repoManager = repoManager; } - public int read() throws OrmException { + public int read() throws StorageException { try (Repository repo = repoManager.openRepository(allProjectsName)) { return IntBlob.parse(repo, REFS_VERSION).map(IntBlob::value).orElse(0); } catch (IOException e) { - throw new OrmException("Failed to read " + REFS_VERSION, e); + throw new StorageException("Failed to read " + REFS_VERSION, e); } } - public void init() throws IOException, OrmException { + public void init() throws IOException, StorageException { try (Repository repo = repoManager.openRepository(allProjectsName); RevWalk rw = new RevWalk(repo)) { Optional old = IntBlob.parse(repo, REFS_VERSION, rw); if (old.isPresent()) { - throw new OrmException( + throw new StorageException( String.format( "Expected no old version for %s, found %s", REFS_VERSION, old.get().value())); } @@ -73,12 +73,12 @@ public class NoteDbSchemaVersionManager { } } - public void increment(int expectedOldVersion) throws IOException, OrmException { + public void increment(int expectedOldVersion) throws IOException, StorageException { try (Repository repo = repoManager.openRepository(allProjectsName); RevWalk rw = new RevWalk(repo)) { Optional old = IntBlob.parse(repo, REFS_VERSION, rw); if (old.isPresent() && old.get().value() != expectedOldVersion) { - throw new OrmException( + throw new StorageException( String.format( "Expected old version %d for %s, found %d", expectedOldVersion, REFS_VERSION, old.get().value())); diff --git a/java/com/google/gerrit/server/schema/PostgresqlAccountPatchReviewStore.java b/java/com/google/gerrit/server/schema/PostgresqlAccountPatchReviewStore.java index 34f7dba1c0..db68f2e8a2 100644 --- a/java/com/google/gerrit/server/schema/PostgresqlAccountPatchReviewStore.java +++ b/java/com/google/gerrit/server/schema/PostgresqlAccountPatchReviewStore.java @@ -14,11 +14,11 @@ package com.google.gerrit.server.schema; +import com.google.gerrit.exceptions.DuplicateKeyException; +import com.google.gerrit.exceptions.StorageException; import com.google.gerrit.server.config.GerritServerConfig; import com.google.gerrit.server.config.SitePaths; import com.google.gerrit.server.config.ThreadSettingsConfig; -import com.google.gwtorm.server.OrmDuplicateKeyException; -import com.google.gwtorm.server.OrmException; import com.google.inject.Inject; import com.google.inject.Singleton; import java.sql.SQLException; @@ -36,10 +36,10 @@ public class PostgresqlAccountPatchReviewStore extends JdbcAccountPatchReviewSto } @Override - public OrmException convertError(String op, SQLException err) { + public StorageException convertError(String op, SQLException err) { switch (getSQLStateInt(err)) { case 23505: // DUPLICATE_KEY_1 - return new OrmDuplicateKeyException("ACCOUNT_PATCH_REVIEWS", err); + return new DuplicateKeyException("ACCOUNT_PATCH_REVIEWS", err); case 23514: // CHECK CONSTRAINT VIOLATION case 23503: // FOREIGN KEY CONSTRAINT VIOLATION @@ -49,7 +49,7 @@ public class PostgresqlAccountPatchReviewStore extends JdbcAccountPatchReviewSto if (err.getCause() == null && err.getNextException() != null) { err.initCause(err.getNextException()); } - return new OrmException(op + " failure on ACCOUNT_PATCH_REVIEWS", err); + return new StorageException(op + " failure on ACCOUNT_PATCH_REVIEWS", err); } } } diff --git a/java/com/google/gerrit/server/schema/ProjectConfigSchemaUpdate.java b/java/com/google/gerrit/server/schema/ProjectConfigSchemaUpdate.java index 483e36323d..a93c9da9c4 100644 --- a/java/com/google/gerrit/server/schema/ProjectConfigSchemaUpdate.java +++ b/java/com/google/gerrit/server/schema/ProjectConfigSchemaUpdate.java @@ -20,13 +20,13 @@ import static java.util.stream.Collectors.toList; import com.google.common.annotations.VisibleForTesting; import com.google.gerrit.common.Nullable; import com.google.gerrit.common.data.PermissionRule; +import com.google.gerrit.exceptions.StorageException; import com.google.gerrit.reviewdb.client.RefNames; import com.google.gerrit.server.config.AllProjectsName; import com.google.gerrit.server.config.SitePaths; import com.google.gerrit.server.git.meta.MetaDataUpdate; import com.google.gerrit.server.git.meta.VersionedMetaData; import com.google.gerrit.server.project.ProjectConfig; -import com.google.gwtorm.server.OrmException; import com.google.inject.Inject; import java.io.IOException; import java.util.Arrays; @@ -115,7 +115,7 @@ public class ProjectConfigSchemaUpdate extends VersionedMetaData { return true; } - public void save(PersonIdent personIdent, String commitMessage) throws OrmException { + public void save(PersonIdent personIdent, String commitMessage) throws StorageException { if (!updated) { return; } @@ -126,7 +126,7 @@ public class ProjectConfigSchemaUpdate extends VersionedMetaData { try { commit(update); } catch (IOException e) { - throw new OrmException(e); + throw new StorageException(e); } } diff --git a/java/com/google/gerrit/server/schema/SchemaCreator.java b/java/com/google/gerrit/server/schema/SchemaCreator.java index 8cf8fe7fde..49f028a814 100644 --- a/java/com/google/gerrit/server/schema/SchemaCreator.java +++ b/java/com/google/gerrit/server/schema/SchemaCreator.java @@ -14,7 +14,7 @@ package com.google.gerrit.server.schema; -import com.google.gwtorm.server.OrmException; +import com.google.gerrit.exceptions.StorageException; import java.io.IOException; import org.eclipse.jgit.errors.ConfigInvalidException; @@ -26,20 +26,20 @@ public interface SchemaCreator { * *

Fails if the schema does exist. * - * @throws OrmException an error occurred. + * @throws StorageException an error occurred. * @throws IOException an error occurred. * @throws ConfigInvalidException an error occurred. */ - void create() throws OrmException, IOException, ConfigInvalidException; + void create() throws StorageException, IOException, ConfigInvalidException; /** * Create the schema only if it does not already exist. * *

Succeeds if the schema does exist. * - * @throws OrmException an error occurred. + * @throws StorageException an error occurred. * @throws IOException an error occurred. * @throws ConfigInvalidException an error occurred. */ - void ensureCreated() throws OrmException, IOException, ConfigInvalidException; + void ensureCreated() throws StorageException, IOException, ConfigInvalidException; } diff --git a/java/com/google/gerrit/server/schema/SchemaCreatorImpl.java b/java/com/google/gerrit/server/schema/SchemaCreatorImpl.java index 3605dd57da..46e6fe6983 100644 --- a/java/com/google/gerrit/server/schema/SchemaCreatorImpl.java +++ b/java/com/google/gerrit/server/schema/SchemaCreatorImpl.java @@ -17,6 +17,8 @@ package com.google.gerrit.server.schema; import com.google.common.collect.ImmutableSet; import com.google.gerrit.common.Nullable; import com.google.gerrit.common.data.GroupReference; +import com.google.gerrit.exceptions.DuplicateKeyException; +import com.google.gerrit.exceptions.StorageException; import com.google.gerrit.git.RefUpdateUtil; import com.google.gerrit.metrics.MetricMaker; import com.google.gerrit.reviewdb.client.AccountGroup; @@ -36,8 +38,6 @@ import com.google.gerrit.server.group.db.InternalGroupUpdate; import com.google.gerrit.server.index.group.GroupIndex; import com.google.gerrit.server.index.group.GroupIndexCollection; import com.google.gerrit.server.notedb.Sequences; -import com.google.gwtorm.server.OrmDuplicateKeyException; -import com.google.gwtorm.server.OrmException; import com.google.inject.Inject; import java.io.IOException; import org.eclipse.jgit.errors.ConfigInvalidException; @@ -90,7 +90,7 @@ public class SchemaCreatorImpl implements SchemaCreator { } @Override - public void create() throws OrmException, IOException, ConfigInvalidException { + public void create() throws StorageException, IOException, ConfigInvalidException { GroupReference admins = createGroupReference("Administrators"); GroupReference batchUsers = createGroupReference("Non-Interactive Users"); @@ -117,7 +117,7 @@ public class SchemaCreatorImpl implements SchemaCreator { } @Override - public void ensureCreated() throws OrmException, IOException, ConfigInvalidException { + public void ensureCreated() throws StorageException, IOException, ConfigInvalidException { try { repoManager.openRepository(allProjectsName).close(); } catch (RepositoryNotFoundException e) { @@ -127,7 +127,7 @@ public class SchemaCreatorImpl implements SchemaCreator { private void createAdminsGroup( Sequences seqs, Repository allUsersRepo, GroupReference groupReference) - throws OrmException, IOException, ConfigInvalidException { + throws StorageException, IOException, ConfigInvalidException { InternalGroupCreation groupCreation = getGroupCreation(seqs, groupReference); InternalGroupUpdate groupUpdate = InternalGroupUpdate.builder().setDescription("Gerrit Site Administrators").build(); @@ -140,7 +140,7 @@ public class SchemaCreatorImpl implements SchemaCreator { Repository allUsersRepo, GroupReference groupReference, AccountGroup.UUID adminsGroupUuid) - throws OrmException, IOException, ConfigInvalidException { + throws StorageException, IOException, ConfigInvalidException { InternalGroupCreation groupCreation = getGroupCreation(seqs, groupReference); InternalGroupUpdate groupUpdate = InternalGroupUpdate.builder() @@ -153,14 +153,14 @@ public class SchemaCreatorImpl implements SchemaCreator { private void createGroup( Repository allUsersRepo, InternalGroupCreation groupCreation, InternalGroupUpdate groupUpdate) - throws OrmException, ConfigInvalidException, IOException { + throws StorageException, ConfigInvalidException, IOException { InternalGroup createdGroup = createGroupInNoteDb(allUsersRepo, groupCreation, groupUpdate); index(createdGroup); } private InternalGroup createGroupInNoteDb( Repository allUsersRepo, InternalGroupCreation groupCreation, InternalGroupUpdate groupUpdate) - throws ConfigInvalidException, IOException, OrmDuplicateKeyException { + throws ConfigInvalidException, IOException, DuplicateKeyException { // This method is only executed on a new server which doesn't have any accounts or groups. AuditLogFormatter auditLogFormatter = AuditLogFormatter.createBackedBy(ImmutableSet.of(), ImmutableSet.of(), serverId); @@ -217,7 +217,7 @@ public class SchemaCreatorImpl implements SchemaCreator { } private InternalGroupCreation getGroupCreation(Sequences seqs, GroupReference groupReference) - throws OrmException { + throws StorageException { int next = seqs.nextGroupId(); return InternalGroupCreation.builder() .setNameKey(new AccountGroup.NameKey(groupReference.getName())) diff --git a/java/com/google/gerrit/server/submit/ChangeSet.java b/java/com/google/gerrit/server/submit/ChangeSet.java index 422e1b9c02..dcab2e9d3d 100644 --- a/java/com/google/gerrit/server/submit/ChangeSet.java +++ b/java/com/google/gerrit/server/submit/ChangeSet.java @@ -20,11 +20,11 @@ import com.google.common.collect.ImmutableMap; import com.google.common.collect.ImmutableSet; import com.google.common.collect.ListMultimap; import com.google.common.collect.MultimapBuilder; +import com.google.gerrit.exceptions.StorageException; import com.google.gerrit.reviewdb.client.Branch; import com.google.gerrit.reviewdb.client.Change; import com.google.gerrit.reviewdb.client.Project; import com.google.gerrit.server.query.change.ChangeData; -import com.google.gwtorm.server.OrmException; import java.util.Collection; import java.util.LinkedHashMap; import java.util.Map; @@ -77,7 +77,7 @@ public class ChangeSet { return changeData; } - public ListMultimap changesByBranch() throws OrmException { + public ListMultimap changesByBranch() throws StorageException { ListMultimap ret = MultimapBuilder.hashKeys().arrayListValues().build(); for (ChangeData cd : changeData.values()) { diff --git a/java/com/google/gerrit/server/submit/CherryPick.java b/java/com/google/gerrit/server/submit/CherryPick.java index f50525ce68..0c4dcc16d0 100644 --- a/java/com/google/gerrit/server/submit/CherryPick.java +++ b/java/com/google/gerrit/server/submit/CherryPick.java @@ -19,6 +19,7 @@ import static com.google.gerrit.server.submit.CommitMergeStatus.SKIPPED_IDENTICA import static java.util.Objects.requireNonNull; import com.google.common.collect.ImmutableList; +import com.google.gerrit.exceptions.StorageException; import com.google.gerrit.extensions.restapi.MergeConflictException; import com.google.gerrit.extensions.restapi.MethodNotAllowedException; import com.google.gerrit.reviewdb.client.BooleanProjectConfig; @@ -30,7 +31,6 @@ import com.google.gerrit.server.git.MergeTip; import com.google.gerrit.server.project.NoSuchChangeException; import com.google.gerrit.server.update.ChangeContext; import com.google.gerrit.server.update.RepoContext; -import com.google.gwtorm.server.OrmException; import java.io.IOException; import java.util.ArrayList; import java.util.Collection; @@ -91,7 +91,7 @@ public class CherryPick extends SubmitStrategy { @Override protected void updateRepoImpl(RepoContext ctx) - throws IntegrationException, IOException, OrmException, MethodNotAllowedException { + throws IntegrationException, IOException, StorageException, MethodNotAllowedException { // If there is only one parent, a cherry-pick can be done by taking the // delta relative to that one parent and redoing that on the current merge // tip. @@ -147,7 +147,7 @@ public class CherryPick extends SubmitStrategy { @Override public PatchSet updateChangeImpl(ChangeContext ctx) - throws OrmException, NoSuchChangeException, IOException { + throws StorageException, NoSuchChangeException, IOException { if (newCommit == null && toMerge.getStatusCode() == SKIPPED_IDENTICAL_TREE) { return null; } diff --git a/java/com/google/gerrit/server/submit/CommitMergeStatus.java b/java/com/google/gerrit/server/submit/CommitMergeStatus.java index 5ac7c98d27..5189583305 100644 --- a/java/com/google/gerrit/server/submit/CommitMergeStatus.java +++ b/java/com/google/gerrit/server/submit/CommitMergeStatus.java @@ -17,11 +17,11 @@ package com.google.gerrit.server.submit; import static java.util.stream.Collectors.toSet; import com.google.gerrit.common.Nullable; +import com.google.gerrit.exceptions.StorageException; import com.google.gerrit.reviewdb.client.PatchSet; import com.google.gerrit.server.CurrentUser; import com.google.gerrit.server.query.change.ChangeData; import com.google.gerrit.server.query.change.InternalChangeQuery; -import com.google.gwtorm.server.OrmException; import com.google.inject.Provider; import java.util.List; import java.util.Optional; @@ -94,7 +94,7 @@ public enum CommitMergeStatus { Provider queryProvider, String commit, String otherCommit) - throws OrmException { + throws StorageException { List changes = queryProvider.get().enforceVisibility(true).byCommit(otherCommit); if (changes.isEmpty()) { diff --git a/java/com/google/gerrit/server/submit/LocalMergeSuperSetComputation.java b/java/com/google/gerrit/server/submit/LocalMergeSuperSetComputation.java index 832c387979..e0033ebed2 100644 --- a/java/com/google/gerrit/server/submit/LocalMergeSuperSetComputation.java +++ b/java/com/google/gerrit/server/submit/LocalMergeSuperSetComputation.java @@ -23,6 +23,7 @@ import com.google.common.collect.ImmutableSet; import com.google.common.collect.Iterables; import com.google.common.flogger.FluentLogger; import com.google.gerrit.common.data.SubmitTypeRecord; +import com.google.gerrit.exceptions.StorageException; import com.google.gerrit.extensions.client.SubmitType; import com.google.gerrit.extensions.registration.DynamicItem; import com.google.gerrit.extensions.restapi.AuthException; @@ -39,7 +40,6 @@ import com.google.gerrit.server.query.change.ChangeData; import com.google.gerrit.server.query.change.ChangeIsVisibleToPredicate; import com.google.gerrit.server.query.change.InternalChangeQuery; import com.google.gerrit.server.submit.MergeOpRepoManager.OpenRepo; -import com.google.gwtorm.server.OrmException; import com.google.inject.AbstractModule; import com.google.inject.Inject; import com.google.inject.Provider; @@ -109,7 +109,7 @@ public class LocalMergeSuperSetComputation implements MergeSuperSetComputation { @Override public ChangeSet completeWithoutTopic( MergeOpRepoManager orm, ChangeSet changeSet, CurrentUser user) - throws OrmException, IOException, PermissionBackendException { + throws StorageException, IOException, PermissionBackendException { Collection visibleChanges = new ArrayList<>(); Collection nonVisibleChanges = new ArrayList<>(); @@ -161,7 +161,7 @@ public class LocalMergeSuperSetComputation implements MergeSuperSetComputation { } private static ImmutableListMultimap byBranch( - Iterable changes) throws OrmException { + Iterable changes) throws StorageException { ImmutableListMultimap.Builder builder = ImmutableListMultimap.builder(); for (ChangeData cd : changes) { @@ -202,7 +202,7 @@ public class LocalMergeSuperSetComputation implements MergeSuperSetComputation { } } - private SubmitType submitType(ChangeData cd) throws OrmException { + private SubmitType submitType(ChangeData cd) throws StorageException { SubmitTypeRecord str = cd.submitTypeRecord(); if (!str.isOk()) { logErrorAndThrow("Failed to get submit type for " + cd.getId() + ": " + str.errorMessage); @@ -212,7 +212,7 @@ public class LocalMergeSuperSetComputation implements MergeSuperSetComputation { private ChangeSet byCommitsOnBranchNotMerged( OpenRepo or, Branch.NameKey branch, Set visibleHashes, Set nonVisibleHashes) - throws OrmException, IOException { + throws StorageException, IOException { List potentiallyVisibleChanges = byCommitsOnBranchNotMerged(or, branch, visibleHashes); List invisibleChanges = @@ -229,7 +229,7 @@ public class LocalMergeSuperSetComputation implements MergeSuperSetComputation { } private ImmutableList byCommitsOnBranchNotMerged( - OpenRepo or, Branch.NameKey branch, Set hashes) throws OrmException, IOException { + OpenRepo or, Branch.NameKey branch, Set hashes) throws StorageException, IOException { if (hashes.isEmpty()) { return ImmutableList.of(); } @@ -281,8 +281,8 @@ public class LocalMergeSuperSetComputation implements MergeSuperSetComputation { } } - private void logErrorAndThrow(String msg) throws OrmException { + private void logErrorAndThrow(String msg) throws StorageException { logger.atSevere().log(msg); - throw new OrmException(msg); + throw new StorageException(msg); } } diff --git a/java/com/google/gerrit/server/submit/MergeOp.java b/java/com/google/gerrit/server/submit/MergeOp.java index 8b93ce8a4e..ef14dfc1a5 100644 --- a/java/com/google/gerrit/server/submit/MergeOp.java +++ b/java/com/google/gerrit/server/submit/MergeOp.java @@ -36,6 +36,7 @@ import com.google.gerrit.common.Nullable; import com.google.gerrit.common.data.SubmitRecord; import com.google.gerrit.common.data.SubmitRequirement; import com.google.gerrit.common.data.SubmitTypeRecord; +import com.google.gerrit.exceptions.StorageException; import com.google.gerrit.extensions.api.changes.NotifyHandling; import com.google.gerrit.extensions.api.changes.SubmitInput; import com.google.gerrit.extensions.client.SubmitType; @@ -78,7 +79,6 @@ import com.google.gerrit.server.update.RetryHelper; import com.google.gerrit.server.update.RetryHelper.ActionType; import com.google.gerrit.server.update.UpdateException; import com.google.gerrit.server.util.time.TimeUtil; -import com.google.gwtorm.server.OrmException; import com.google.inject.Inject; import com.google.inject.Provider; import com.google.inject.Singleton; @@ -124,7 +124,7 @@ public class MergeOp implements AutoCloseable { private final ListMultimap problems; private final boolean allowClosed; - private CommitStatus(ChangeSet cs, boolean allowClosed) throws OrmException { + private CommitStatus(ChangeSet cs, boolean allowClosed) throws StorageException { checkArgument( !cs.furtherHiddenChanges(), "CommitStatus must not be called with hidden changes"); changes = cs.changesById(); @@ -283,7 +283,7 @@ public class MergeOp implements AutoCloseable { } public static void checkSubmitRule(ChangeData cd, boolean allowClosed) - throws ResourceConflictException, OrmException { + throws ResourceConflictException, StorageException { PatchSet patchSet = cd.currentPatchSet(); if (patchSet == null) { throw new ResourceConflictException("missing current patch set for change " + cd.getId()); @@ -332,7 +332,8 @@ public class MergeOp implements AutoCloseable { return cd.submitRecords(submitRuleOptions(allowClosed)); } - private static String describeNotReady(ChangeData cd, SubmitRecord record) throws OrmException { + private static String describeNotReady(ChangeData cd, SubmitRecord record) + throws StorageException { List blockingConditions = new ArrayList<>(); if (record.labels != null) { blockingConditions.add(describeLabels(cd, record.labels)); @@ -346,7 +347,7 @@ public class MergeOp implements AutoCloseable { } private static String describeLabels(ChangeData cd, List labels) - throws OrmException { + throws StorageException { List labelResults = new ArrayList<>(); for (SubmitRecord.Label lbl : labels) { switch (lbl.status) { @@ -394,7 +395,7 @@ public class MergeOp implements AutoCloseable { } } catch (ResourceConflictException e) { commitStatus.problem(cd.getId(), e.getMessage()); - } catch (OrmException e) { + } catch (StorageException e) { String msg = "Error checking submit rules for change"; logger.atWarning().withCause(e).log("%s %s", msg, cd.getId()); commitStatus.problem(cd.getId(), msg); @@ -426,7 +427,7 @@ public class MergeOp implements AutoCloseable { * @param caller the identity of the caller * @param checkSubmitRules whether the prolog submit rules should be evaluated * @param submitInput parameters regarding the merge - * @throws OrmException an error occurred reading or writing the database. + * @throws StorageException an error occurred reading or writing the database. * @throws RestApiException if an error occurred. * @throws PermissionBackendException if permissions can't be checked * @throws IOException an error occurred reading from NoteDb. @@ -437,8 +438,8 @@ public class MergeOp implements AutoCloseable { boolean checkSubmitRules, SubmitInput submitInput, boolean dryrun) - throws OrmException, RestApiException, UpdateException, IOException, ConfigInvalidException, - PermissionBackendException { + throws StorageException, RestApiException, UpdateException, IOException, + ConfigInvalidException, PermissionBackendException { this.submitInput = submitInput; this.notify = notifyResolver.resolve( @@ -520,7 +521,7 @@ public class MergeOp implements AutoCloseable { } } catch (IOException e) { // Anything before the merge attempt is an error - throw new OrmException(e); + throw new StorageException(e); } } } @@ -580,7 +581,7 @@ public class MergeOp implements AutoCloseable { ListMultimap cbb; try { cbb = cs.changesByBranch(); - } catch (OrmException e) { + } catch (StorageException e) { throw new IntegrationException("Error reading changes to submit", e); } Set branches = cbb.keySet(); @@ -742,7 +743,7 @@ public class MergeOp implements AutoCloseable { notes = cd.notes(); chg = cd.change(); st = getSubmitType(cd); - } catch (OrmException e) { + } catch (StorageException e) { commitStatus.logProblem(changeId, e); continue; } @@ -774,7 +775,7 @@ public class MergeOp implements AutoCloseable { Branch.NameKey destBranch = chg.getDest(); try { ps = cd.currentPatchSet(); - } catch (OrmException e) { + } catch (StorageException e) { commitStatus.logProblem(changeId, e); continue; } @@ -870,7 +871,7 @@ public class MergeOp implements AutoCloseable { revisions.put(e.getValue().getObjectId(), PatchSet.Id.fromRef(e.getKey())); } return revisions; - } catch (IOException | OrmException e) { + } catch (IOException | StorageException e) { throw new IntegrationException("Failed to validate changes", e); } } @@ -929,7 +930,7 @@ public class MergeOp implements AutoCloseable { } } } - } catch (OrmException e) { + } catch (StorageException e) { logger.atWarning().withCause(e).log( "Cannot abandon changes for deleted project %s", destProject); } diff --git a/java/com/google/gerrit/server/submit/MergeSorter.java b/java/com/google/gerrit/server/submit/MergeSorter.java index dbdb0b4646..bf2f1e9a71 100644 --- a/java/com/google/gerrit/server/submit/MergeSorter.java +++ b/java/com/google/gerrit/server/submit/MergeSorter.java @@ -15,11 +15,11 @@ package com.google.gerrit.server.submit; import com.google.gerrit.common.Nullable; +import com.google.gerrit.exceptions.StorageException; import com.google.gerrit.server.CurrentUser; import com.google.gerrit.server.git.CodeReviewCommit; import com.google.gerrit.server.git.CodeReviewCommit.CodeReviewRevWalk; import com.google.gerrit.server.query.change.InternalChangeQuery; -import com.google.gwtorm.server.OrmException; import com.google.inject.Provider; import java.io.IOException; import java.util.Collection; @@ -54,7 +54,7 @@ public class MergeSorter { } public Collection sort(Collection toMerge) - throws IOException, OrmException { + throws IOException, StorageException { final Set heads = new HashSet<>(); final Set sort = new HashSet<>(toMerge); while (!sort.isEmpty()) { diff --git a/java/com/google/gerrit/server/submit/MergeSuperSet.java b/java/com/google/gerrit/server/submit/MergeSuperSet.java index 87ce6d4d0e..a828be7322 100644 --- a/java/com/google/gerrit/server/submit/MergeSuperSet.java +++ b/java/com/google/gerrit/server/submit/MergeSuperSet.java @@ -19,6 +19,7 @@ import static java.util.Objects.requireNonNull; import com.google.common.base.Strings; import com.google.common.collect.Iterables; +import com.google.gerrit.exceptions.StorageException; import com.google.gerrit.extensions.registration.DynamicItem; import com.google.gerrit.extensions.restapi.AuthException; import com.google.gerrit.reviewdb.client.Change; @@ -33,7 +34,6 @@ import com.google.gerrit.server.project.ProjectCache; import com.google.gerrit.server.project.ProjectState; import com.google.gerrit.server.query.change.ChangeData; import com.google.gerrit.server.query.change.InternalChangeQuery; -import com.google.gwtorm.server.OrmException; import com.google.inject.Inject; import com.google.inject.Provider; import java.io.IOException; @@ -93,7 +93,7 @@ public class MergeSuperSet { } public ChangeSet completeChangeSet(Change change, CurrentUser user) - throws IOException, OrmException, PermissionBackendException { + throws IOException, StorageException, PermissionBackendException { try { if (orm == null) { orm = repoManagerProvider.get(); @@ -146,7 +146,7 @@ public class MergeSuperSet { */ private ChangeSet topicClosure( ChangeSet changeSet, CurrentUser user, Set topicsSeen, Set visibleTopicsSeen) - throws OrmException, PermissionBackendException, IOException { + throws StorageException, PermissionBackendException, IOException { List visibleChanges = new ArrayList<>(); List nonVisibleChanges = new ArrayList<>(); @@ -181,7 +181,7 @@ public class MergeSuperSet { } private ChangeSet completeChangeSetIncludingTopics(ChangeSet changeSet, CurrentUser user) - throws IOException, OrmException, PermissionBackendException { + throws IOException, StorageException, PermissionBackendException { Set topicsSeen = new HashSet<>(); Set visibleTopicsSeen = new HashSet<>(); int oldSeen; @@ -201,7 +201,7 @@ public class MergeSuperSet { return changeSet; } - private List byTopicOpen(String topic) throws OrmException { + private List byTopicOpen(String topic) throws StorageException { return queryProvider.get().byTopicOpen(topic); } diff --git a/java/com/google/gerrit/server/submit/MergeSuperSetComputation.java b/java/com/google/gerrit/server/submit/MergeSuperSetComputation.java index a487c95c9b..39ac429db7 100644 --- a/java/com/google/gerrit/server/submit/MergeSuperSetComputation.java +++ b/java/com/google/gerrit/server/submit/MergeSuperSetComputation.java @@ -14,10 +14,10 @@ package com.google.gerrit.server.submit; +import com.google.gerrit.exceptions.StorageException; import com.google.gerrit.extensions.annotations.ExtensionPoint; import com.google.gerrit.server.CurrentUser; import com.google.gerrit.server.permissions.PermissionBackendException; -import com.google.gwtorm.server.OrmException; import java.io.IOException; /** @@ -46,5 +46,5 @@ public interface MergeSuperSetComputation { * @return the completed set of changes that should be submitted together */ ChangeSet completeWithoutTopic(MergeOpRepoManager orm, ChangeSet changeSet, CurrentUser user) - throws OrmException, IOException, PermissionBackendException; + throws StorageException, IOException, PermissionBackendException; } diff --git a/java/com/google/gerrit/server/submit/RebaseSorter.java b/java/com/google/gerrit/server/submit/RebaseSorter.java index ccb08daefd..d668f872f4 100644 --- a/java/com/google/gerrit/server/submit/RebaseSorter.java +++ b/java/com/google/gerrit/server/submit/RebaseSorter.java @@ -15,13 +15,13 @@ package com.google.gerrit.server.submit; import com.google.common.flogger.FluentLogger; +import com.google.gerrit.exceptions.StorageException; import com.google.gerrit.reviewdb.client.Branch; import com.google.gerrit.server.CurrentUser; import com.google.gerrit.server.git.CodeReviewCommit; import com.google.gerrit.server.git.CodeReviewCommit.CodeReviewRevWalk; import com.google.gerrit.server.query.change.ChangeData; import com.google.gerrit.server.query.change.InternalChangeQuery; -import com.google.gwtorm.server.OrmException; import com.google.inject.Provider; import java.io.IOException; import java.util.ArrayList; @@ -63,7 +63,7 @@ public class RebaseSorter { } public List sort(Collection toSort) - throws IOException, OrmException { + throws IOException, StorageException { final List sorted = new ArrayList<>(); final Set sort = new HashSet<>(toSort); while (!sort.isEmpty()) { @@ -132,7 +132,7 @@ public class RebaseSorter { } } return false; - } catch (OrmException e) { + } catch (StorageException e) { throw new IOException(e); } } diff --git a/java/com/google/gerrit/server/submit/RebaseSubmitStrategy.java b/java/com/google/gerrit/server/submit/RebaseSubmitStrategy.java index 8abef0363c..a7c5c98687 100644 --- a/java/com/google/gerrit/server/submit/RebaseSubmitStrategy.java +++ b/java/com/google/gerrit/server/submit/RebaseSubmitStrategy.java @@ -19,6 +19,7 @@ import static com.google.gerrit.server.submit.CommitMergeStatus.EMPTY_COMMIT; import static com.google.gerrit.server.submit.CommitMergeStatus.SKIPPED_IDENTICAL_TREE; import com.google.common.collect.ImmutableList; +import com.google.gerrit.exceptions.StorageException; import com.google.gerrit.extensions.restapi.MergeConflictException; import com.google.gerrit.extensions.restapi.ResourceConflictException; import com.google.gerrit.extensions.restapi.RestApiException; @@ -34,7 +35,6 @@ import com.google.gerrit.server.project.NoSuchChangeException; import com.google.gerrit.server.update.ChangeContext; import com.google.gerrit.server.update.Context; import com.google.gerrit.server.update.RepoContext; -import com.google.gwtorm.server.OrmException; import java.io.IOException; import java.util.ArrayList; import java.util.Collection; @@ -59,7 +59,7 @@ public class RebaseSubmitStrategy extends SubmitStrategy { List sorted; try { sorted = args.rebaseSorter.sort(toMerge); - } catch (IOException | OrmException e) { + } catch (IOException | StorageException e) { throw new IntegrationException("Commit sorting failed", e); } List ops = new ArrayList<>(sorted.size()); @@ -119,7 +119,7 @@ public class RebaseSubmitStrategy extends SubmitStrategy { @Override public void updateRepoImpl(RepoContext ctx) throws IntegrationException, InvalidChangeOperationException, RestApiException, IOException, - OrmException, PermissionBackendException { + StorageException, PermissionBackendException { if (args.mergeUtil.canFastForward( args.mergeSorter, args.mergeTip.getCurrentTip(), args.rw, toMerge)) { if (!rebaseAlways) { @@ -214,7 +214,7 @@ public class RebaseSubmitStrategy extends SubmitStrategy { @Override public PatchSet updateChangeImpl(ChangeContext ctx) - throws NoSuchChangeException, ResourceConflictException, OrmException, IOException { + throws NoSuchChangeException, ResourceConflictException, StorageException, IOException { if (newCommit == null) { checkState(!rebaseAlways, "RebaseAlways must never fast forward"); // otherwise, took the fast-forward option, nothing to do. @@ -246,7 +246,7 @@ public class RebaseSubmitStrategy extends SubmitStrategy { } @Override - public void postUpdateImpl(Context ctx) throws OrmException { + public void postUpdateImpl(Context ctx) throws StorageException { if (rebaseOp != null) { rebaseOp.postUpdate(ctx); } diff --git a/java/com/google/gerrit/server/submit/SubmitStrategyOp.java b/java/com/google/gerrit/server/submit/SubmitStrategyOp.java index 1cc0db53e4..4bcda8ba2c 100644 --- a/java/com/google/gerrit/server/submit/SubmitStrategyOp.java +++ b/java/com/google/gerrit/server/submit/SubmitStrategyOp.java @@ -23,6 +23,7 @@ import static java.util.Objects.requireNonNull; import com.google.common.base.Function; import com.google.common.flogger.FluentLogger; import com.google.gerrit.common.data.SubmitRecord; +import com.google.gerrit.exceptions.StorageException; import com.google.gerrit.reviewdb.client.Account; import com.google.gerrit.reviewdb.client.Branch; import com.google.gerrit.reviewdb.client.Change; @@ -48,7 +49,6 @@ import com.google.gerrit.server.update.BatchUpdateOp; import com.google.gerrit.server.update.ChangeContext; import com.google.gerrit.server.update.Context; import com.google.gerrit.server.update.RepoContext; -import com.google.gwtorm.server.OrmException; import java.io.IOException; import java.util.ArrayList; import java.util.HashMap; @@ -283,7 +283,7 @@ abstract class SubmitStrategyOp implements BatchUpdateOp { : alreadyMergedCommit; try { setMerged(ctx, message(ctx, commit, s)); - } catch (OrmException err) { + } catch (StorageException err) { String msg = "Error updating change status for " + id; logger.atSevere().withCause(err).log(msg); args.commitStatus.logProblem(id, msg); @@ -295,7 +295,7 @@ abstract class SubmitStrategyOp implements BatchUpdateOp { } private PatchSet getOrCreateAlreadyMergedPatchSet(ChangeContext ctx) - throws IOException, OrmException { + throws IOException, StorageException { PatchSet.Id psId = alreadyMergedCommit.getPatchsetId(); logger.atFine().log("Fixing up already-merged patch set %s", psId); PatchSet prevPs = args.psUtil.current(ctx.getNotes()); @@ -318,7 +318,7 @@ abstract class SubmitStrategyOp implements BatchUpdateOp { } private void setApproval(ChangeContext ctx, IdentifiedUser user) - throws OrmException, IOException { + throws StorageException, IOException { Change.Id id = ctx.getChange().getId(); List records = args.commitStatus.getSubmitRecords(id); PatchSet.Id oldPsId = toMerge.getPatchsetId(); @@ -340,7 +340,7 @@ abstract class SubmitStrategyOp implements BatchUpdateOp { } private LabelNormalizer.Result approve(ChangeContext ctx, ChangeUpdate update) - throws OrmException, IOException { + throws StorageException, IOException { PatchSet.Id psId = update.getPatchSetId(); Map byKey = new HashMap<>(); for (PatchSetApproval psa : @@ -405,7 +405,7 @@ abstract class SubmitStrategyOp implements BatchUpdateOp { } private ChangeMessage message(ChangeContext ctx, CodeReviewCommit commit, CommitMergeStatus s) - throws OrmException { + throws StorageException { requireNonNull(s, "CommitMergeStatus may not be null"); String txt = s.getDescription(); if (s == CommitMergeStatus.CLEAN_MERGE) { diff --git a/java/com/google/gerrit/server/update/BatchUpdate.java b/java/com/google/gerrit/server/update/BatchUpdate.java index 27a6aeec64..0553894dce 100644 --- a/java/com/google/gerrit/server/update/BatchUpdate.java +++ b/java/com/google/gerrit/server/update/BatchUpdate.java @@ -30,6 +30,7 @@ import com.google.common.collect.MultimapBuilder; import com.google.common.collect.Multiset; import com.google.common.flogger.FluentLogger; 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.config.FactoryModule; import com.google.gerrit.extensions.restapi.ResourceConflictException; @@ -54,7 +55,6 @@ import com.google.gerrit.server.project.InvalidChangeOperationException; import com.google.gerrit.server.project.NoSuchChangeException; import com.google.gerrit.server.project.NoSuchProjectException; import com.google.gerrit.server.project.NoSuchRefException; -import com.google.gwtorm.server.OrmException; import com.google.inject.Inject; import com.google.inject.Module; import com.google.inject.assistedinject.Assisted; @@ -500,7 +500,7 @@ public class BatchUpdate implements AutoCloseable { checkArgument(old == null, "result for change %s already set: %s", id, old); } - void execute() throws OrmException, IOException { + void execute() throws StorageException, IOException { BatchUpdate.this.batchRefUpdate = manager.execute(dryrun); } @@ -583,7 +583,7 @@ public class BatchUpdate implements AutoCloseable { return handle; } - private ChangeContextImpl newChangeContext(Change.Id id) throws OrmException { + private ChangeContextImpl newChangeContext(Change.Id id) throws StorageException { logDebug("Opening change %s for update", id); Change c = newChanges.get(id); boolean isNew = c != null; diff --git a/java/com/google/gerrit/sshd/AbstractGitCommand.java b/java/com/google/gerrit/sshd/AbstractGitCommand.java index d726ef6b0d..ccfbcf8837 100644 --- a/java/com/google/gerrit/sshd/AbstractGitCommand.java +++ b/java/com/google/gerrit/sshd/AbstractGitCommand.java @@ -14,6 +14,7 @@ package com.google.gerrit.sshd; +import com.google.gerrit.exceptions.StorageException; import com.google.gerrit.reviewdb.client.Project; import com.google.gerrit.server.AccessPath; import com.google.gerrit.server.IdentifiedUser; @@ -21,7 +22,6 @@ import com.google.gerrit.server.git.GitRepositoryManager; import com.google.gerrit.server.permissions.PermissionBackendException; import com.google.gerrit.server.project.ProjectState; import com.google.gerrit.sshd.SshScope.Context; -import com.google.gwtorm.server.OrmException; import com.google.inject.Inject; import java.io.IOException; import org.apache.sshd.server.Environment; @@ -85,7 +85,7 @@ public abstract class AbstractGitCommand extends BaseCommand { return n; } - private void service() throws IOException, OrmException, PermissionBackendException, Failure { + private void service() throws IOException, StorageException, PermissionBackendException, Failure { project = projectState.getProject(); projectName = project.getNameKey(); @@ -103,5 +103,5 @@ public abstract class AbstractGitCommand extends BaseCommand { } protected abstract void runImpl() - throws IOException, OrmException, PermissionBackendException, Failure; + throws IOException, StorageException, PermissionBackendException, Failure; } diff --git a/java/com/google/gerrit/sshd/BUILD b/java/com/google/gerrit/sshd/BUILD index 537d849d1b..42ef7d5b76 100644 --- a/java/com/google/gerrit/sshd/BUILD +++ b/java/com/google/gerrit/sshd/BUILD @@ -22,7 +22,6 @@ java_library( "//java/com/google/gerrit/server/schema", "//java/com/google/gerrit/server/util/time", "//java/com/google/gerrit/util/cli", - "//java/com/google/gwtorm", "//lib:args4j", "//lib:gson", "//lib:guava", diff --git a/java/com/google/gerrit/sshd/ChangeArgumentParser.java b/java/com/google/gerrit/sshd/ChangeArgumentParser.java index c8586f2595..00a37a6a8b 100644 --- a/java/com/google/gerrit/sshd/ChangeArgumentParser.java +++ b/java/com/google/gerrit/sshd/ChangeArgumentParser.java @@ -14,6 +14,7 @@ package com.google.gerrit.sshd; +import com.google.gerrit.exceptions.StorageException; import com.google.gerrit.extensions.restapi.AuthException; import com.google.gerrit.extensions.restapi.RestApiException; import com.google.gerrit.reviewdb.client.Change; @@ -28,7 +29,6 @@ import com.google.gerrit.server.permissions.PermissionBackendException; import com.google.gerrit.server.project.ProjectState; import com.google.gerrit.server.restapi.change.ChangesCollection; import com.google.gerrit.sshd.BaseCommand.UnloggedFailure; -import com.google.gwtorm.server.OrmException; import com.google.inject.Inject; import java.io.IOException; import java.util.ArrayList; @@ -55,13 +55,13 @@ public class ChangeArgumentParser { } public void addChange(String id, Map changes) - throws UnloggedFailure, OrmException, PermissionBackendException, IOException { + throws UnloggedFailure, StorageException, PermissionBackendException, IOException { addChange(id, changes, null); } public void addChange( String id, Map changes, ProjectState projectState) - throws UnloggedFailure, OrmException, PermissionBackendException, IOException { + throws UnloggedFailure, StorageException, PermissionBackendException, IOException { addChange(id, changes, projectState, true); } @@ -70,7 +70,7 @@ public class ChangeArgumentParser { Map changes, ProjectState projectState, boolean useIndex) - throws UnloggedFailure, OrmException, PermissionBackendException, IOException { + throws UnloggedFailure, StorageException, PermissionBackendException, IOException { List matched = useIndex ? changeFinder.find(id) : changeFromNotesFactory(id); List toAdd = new ArrayList<>(changes.size()); boolean canMaintainServer; @@ -116,7 +116,8 @@ public class ChangeArgumentParser { changes.put(cId, changeResource); } - private List changeFromNotesFactory(String id) throws OrmException, UnloggedFailure { + private List changeFromNotesFactory(String id) + throws StorageException, UnloggedFailure { return changeNotesFactory.create(parseId(id)); } diff --git a/java/com/google/gerrit/sshd/commands/CreateAccountCommand.java b/java/com/google/gerrit/sshd/commands/CreateAccountCommand.java index 8a37cce803..df89f69f2f 100644 --- a/java/com/google/gerrit/sshd/commands/CreateAccountCommand.java +++ b/java/com/google/gerrit/sshd/commands/CreateAccountCommand.java @@ -18,6 +18,7 @@ import static java.nio.charset.StandardCharsets.UTF_8; import com.google.common.collect.Lists; import com.google.gerrit.common.data.GlobalCapability; +import com.google.gerrit.exceptions.StorageException; import com.google.gerrit.extensions.annotations.RequiresCapability; import com.google.gerrit.extensions.api.accounts.AccountInput; import com.google.gerrit.extensions.restapi.IdString; @@ -28,7 +29,6 @@ import com.google.gerrit.server.permissions.PermissionBackendException; import com.google.gerrit.server.restapi.account.CreateAccount; import com.google.gerrit.sshd.CommandMetaData; import com.google.gerrit.sshd.SshCommand; -import com.google.gwtorm.server.OrmException; import com.google.inject.Inject; import java.io.BufferedReader; import java.io.IOException; @@ -72,7 +72,7 @@ final class CreateAccountCommand extends SshCommand { @Override protected void run() - throws OrmException, IOException, ConfigInvalidException, UnloggedFailure, + throws StorageException, IOException, ConfigInvalidException, UnloggedFailure, PermissionBackendException { AccountInput input = new AccountInput(); input.username = username; diff --git a/java/com/google/gerrit/sshd/commands/CreateGroupCommand.java b/java/com/google/gerrit/sshd/commands/CreateGroupCommand.java index 917c138c80..d589be4a9b 100644 --- a/java/com/google/gerrit/sshd/commands/CreateGroupCommand.java +++ b/java/com/google/gerrit/sshd/commands/CreateGroupCommand.java @@ -17,6 +17,7 @@ package com.google.gerrit.sshd.commands; import static java.util.stream.Collectors.toList; import com.google.gerrit.common.data.GlobalCapability; +import com.google.gerrit.exceptions.StorageException; import com.google.gerrit.extensions.annotations.RequiresCapability; import com.google.gerrit.extensions.api.groups.GroupInput; import com.google.gerrit.extensions.common.GroupInfo; @@ -33,7 +34,6 @@ import com.google.gerrit.server.restapi.group.CreateGroup; import com.google.gerrit.server.restapi.group.GroupsCollection; import com.google.gerrit.sshd.CommandMetaData; import com.google.gerrit.sshd.SshCommand; -import com.google.gwtorm.server.OrmException; import com.google.inject.Inject; import java.io.IOException; import java.util.HashSet; @@ -102,7 +102,7 @@ final class CreateGroupCommand extends SshCommand { @Override protected void run() - throws Failure, OrmException, IOException, ConfigInvalidException, + throws Failure, StorageException, IOException, ConfigInvalidException, PermissionBackendException { try { GroupResource rsrc = createGroup(); @@ -120,7 +120,7 @@ final class CreateGroupCommand extends SshCommand { } private GroupResource createGroup() - throws RestApiException, OrmException, IOException, ConfigInvalidException, + throws RestApiException, StorageException, IOException, ConfigInvalidException, PermissionBackendException { GroupInput input = new GroupInput(); input.description = groupDescription; @@ -136,7 +136,7 @@ final class CreateGroupCommand extends SshCommand { } private void addMembers(GroupResource rsrc) - throws RestApiException, OrmException, IOException, ConfigInvalidException, + throws RestApiException, StorageException, IOException, ConfigInvalidException, PermissionBackendException { AddMembers.Input input = AddMembers.Input.fromMembers( @@ -145,7 +145,7 @@ final class CreateGroupCommand extends SshCommand { } private void addSubgroups(GroupResource rsrc) - throws RestApiException, OrmException, IOException, ConfigInvalidException, + throws RestApiException, StorageException, IOException, ConfigInvalidException, PermissionBackendException { AddSubgroups.Input input = AddSubgroups.Input.fromGroups( diff --git a/java/com/google/gerrit/sshd/commands/IndexChangesCommand.java b/java/com/google/gerrit/sshd/commands/IndexChangesCommand.java index fad74f54a9..5aa2ec814d 100644 --- a/java/com/google/gerrit/sshd/commands/IndexChangesCommand.java +++ b/java/com/google/gerrit/sshd/commands/IndexChangesCommand.java @@ -14,6 +14,7 @@ package com.google.gerrit.sshd.commands; +import com.google.gerrit.exceptions.StorageException; import com.google.gerrit.extensions.common.Input; import com.google.gerrit.reviewdb.client.Change; import com.google.gerrit.server.change.ChangeResource; @@ -22,7 +23,6 @@ import com.google.gerrit.server.restapi.change.Index; import com.google.gerrit.sshd.ChangeArgumentParser; import com.google.gerrit.sshd.CommandMetaData; import com.google.gerrit.sshd.SshCommand; -import com.google.gwtorm.server.OrmException; import com.google.inject.Inject; import java.io.IOException; import java.util.LinkedHashMap; @@ -44,7 +44,7 @@ final class IndexChangesCommand extends SshCommand { void addChange(String token) { try { changeArgumentParser.addChange(token, changes, null, false); - } catch (UnloggedFailure | OrmException | PermissionBackendException | IOException e) { + } catch (UnloggedFailure | StorageException | PermissionBackendException | IOException e) { writeError("warning", e.getMessage()); } } diff --git a/java/com/google/gerrit/sshd/commands/LsUserRefs.java b/java/com/google/gerrit/sshd/commands/LsUserRefs.java index 3d9ef56501..1f991e0224 100644 --- a/java/com/google/gerrit/sshd/commands/LsUserRefs.java +++ b/java/com/google/gerrit/sshd/commands/LsUserRefs.java @@ -17,6 +17,7 @@ package com.google.gerrit.sshd.commands; import static com.google.gerrit.sshd.CommandMetaData.Mode.MASTER_OR_SLAVE; import com.google.gerrit.common.data.GlobalCapability; +import com.google.gerrit.exceptions.StorageException; import com.google.gerrit.extensions.annotations.RequiresCapability; import com.google.gerrit.extensions.restapi.UnprocessableEntityException; import com.google.gerrit.reviewdb.client.Account; @@ -32,7 +33,6 @@ import com.google.gerrit.server.util.ManualRequestContext; import com.google.gerrit.server.util.OneOffRequestContext; import com.google.gerrit.sshd.CommandMetaData; import com.google.gerrit.sshd.SshCommand; -import com.google.gwtorm.server.OrmException; import com.google.inject.Inject; import java.io.IOException; import java.util.Map; @@ -81,7 +81,7 @@ public class LsUserRefs extends SshCommand { stdout.println(e.getMessage()); stdout.flush(); return; - } catch (OrmException | IOException | ConfigInvalidException e) { + } catch (StorageException | IOException | ConfigInvalidException e) { throw die(e); } diff --git a/java/com/google/gerrit/sshd/commands/PatchSetParser.java b/java/com/google/gerrit/sshd/commands/PatchSetParser.java index d174561d83..8950d817be 100644 --- a/java/com/google/gerrit/sshd/commands/PatchSetParser.java +++ b/java/com/google/gerrit/sshd/commands/PatchSetParser.java @@ -15,6 +15,7 @@ package com.google.gerrit.sshd.commands; import com.google.gerrit.common.Nullable; +import com.google.gerrit.exceptions.StorageException; import com.google.gerrit.reviewdb.client.Change; import com.google.gerrit.reviewdb.client.PatchSet; import com.google.gerrit.reviewdb.client.Project; @@ -27,7 +28,6 @@ import com.google.gerrit.server.project.ProjectState; import com.google.gerrit.server.query.change.ChangeData; import com.google.gerrit.server.query.change.InternalChangeQuery; import com.google.gerrit.sshd.BaseCommand.UnloggedFailure; -import com.google.gwtorm.server.OrmException; import com.google.inject.Inject; import com.google.inject.Provider; import com.google.inject.Singleton; @@ -54,7 +54,7 @@ public class PatchSetParser { } public PatchSet parsePatchSet(String token, ProjectState projectState, String branch) - throws UnloggedFailure, OrmException { + throws UnloggedFailure, StorageException { // By commit? // if (token.matches("^([0-9a-fA-F]{4," + RevId.LEN + "})$")) { @@ -123,7 +123,7 @@ public class PatchSetParser { } private ChangeNotes getNotes(@Nullable ProjectState projectState, Change.Id changeId) - throws OrmException, UnloggedFailure { + throws StorageException, UnloggedFailure { if (projectState != null) { return notesFactory.create(projectState.getNameKey(), changeId); } diff --git a/java/com/google/gerrit/sshd/commands/ReviewCommand.java b/java/com/google/gerrit/sshd/commands/ReviewCommand.java index 0861540655..7af07de779 100644 --- a/java/com/google/gerrit/sshd/commands/ReviewCommand.java +++ b/java/com/google/gerrit/sshd/commands/ReviewCommand.java @@ -23,6 +23,7 @@ import com.google.common.flogger.FluentLogger; import com.google.common.io.CharStreams; import com.google.gerrit.common.data.LabelType; import com.google.gerrit.common.data.LabelValue; +import com.google.gerrit.exceptions.StorageException; import com.google.gerrit.extensions.api.GerritApi; import com.google.gerrit.extensions.api.changes.AbandonInput; import com.google.gerrit.extensions.api.changes.ChangeApi; @@ -44,7 +45,6 @@ import com.google.gerrit.sshd.SshCommand; import com.google.gerrit.util.cli.CmdLineParser; import com.google.gerrit.util.cli.OptionUtil; import com.google.gson.JsonSyntaxException; -import com.google.gwtorm.server.OrmException; import com.google.inject.Inject; import java.io.IOException; import java.io.InputStreamReader; @@ -89,7 +89,7 @@ public class ReviewCommand extends SshCommand { patchSets.add(ps); } catch (UnloggedFailure e) { throw new IllegalArgumentException(e.getMessage(), e); - } catch (OrmException e) { + } catch (StorageException e) { throw new IllegalArgumentException("database error", e); } } diff --git a/java/com/google/gerrit/sshd/commands/SetAccountCommand.java b/java/com/google/gerrit/sshd/commands/SetAccountCommand.java index 91f8535959..bc4a71f57c 100644 --- a/java/com/google/gerrit/sshd/commands/SetAccountCommand.java +++ b/java/com/google/gerrit/sshd/commands/SetAccountCommand.java @@ -19,6 +19,7 @@ import static java.nio.charset.StandardCharsets.UTF_8; import com.google.common.base.Strings; import com.google.gerrit.common.RawInputUtil; import com.google.gerrit.exceptions.EmailException; +import com.google.gerrit.exceptions.StorageException; import com.google.gerrit.extensions.api.accounts.EmailInput; import com.google.gerrit.extensions.api.accounts.SshKeyInput; import com.google.gerrit.extensions.common.EmailInfo; @@ -52,7 +53,6 @@ import com.google.gerrit.server.restapi.account.PutName; import com.google.gerrit.server.restapi.account.PutPreferred; import com.google.gerrit.sshd.CommandMetaData; import com.google.gerrit.sshd.SshCommand; -import com.google.gwtorm.server.OrmException; import com.google.inject.Inject; import com.google.inject.Provider; import java.io.BufferedReader; @@ -213,7 +213,7 @@ final class SetAccountCommand extends SshCommand { } private void setAccount() - throws OrmException, IOException, UnloggedFailure, ConfigInvalidException, + throws StorageException, IOException, UnloggedFailure, ConfigInvalidException, PermissionBackendException { user = genericUserFactory.create(id); rsrc = new AccountResource(user.asIdentifiedUser()); @@ -273,7 +273,7 @@ final class SetAccountCommand extends SshCommand { } private void addSshKeys(List sshKeys) - throws RestApiException, OrmException, IOException, ConfigInvalidException, + throws RestApiException, StorageException, IOException, ConfigInvalidException, PermissionBackendException { for (String sshKey : sshKeys) { SshKeyInput in = new SshKeyInput(); @@ -283,7 +283,7 @@ final class SetAccountCommand extends SshCommand { } private void deleteSshKeys(List sshKeys) - throws RestApiException, OrmException, RepositoryNotFoundException, IOException, + throws RestApiException, StorageException, RepositoryNotFoundException, IOException, ConfigInvalidException, PermissionBackendException { List infos = getSshKeys.apply(rsrc); if (sshKeys.contains("ALL")) { @@ -302,15 +302,15 @@ final class SetAccountCommand extends SshCommand { } private void deleteSshKey(SshKeyInfo i) - throws AuthException, OrmException, RepositoryNotFoundException, IOException, + throws AuthException, StorageException, RepositoryNotFoundException, IOException, ConfigInvalidException, PermissionBackendException { AccountSshKey sshKey = AccountSshKey.create(user.getAccountId(), i.seq, i.sshPublicKey); deleteSshKey.apply(new AccountResource.SshKey(user.asIdentifiedUser(), sshKey), null); } private void addEmail(String email) - throws UnloggedFailure, RestApiException, OrmException, IOException, ConfigInvalidException, - PermissionBackendException { + throws UnloggedFailure, RestApiException, StorageException, IOException, + ConfigInvalidException, PermissionBackendException { EmailInput in = new EmailInput(); in.email = email; in.noConfirmation = true; @@ -322,7 +322,7 @@ final class SetAccountCommand extends SshCommand { } private void deleteEmail(String email) - throws RestApiException, OrmException, IOException, ConfigInvalidException, + throws RestApiException, StorageException, IOException, ConfigInvalidException, PermissionBackendException { if (email.equals("ALL")) { List emails = getEmails.apply(rsrc); @@ -335,7 +335,7 @@ final class SetAccountCommand extends SshCommand { } private void putPreferred(String email) - throws RestApiException, OrmException, IOException, PermissionBackendException, + throws RestApiException, StorageException, IOException, PermissionBackendException, ConfigInvalidException { for (EmailInfo e : getEmails.apply(rsrc)) { if (e.email.equals(email)) { diff --git a/java/com/google/gerrit/sshd/commands/SetParentCommand.java b/java/com/google/gerrit/sshd/commands/SetParentCommand.java index f2d8c4c8ae..67d24d037f 100644 --- a/java/com/google/gerrit/sshd/commands/SetParentCommand.java +++ b/java/com/google/gerrit/sshd/commands/SetParentCommand.java @@ -16,6 +16,7 @@ package com.google.gerrit.sshd.commands; import static java.util.stream.Collectors.toList; +import com.google.gerrit.exceptions.StorageException; import com.google.gerrit.extensions.api.projects.ParentInput; import com.google.gerrit.extensions.common.ProjectInfo; import com.google.gerrit.extensions.restapi.AuthException; @@ -33,7 +34,6 @@ import com.google.gerrit.server.restapi.project.ListChildProjects; import com.google.gerrit.server.restapi.project.SetParent; import com.google.gerrit.sshd.CommandMetaData; import com.google.gerrit.sshd.SshCommand; -import com.google.gwtorm.server.OrmException; import com.google.inject.Inject; import java.io.IOException; import java.util.ArrayList; @@ -112,7 +112,7 @@ final class SetParentCommand extends SshCommand { childProjects.addAll(getChildrenForReparenting(oldParent)); } catch (PermissionBackendException e) { throw new Failure(1, "permissions unavailable", e); - } catch (OrmException | RestApiException e) { + } catch (StorageException | RestApiException e) { throw new Failure(1, "failure in request", e); } } @@ -149,7 +149,7 @@ final class SetParentCommand extends SshCommand { * reparenting. */ private List getChildrenForReparenting(ProjectState parent) - throws PermissionBackendException, OrmException, RestApiException { + throws PermissionBackendException, StorageException, RestApiException { final List childProjects = new ArrayList<>(); final List excluded = new ArrayList<>(excludedChildren.size()); for (ProjectState excludedChild : excludedChildren) { diff --git a/java/com/google/gerrit/sshd/commands/SetReviewersCommand.java b/java/com/google/gerrit/sshd/commands/SetReviewersCommand.java index a4a8ea865f..30caa434fc 100644 --- a/java/com/google/gerrit/sshd/commands/SetReviewersCommand.java +++ b/java/com/google/gerrit/sshd/commands/SetReviewersCommand.java @@ -15,6 +15,7 @@ package com.google.gerrit.sshd.commands; import com.google.common.flogger.FluentLogger; +import com.google.gerrit.exceptions.StorageException; import com.google.gerrit.extensions.api.changes.AddReviewerInput; import com.google.gerrit.extensions.api.changes.DeleteReviewerInput; import com.google.gerrit.extensions.restapi.ResourceNotFoundException; @@ -29,7 +30,6 @@ import com.google.gerrit.server.restapi.change.PostReviewers; import com.google.gerrit.sshd.ChangeArgumentParser; import com.google.gerrit.sshd.CommandMetaData; import com.google.gerrit.sshd.SshCommand; -import com.google.gwtorm.server.OrmException; import com.google.inject.Inject; import java.io.IOException; import java.util.ArrayList; @@ -75,7 +75,7 @@ public class SetReviewersCommand extends SshCommand { changeArgumentParser.addChange(token, changes, projectState); } catch (IOException | UnloggedFailure e) { throw new IllegalArgumentException(e.getMessage(), e); - } catch (OrmException e) { + } catch (StorageException e) { throw new IllegalArgumentException("database is down", e); } catch (PermissionBackendException e) { throw new IllegalArgumentException("can't check permissions", e); diff --git a/java/com/google/gerrit/sshd/commands/UploadArchive.java b/java/com/google/gerrit/sshd/commands/UploadArchive.java index 26a0d15cd0..155ffb2609 100644 --- a/java/com/google/gerrit/sshd/commands/UploadArchive.java +++ b/java/com/google/gerrit/sshd/commands/UploadArchive.java @@ -19,6 +19,7 @@ import static java.util.Objects.requireNonNull; import com.google.common.base.Splitter; import com.google.common.collect.ImmutableMap; +import com.google.gerrit.exceptions.StorageException; import com.google.gerrit.extensions.restapi.AuthException; import com.google.gerrit.server.change.ArchiveFormat; import com.google.gerrit.server.permissions.PermissionBackend; @@ -29,7 +30,6 @@ import com.google.gerrit.server.project.ProjectState; import com.google.gerrit.server.restapi.change.AllowedFormats; import com.google.gerrit.server.restapi.project.CommitsCollection; import com.google.gerrit.sshd.AbstractGitCommand; -import com.google.gwtorm.server.OrmException; import com.google.inject.Inject; import java.io.IOException; import java.util.ArrayList; @@ -165,7 +165,8 @@ public class UploadArchive extends AbstractGitCommand { } @Override - protected void runImpl() throws IOException, OrmException, PermissionBackendException, Failure { + protected void runImpl() + throws IOException, StorageException, PermissionBackendException, Failure { PacketLineOut packetOut = new PacketLineOut(out); packetOut.setFlushOnEnd(true); packetOut.writeString("ACK"); @@ -246,7 +247,7 @@ public class UploadArchive extends AbstractGitCommand { } private boolean canRead(ObjectId revId) - throws IOException, OrmException, PermissionBackendException { + throws IOException, StorageException, PermissionBackendException { ProjectState projectState = projectCache.get(projectName); requireNonNull(projectState, () -> String.format("Failed to load project %s", projectName)); diff --git a/java/com/google/gerrit/testing/BUILD b/java/com/google/gerrit/testing/BUILD index 1c95d2dc66..ec5076e17e 100644 --- a/java/com/google/gerrit/testing/BUILD +++ b/java/com/google/gerrit/testing/BUILD @@ -34,7 +34,6 @@ java_library( "//java/com/google/gerrit/server/restapi", "//java/com/google/gerrit/server/schema", "//java/com/google/gerrit/server/util/time", - "//java/com/google/gwtorm", "//lib:guava", "//lib:h2", "//lib:junit", diff --git a/java/gerrit/BUILD b/java/gerrit/BUILD index 127e598f9f..f416f11649 100644 --- a/java/gerrit/BUILD +++ b/java/gerrit/BUILD @@ -4,10 +4,10 @@ java_library( visibility = ["//visibility:public"], deps = [ "//java/com/google/gerrit/common:server", + "//java/com/google/gerrit/exceptions", "//java/com/google/gerrit/extensions:api", "//java/com/google/gerrit/reviewdb:server", "//java/com/google/gerrit/server", - "//java/com/google/gwtorm", "//lib/flogger:api", "//lib/jgit/org.eclipse.jgit:jgit", "//lib/prolog:runtime", diff --git a/java/gerrit/PRED__load_commit_labels_1.java b/java/gerrit/PRED__load_commit_labels_1.java index 1d0ba8a48a..08a3b7792d 100644 --- a/java/gerrit/PRED__load_commit_labels_1.java +++ b/java/gerrit/PRED__load_commit_labels_1.java @@ -4,10 +4,10 @@ package gerrit; import com.google.gerrit.common.data.LabelType; import com.google.gerrit.common.data.LabelTypes; +import com.google.gerrit.exceptions.StorageException; import com.google.gerrit.reviewdb.client.PatchSetApproval; import com.google.gerrit.server.query.change.ChangeData; import com.google.gerrit.server.rules.StoredValues; -import com.google.gwtorm.server.OrmException; import com.googlecode.prolog_cafe.exceptions.JavaException; import com.googlecode.prolog_cafe.exceptions.PrologException; import com.googlecode.prolog_cafe.lang.IntegerTerm; @@ -55,7 +55,7 @@ class PRED__load_commit_labels_1 extends Predicate.P1 { listHead = new ListTerm(new StructureTerm(sym_commit_label, labelTerm, userTerm), listHead); } - } catch (OrmException err) { + } catch (StorageException err) { throw new JavaException(this, 1, err); } diff --git a/java/gerrit/PRED_get_legacy_label_types_1.java b/java/gerrit/PRED_get_legacy_label_types_1.java index ef79e0584f..567415c1db 100644 --- a/java/gerrit/PRED_get_legacy_label_types_1.java +++ b/java/gerrit/PRED_get_legacy_label_types_1.java @@ -16,8 +16,8 @@ package gerrit; import com.google.gerrit.common.data.LabelType; import com.google.gerrit.common.data.LabelValue; +import com.google.gerrit.exceptions.StorageException; import com.google.gerrit.server.rules.StoredValues; -import com.google.gwtorm.server.OrmException; import com.googlecode.prolog_cafe.exceptions.JavaException; import com.googlecode.prolog_cafe.exceptions.PrologException; import com.googlecode.prolog_cafe.lang.IntegerTerm; @@ -56,7 +56,7 @@ class PRED_get_legacy_label_types_1 extends Predicate.P1 { List list; try { list = StoredValues.CHANGE_DATA.get(engine).getLabelTypes().getLabelTypes(); - } catch (OrmException err) { + } catch (StorageException err) { throw new JavaException(this, 1, err); } Term head = Prolog.Nil; diff --git a/java/gerrit/PRED_pure_revert_1.java b/java/gerrit/PRED_pure_revert_1.java index 95a0729111..4a631e2773 100644 --- a/java/gerrit/PRED_pure_revert_1.java +++ b/java/gerrit/PRED_pure_revert_1.java @@ -14,8 +14,8 @@ package gerrit; +import com.google.gerrit.exceptions.StorageException; import com.google.gerrit.server.rules.StoredValues; -import com.google.gwtorm.server.OrmException; import com.googlecode.prolog_cafe.exceptions.JavaException; import com.googlecode.prolog_cafe.exceptions.PrologException; import com.googlecode.prolog_cafe.lang.IntegerTerm; @@ -39,7 +39,7 @@ public class PRED_pure_revert_1 extends Predicate.P1 { Boolean isPureRevert; try { isPureRevert = StoredValues.CHANGE_DATA.get(engine).isPureRevert(); - } catch (OrmException e) { + } catch (StorageException e) { throw new JavaException(this, 1, e); } if (!a1.unify(new IntegerTerm(Boolean.TRUE.equals(isPureRevert) ? 1 : 0), engine.trail)) { diff --git a/java/gerrit/PRED_unresolved_comments_count_1.java b/java/gerrit/PRED_unresolved_comments_count_1.java index 5ed1525cfd..6076b9eb98 100644 --- a/java/gerrit/PRED_unresolved_comments_count_1.java +++ b/java/gerrit/PRED_unresolved_comments_count_1.java @@ -14,8 +14,8 @@ package gerrit; +import com.google.gerrit.exceptions.StorageException; import com.google.gerrit.server.rules.StoredValues; -import com.google.gwtorm.server.OrmException; import com.googlecode.prolog_cafe.exceptions.JavaException; import com.googlecode.prolog_cafe.exceptions.PrologException; import com.googlecode.prolog_cafe.lang.IntegerTerm; @@ -40,7 +40,7 @@ public class PRED_unresolved_comments_count_1 extends Predicate.P1 { if (!a1.unify(new IntegerTerm(count != null ? count : 0), engine.trail)) { return engine.fail(); } - } catch (OrmException err) { + } catch (StorageException err) { throw new JavaException(this, 1, err); } return cont; diff --git a/javatests/com/google/gerrit/acceptance/api/accounts/AccountIT.java b/javatests/com/google/gerrit/acceptance/api/accounts/AccountIT.java index 6adb373793..0c21068750 100644 --- a/javatests/com/google/gerrit/acceptance/api/accounts/AccountIT.java +++ b/javatests/com/google/gerrit/acceptance/api/accounts/AccountIT.java @@ -67,6 +67,7 @@ import com.google.gerrit.common.data.GlobalCapability; import com.google.gerrit.common.data.GroupReference; import com.google.gerrit.common.data.Permission; import com.google.gerrit.common.data.PermissionRule.Action; +import com.google.gerrit.exceptions.StorageException; import com.google.gerrit.extensions.api.accounts.AccountInput; import com.google.gerrit.extensions.api.accounts.DeleteDraftCommentsInput; import com.google.gerrit.extensions.api.accounts.DeletedDraftCommentInfo; @@ -135,7 +136,6 @@ import com.google.gerrit.server.validators.ValidationException; import com.google.gerrit.testing.ConfigSuite; import com.google.gerrit.testing.FakeEmailSender.Message; import com.google.gerrit.testing.TestTimeUtil; -import com.google.gwtorm.server.OrmException; import com.google.inject.Inject; import com.google.inject.Provider; import com.google.inject.name.Named; @@ -2289,7 +2289,7 @@ public class AccountIT extends AbstractDaemonTest { accountsUpdateProvider .get() .update("Set Status", admin.id(), u -> u.setStatus(status)); - } catch (IOException | ConfigInvalidException | OrmException e) { + } catch (IOException | ConfigInvalidException | StorageException e) { // Ignore, the successful update of the account is asserted later } } @@ -2346,7 +2346,7 @@ public class AccountIT extends AbstractDaemonTest { "Set Status", admin.id(), u -> u.setStatus(status.get(bgCounter.getAndAdd(1)))); - } catch (IOException | ConfigInvalidException | OrmException e) { + } catch (IOException | ConfigInvalidException | StorageException e) { // Ignore, the expected exception is asserted later } }, @@ -2399,7 +2399,7 @@ public class AccountIT extends AbstractDaemonTest { accountsUpdateProvider .get() .update("Set Status", admin.id(), u -> u.setStatus("A-2")); - } catch (IOException | ConfigInvalidException | OrmException e) { + } catch (IOException | ConfigInvalidException | StorageException e) { // Ignore, the expected exception is asserted later } }); @@ -2468,7 +2468,7 @@ public class AccountIT extends AbstractDaemonTest { "Update External ID", accountId, u -> u.replaceExternalId(extIdA1, extIdA2)); - } catch (IOException | ConfigInvalidException | OrmException e) { + } catch (IOException | ConfigInvalidException | StorageException e) { // Ignore, the expected exception is asserted later } }); diff --git a/javatests/com/google/gerrit/acceptance/api/change/ChangeIT.java b/javatests/com/google/gerrit/acceptance/api/change/ChangeIT.java index ee556a383c..0abf8f5a1f 100644 --- a/javatests/com/google/gerrit/acceptance/api/change/ChangeIT.java +++ b/javatests/com/google/gerrit/acceptance/api/change/ChangeIT.java @@ -74,6 +74,7 @@ import com.google.gerrit.common.data.GlobalCapability; import com.google.gerrit.common.data.LabelFunction; import com.google.gerrit.common.data.LabelType; import com.google.gerrit.common.data.Permission; +import com.google.gerrit.exceptions.StorageException; import com.google.gerrit.extensions.annotations.Exports; import com.google.gerrit.extensions.api.changes.AddReviewerInput; import com.google.gerrit.extensions.api.changes.AddReviewerResult; @@ -158,7 +159,6 @@ import com.google.gerrit.server.update.ChangeContext; import com.google.gerrit.server.util.time.TimeUtil; import com.google.gerrit.testing.FakeEmailSender.Message; import com.google.gerrit.testing.TestTimeUtil; -import com.google.gwtorm.server.OrmException; import com.google.inject.AbstractModule; import com.google.inject.Inject; import java.io.IOException; @@ -2544,7 +2544,7 @@ public class ChangeIT extends AbstractDaemonTest { } @Override - public boolean match(ChangeData cd) throws OrmException { + public boolean match(ChangeData cd) throws StorageException { return Objects.equals(cd.change().getTopic(), value); } diff --git a/javatests/com/google/gerrit/acceptance/api/group/BUILD b/javatests/com/google/gerrit/acceptance/api/group/BUILD index 29df2b1b6e..a12342a69f 100644 --- a/javatests/com/google/gerrit/acceptance/api/group/BUILD +++ b/javatests/com/google/gerrit/acceptance/api/group/BUILD @@ -21,7 +21,6 @@ java_library( "//java/com/google/gerrit/extensions:api", "//java/com/google/gerrit/reviewdb:server", "//java/com/google/gerrit/server", - "//java/com/google/gwtorm", "//lib/truth", ], ) diff --git a/javatests/com/google/gerrit/acceptance/api/group/GroupIndexerIT.java b/javatests/com/google/gerrit/acceptance/api/group/GroupIndexerIT.java index ee81683c26..d03b328b21 100644 --- a/javatests/com/google/gerrit/acceptance/api/group/GroupIndexerIT.java +++ b/javatests/com/google/gerrit/acceptance/api/group/GroupIndexerIT.java @@ -21,6 +21,7 @@ import static com.google.gerrit.truth.OptionalSubject.assertThat; import com.google.common.collect.ImmutableSet; import com.google.gerrit.exceptions.NoSuchGroupException; +import com.google.gerrit.exceptions.StorageException; import com.google.gerrit.extensions.api.GerritApi; import com.google.gerrit.extensions.common.GroupInfo; import com.google.gerrit.extensions.restapi.RestApiException; @@ -36,7 +37,6 @@ import com.google.gerrit.server.query.group.InternalGroupQuery; import com.google.gerrit.testing.InMemoryTestEnvironment; import com.google.gerrit.truth.ListSubject; import com.google.gerrit.truth.OptionalSubject; -import com.google.gwtorm.server.OrmException; import com.google.inject.Inject; import com.google.inject.Provider; import java.io.IOException; @@ -158,7 +158,7 @@ public class GroupIndexerIT { private void updateGroupWithoutCacheOrIndex( AccountGroup.UUID groupUuid, InternalGroupUpdate groupUpdate) - throws OrmException, NoSuchGroupException, IOException, ConfigInvalidException { + throws StorageException, NoSuchGroupException, IOException, ConfigInvalidException { groupsUpdate.updateGroupInNoteDb(groupUuid, groupUpdate); } diff --git a/javatests/com/google/gerrit/acceptance/api/group/GroupsUpdateIT.java b/javatests/com/google/gerrit/acceptance/api/group/GroupsUpdateIT.java index 72c12579a7..72fec77ce9 100644 --- a/javatests/com/google/gerrit/acceptance/api/group/GroupsUpdateIT.java +++ b/javatests/com/google/gerrit/acceptance/api/group/GroupsUpdateIT.java @@ -19,6 +19,7 @@ import static com.google.common.truth.Truth8.assertThat; import com.google.common.collect.ImmutableSet; import com.google.gerrit.common.data.GroupReference; 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.AccountGroup; import com.google.gerrit.server.ServerInitiated; @@ -27,7 +28,6 @@ import com.google.gerrit.server.group.db.GroupsUpdate; import com.google.gerrit.server.group.db.InternalGroupCreation; import com.google.gerrit.server.group.db.InternalGroupUpdate; import com.google.gerrit.testing.InMemoryTestEnvironment; -import com.google.gwtorm.server.OrmException; import com.google.inject.Inject; import com.google.inject.Provider; import java.io.IOException; @@ -92,7 +92,7 @@ public class GroupsUpdateIT { } private void createGroup(InternalGroupCreation groupCreation, InternalGroupUpdate groupUpdate) - throws OrmException, IOException, ConfigInvalidException { + throws StorageException, IOException, ConfigInvalidException { groupsUpdateProvider.get().createGroup(groupCreation, groupUpdate); } @@ -138,7 +138,7 @@ public class GroupsUpdateIT { InternalGroupUpdate groupUpdate = InternalGroupUpdate.builder().build(); try { groupsUpdateProvider.get().createGroup(groupCreation, groupUpdate); - } catch (OrmException | IOException | ConfigInvalidException e) { + } catch (StorageException | IOException | ConfigInvalidException e) { throw new IllegalStateException(e); } } diff --git a/javatests/com/google/gerrit/acceptance/rest/account/BUILD b/javatests/com/google/gerrit/acceptance/rest/account/BUILD index e475a6da4d..3b46414b31 100644 --- a/javatests/com/google/gerrit/acceptance/rest/account/BUILD +++ b/javatests/com/google/gerrit/acceptance/rest/account/BUILD @@ -18,7 +18,6 @@ java_library( deps = [ "//java/com/google/gerrit/acceptance:lib", "//java/com/google/gerrit/reviewdb:server", - "//java/com/google/gwtorm", "//lib:junit", ], ) diff --git a/javatests/com/google/gerrit/acceptance/rest/account/ExternalIdIT.java b/javatests/com/google/gerrit/acceptance/rest/account/ExternalIdIT.java index f29ede5e38..8ff80a050d 100644 --- a/javatests/com/google/gerrit/acceptance/rest/account/ExternalIdIT.java +++ b/javatests/com/google/gerrit/acceptance/rest/account/ExternalIdIT.java @@ -36,6 +36,7 @@ import com.google.gerrit.acceptance.TestAccount; import com.google.gerrit.acceptance.testsuite.request.RequestScopeOperations; import com.google.gerrit.common.data.GlobalCapability; import com.google.gerrit.common.data.Permission; +import com.google.gerrit.exceptions.DuplicateKeyException; import com.google.gerrit.extensions.api.config.ConsistencyCheckInfo; import com.google.gerrit.extensions.api.config.ConsistencyCheckInfo.ConsistencyProblemInfo; import com.google.gerrit.extensions.api.config.ConsistencyCheckInput; @@ -54,7 +55,6 @@ import com.google.gerrit.server.account.externalids.ExternalIds; import com.google.gerrit.server.extensions.events.GitReferenceUpdated; import com.google.gerrit.server.git.meta.MetaDataUpdate; import com.google.gson.reflect.TypeToken; -import com.google.gwtorm.server.OrmDuplicateKeyException; import com.google.inject.Inject; import com.google.inject.Provider; import java.io.IOException; @@ -941,7 +941,7 @@ public class ExternalIdIT extends AbstractDaemonTest { } private void addExtId(TestRepository testRepo, ExternalId... extIds) - throws IOException, OrmDuplicateKeyException, ConfigInvalidException { + throws IOException, DuplicateKeyException, ConfigInvalidException { ExternalIdNotes extIdNotes = externalIdNotesFactory.load(testRepo.getRepository()); extIdNotes.insert(Arrays.asList(extIds)); try (MetaDataUpdate metaDataUpdate = diff --git a/javatests/com/google/gerrit/acceptance/rest/change/AbstractSubmit.java b/javatests/com/google/gerrit/acceptance/rest/change/AbstractSubmit.java index d874ceb99f..2c8e1ca581 100644 --- a/javatests/com/google/gerrit/acceptance/rest/change/AbstractSubmit.java +++ b/javatests/com/google/gerrit/acceptance/rest/change/AbstractSubmit.java @@ -40,6 +40,7 @@ import com.google.gerrit.acceptance.TestProjectInput; import com.google.gerrit.acceptance.testsuite.project.ProjectOperations; import com.google.gerrit.acceptance.testsuite.request.RequestScopeOperations; import com.google.gerrit.common.data.Permission; +import com.google.gerrit.exceptions.StorageException; import com.google.gerrit.extensions.api.changes.ChangeApi; import com.google.gerrit.extensions.api.changes.SubmitInput; import com.google.gerrit.extensions.api.projects.BranchInput; @@ -82,7 +83,6 @@ import com.google.gerrit.server.util.time.TimeUtil; import com.google.gerrit.server.validators.ValidationException; import com.google.gerrit.testing.ConfigSuite; import com.google.gerrit.testing.TestTimeUtil; -import com.google.gwtorm.server.OrmException; import com.google.inject.Inject; import java.io.ByteArrayOutputStream; import java.io.IOException; @@ -1104,7 +1104,7 @@ public abstract class AbstractSubmit extends AbstractDaemonTest { change.getChange().getId(), new BatchUpdateOp() { @Override - public boolean updateChange(ChangeContext ctx) throws OrmException { + public boolean updateChange(ChangeContext ctx) throws StorageException { ctx.getChange().setStatus(Change.Status.NEW); ctx.getUpdate(ctx.getChange().currentPatchSetId()).setStatus(Change.Status.NEW); return true; diff --git a/javatests/com/google/gerrit/acceptance/rest/change/SubmitResolvingMergeCommitIT.java b/javatests/com/google/gerrit/acceptance/rest/change/SubmitResolvingMergeCommitIT.java index 42e7383843..3836093fb2 100644 --- a/javatests/com/google/gerrit/acceptance/rest/change/SubmitResolvingMergeCommitIT.java +++ b/javatests/com/google/gerrit/acceptance/rest/change/SubmitResolvingMergeCommitIT.java @@ -21,6 +21,7 @@ import com.google.common.collect.ImmutableList; import com.google.gerrit.acceptance.AbstractDaemonTest; import com.google.gerrit.acceptance.NoHttpd; import com.google.gerrit.acceptance.PushOneCommit; +import com.google.gerrit.exceptions.StorageException; import com.google.gerrit.extensions.client.ChangeStatus; import com.google.gerrit.reviewdb.client.Project; import com.google.gerrit.server.permissions.PermissionBackendException; @@ -29,7 +30,6 @@ import com.google.gerrit.server.restapi.change.Submit; import com.google.gerrit.server.submit.ChangeSet; import com.google.gerrit.server.submit.MergeSuperSet; import com.google.gerrit.testing.ConfigSuite; -import com.google.gwtorm.server.OrmException; import com.google.inject.Inject; import com.google.inject.Provider; import java.io.IOException; @@ -305,7 +305,7 @@ public class SubmitResolvingMergeCommitIT extends AbstractDaemonTest { } private void assertChangeSetMergeable(ChangeData change, boolean expected) - throws MissingObjectException, IncorrectObjectTypeException, IOException, OrmException, + throws MissingObjectException, IncorrectObjectTypeException, IOException, StorageException, PermissionBackendException { ChangeSet cs = mergeSuperSet.get().completeChangeSet(change.change(), user(admin)); assertThat(submit.unmergeableChanges(cs).isEmpty()).isEqualTo(expected); diff --git a/javatests/com/google/gerrit/acceptance/rest/project/BUILD b/javatests/com/google/gerrit/acceptance/rest/project/BUILD index 1bbf3fa612..131c24a20d 100644 --- a/javatests/com/google/gerrit/acceptance/rest/project/BUILD +++ b/javatests/com/google/gerrit/acceptance/rest/project/BUILD @@ -33,7 +33,6 @@ java_library( "//java/com/google/gerrit/extensions:api", "//java/com/google/gerrit/reviewdb:server", "//java/com/google/gerrit/server", - "//java/com/google/gwtorm", "//lib:guava", "//lib/truth", ], diff --git a/javatests/com/google/gerrit/acceptance/server/change/ConsistencyCheckerIT.java b/javatests/com/google/gerrit/acceptance/server/change/ConsistencyCheckerIT.java index 88f2b6d2c1..b1911613b3 100644 --- a/javatests/com/google/gerrit/acceptance/server/change/ConsistencyCheckerIT.java +++ b/javatests/com/google/gerrit/acceptance/server/change/ConsistencyCheckerIT.java @@ -25,6 +25,7 @@ import com.google.gerrit.acceptance.NoHttpd; import com.google.gerrit.acceptance.TestAccount; import com.google.gerrit.common.FooterConstants; import com.google.gerrit.common.Nullable; +import com.google.gerrit.exceptions.StorageException; import com.google.gerrit.extensions.api.changes.FixInput; import com.google.gerrit.extensions.client.ChangeStatus; import com.google.gerrit.extensions.common.ChangeInfo; @@ -48,7 +49,6 @@ import com.google.gerrit.server.update.ChangeContext; import com.google.gerrit.server.update.RepoContext; import com.google.gerrit.server.util.time.TimeUtil; import com.google.gerrit.testing.TestChanges; -import com.google.gwtorm.server.OrmException; import com.google.inject.Inject; import com.google.inject.Provider; import java.io.IOException; @@ -313,7 +313,7 @@ public class ConsistencyCheckerIT extends AbstractDaemonTest { notes.getChangeId(), new BatchUpdateOp() { @Override - public boolean updateChange(ChangeContext ctx) throws OrmException { + public boolean updateChange(ChangeContext ctx) throws StorageException { ctx.getChange().setStatus(Change.Status.MERGED); ctx.getUpdate(ctx.getChange().currentPatchSetId()).fixStatus(Change.Status.MERGED); return true; @@ -862,7 +862,7 @@ public class ConsistencyCheckerIT extends AbstractDaemonTest { } @Override - public boolean updateChange(ChangeContext ctx) throws OrmException { + public boolean updateChange(ChangeContext ctx) throws StorageException { ctx.getChange().setStatus(Change.Status.MERGED); ctx.getUpdate(ctx.getChange().currentPatchSetId()).fixStatus(Change.Status.MERGED); return true; diff --git a/javatests/com/google/gerrit/acceptance/server/change/GetRelatedIT.java b/javatests/com/google/gerrit/acceptance/server/change/GetRelatedIT.java index 72870d2258..c1ba6fa592 100644 --- a/javatests/com/google/gerrit/acceptance/server/change/GetRelatedIT.java +++ b/javatests/com/google/gerrit/acceptance/server/change/GetRelatedIT.java @@ -34,6 +34,7 @@ import com.google.gerrit.acceptance.testsuite.request.RequestScopeOperations; import com.google.gerrit.common.RawInputUtil; import com.google.gerrit.common.data.GlobalCapability; import com.google.gerrit.common.data.PermissionRule; +import com.google.gerrit.exceptions.StorageException; import com.google.gerrit.extensions.api.changes.RelatedChangeAndCommitInfo; import com.google.gerrit.extensions.api.changes.ReviewInput; import com.google.gerrit.extensions.common.CommitInfo; @@ -53,7 +54,6 @@ import com.google.gerrit.server.update.ChangeContext; import com.google.gerrit.server.util.time.TimeUtil; import com.google.gerrit.testing.ConfigSuite; import com.google.gerrit.testing.TestTimeUtil; -import com.google.gwtorm.server.OrmException; import com.google.inject.Inject; import java.util.ArrayList; import java.util.Arrays; @@ -694,7 +694,7 @@ public class GetRelatedIT extends AbstractDaemonTest { psId.getParentKey(), new BatchUpdateOp() { @Override - public boolean updateChange(ChangeContext ctx) throws OrmException { + public boolean updateChange(ChangeContext ctx) throws StorageException { PatchSet ps = psUtil.get(ctx.getNotes(), psId); psUtil.setGroups(ctx.getUpdate(psId), ps, ImmutableList.of()); return true; diff --git a/javatests/com/google/gerrit/gpg/BUILD b/javatests/com/google/gerrit/gpg/BUILD index 8725457211..6edfa93d91 100644 --- a/javatests/com/google/gerrit/gpg/BUILD +++ b/javatests/com/google/gerrit/gpg/BUILD @@ -18,7 +18,6 @@ junit_tests( "//java/com/google/gerrit/server/project/testing:project-test-util", "//java/com/google/gerrit/server/schema", "//java/com/google/gerrit/testing:gerrit-test-util", - "//java/com/google/gwtorm", "//lib:guava", "//lib/bouncycastle:bcpg", "//lib/bouncycastle:bcpg-neverlink", diff --git a/javatests/com/google/gerrit/httpd/BUILD b/javatests/com/google/gerrit/httpd/BUILD index 16cfe2cad3..0fbd9224ae 100644 --- a/javatests/com/google/gerrit/httpd/BUILD +++ b/javatests/com/google/gerrit/httpd/BUILD @@ -12,7 +12,6 @@ junit_tests( "//java/com/google/gerrit/server", "//java/com/google/gerrit/testing:gerrit-test-util", "//java/com/google/gerrit/util/http", - "//java/com/google/gwtorm", "//javatests/com/google/gerrit/util/http/testutil", "//lib:gson", "//lib:guava", diff --git a/javatests/com/google/gerrit/mail/BUILD b/javatests/com/google/gerrit/mail/BUILD index e7a3fb0130..5cfa00cff5 100644 --- a/javatests/com/google/gerrit/mail/BUILD +++ b/javatests/com/google/gerrit/mail/BUILD @@ -21,7 +21,6 @@ junit_tests( "//java/com/google/gerrit/server", "//java/com/google/gerrit/server/project/testing:project-test-util", "//java/com/google/gerrit/testing:gerrit-test-util", - "//java/com/google/gwtorm", "//java/org/eclipse/jgit:server", "//lib:gson", "//lib:guava-retrying", diff --git a/javatests/com/google/gerrit/server/BUILD b/javatests/com/google/gerrit/server/BUILD index d0114f369e..321d1fd671 100644 --- a/javatests/com/google/gerrit/server/BUILD +++ b/javatests/com/google/gerrit/server/BUILD @@ -61,7 +61,6 @@ junit_tests( "//java/com/google/gerrit/server/util/time", "//java/com/google/gerrit/testing:gerrit-test-util", "//java/com/google/gerrit/truth", - "//java/com/google/gwtorm", "//java/org/eclipse/jgit:server", "//lib:gson", "//lib:guava", diff --git a/javatests/com/google/gerrit/server/group/db/BUILD b/javatests/com/google/gerrit/server/group/db/BUILD index 00e072cf64..b4652c9b6b 100644 --- a/javatests/com/google/gerrit/server/group/db/BUILD +++ b/javatests/com/google/gerrit/server/group/db/BUILD @@ -8,6 +8,7 @@ junit_tests( "//java/com/google/gerrit/common:annotations", "//java/com/google/gerrit/common:server", "//java/com/google/gerrit/common/data/testing:common-data-test-util", + "//java/com/google/gerrit/exceptions", "//java/com/google/gerrit/extensions:api", "//java/com/google/gerrit/extensions/common/testing:common-test-util", "//java/com/google/gerrit/git", @@ -18,7 +19,6 @@ junit_tests( "//java/com/google/gerrit/server/util/time", "//java/com/google/gerrit/testing:gerrit-test-util", "//java/com/google/gerrit/truth", - "//java/com/google/gwtorm", "//lib:guava", "//lib/jgit/org.eclipse.jgit:jgit", "//lib/jgit/org.eclipse.jgit.junit:junit", diff --git a/javatests/com/google/gerrit/server/group/db/GroupNameNotesTest.java b/javatests/com/google/gerrit/server/group/db/GroupNameNotesTest.java index e93102893d..e1211d3144 100644 --- a/javatests/com/google/gerrit/server/group/db/GroupNameNotesTest.java +++ b/javatests/com/google/gerrit/server/group/db/GroupNameNotesTest.java @@ -27,6 +27,7 @@ import static org.eclipse.jgit.lib.Constants.OBJ_BLOB; import com.google.common.collect.ImmutableList; import com.google.gerrit.common.data.GroupReference; import com.google.gerrit.common.data.testing.GroupReferenceSubject; +import com.google.gerrit.exceptions.DuplicateKeyException; import com.google.gerrit.extensions.common.CommitInfo; import com.google.gerrit.extensions.common.testing.CommitInfoSubject; import com.google.gerrit.git.RefUpdateUtil; @@ -43,7 +44,6 @@ import com.google.gerrit.testing.GitTestUtil; import com.google.gerrit.testing.TestTimeUtil; import com.google.gerrit.truth.ListSubject; import com.google.gerrit.truth.OptionalSubject; -import com.google.gwtorm.server.OrmDuplicateKeyException; import java.io.IOException; import java.util.Arrays; import java.util.List; @@ -129,7 +129,7 @@ public class GroupNameNotesTest extends GerritBaseTests { createGroup(groupUuid, groupName); AccountGroup.UUID anotherGroupUuid = new AccountGroup.UUID("AnotherGroup"); - exception.expect(OrmDuplicateKeyException.class); + exception.expect(DuplicateKeyException.class); exception.expectMessage(groupName.get()); GroupNameNotes.forNewGroup(allUsersName, repo, anotherGroupUuid, groupName); } @@ -205,7 +205,7 @@ public class GroupNameNotesTest extends GerritBaseTests { AccountGroup.NameKey anotherGroupName = new AccountGroup.NameKey("admins"); createGroup(anotherGroupUuid, anotherGroupName); - exception.expect(OrmDuplicateKeyException.class); + exception.expect(DuplicateKeyException.class); exception.expectMessage(anotherGroupName.get()); GroupNameNotes.forRename(allUsersName, repo, groupUuid, groupName, anotherGroupName); } diff --git a/javatests/com/google/gerrit/server/index/change/FakeChangeIndex.java b/javatests/com/google/gerrit/server/index/change/FakeChangeIndex.java index efe6a5ab08..a59228b7c0 100644 --- a/javatests/com/google/gerrit/server/index/change/FakeChangeIndex.java +++ b/javatests/com/google/gerrit/server/index/change/FakeChangeIndex.java @@ -15,6 +15,7 @@ package com.google.gerrit.server.index.change; import com.google.common.collect.ImmutableList; +import com.google.gerrit.exceptions.StorageException; import com.google.gerrit.index.QueryOptions; import com.google.gerrit.index.Schema; import com.google.gerrit.index.query.FieldBundle; @@ -24,7 +25,6 @@ import com.google.gerrit.index.query.ResultSet; import com.google.gerrit.reviewdb.client.Change; import com.google.gerrit.server.query.change.ChangeData; import com.google.gerrit.server.query.change.ChangeDataSource; -import com.google.gwtorm.server.OrmException; import org.junit.Ignore; @Ignore @@ -52,12 +52,12 @@ public class FakeChangeIndex implements ChangeIndex { } @Override - public ResultSet read() throws OrmException { + public ResultSet read() throws StorageException { throw new UnsupportedOperationException(); } @Override - public ResultSet readRaw() throws OrmException { + public ResultSet readRaw() throws StorageException { throw new UnsupportedOperationException("not implemented"); } diff --git a/javatests/com/google/gerrit/server/mail/send/CommentSenderTest.java b/javatests/com/google/gerrit/server/mail/send/CommentSenderTest.java index 87e98fddd0..4101a07109 100644 --- a/javatests/com/google/gerrit/server/mail/send/CommentSenderTest.java +++ b/javatests/com/google/gerrit/server/mail/send/CommentSenderTest.java @@ -16,14 +16,14 @@ package com.google.gerrit.server.mail.send; import static com.google.common.truth.Truth.assertThat; +import com.google.gerrit.exceptions.StorageException; import com.google.gerrit.testing.GerritBaseTests; -import com.google.gwtorm.server.OrmException; import java.util.Collections; import org.junit.Test; public class CommentSenderTest extends GerritBaseTests { private static class TestSender extends CommentSender { - TestSender() throws OrmException { + TestSender() throws StorageException { super(null, null, null, null, null); } } diff --git a/javatests/com/google/gerrit/server/notedb/AbstractChangeNotesTest.java b/javatests/com/google/gerrit/server/notedb/AbstractChangeNotesTest.java index 712449e622..f676526780 100644 --- a/javatests/com/google/gerrit/server/notedb/AbstractChangeNotesTest.java +++ b/javatests/com/google/gerrit/server/notedb/AbstractChangeNotesTest.java @@ -19,6 +19,7 @@ import static java.util.concurrent.TimeUnit.SECONDS; import com.google.common.collect.ImmutableList; import com.google.gerrit.common.data.SubmitRecord; +import com.google.gerrit.exceptions.StorageException; import com.google.gerrit.extensions.config.FactoryModule; import com.google.gerrit.metrics.DisabledMetricMaker; import com.google.gerrit.metrics.MetricMaker; @@ -57,7 +58,6 @@ import com.google.gerrit.testing.GerritBaseTests; import com.google.gerrit.testing.InMemoryRepositoryManager; import com.google.gerrit.testing.TestChanges; import com.google.gerrit.testing.TestTimeUtil; -import com.google.gwtorm.server.OrmException; import com.google.inject.Guice; import com.google.inject.Inject; import com.google.inject.Injector; @@ -213,7 +213,7 @@ public abstract class AbstractChangeNotesTest extends GerritBaseTests { return update; } - protected ChangeNotes newNotes(Change c) throws OrmException { + protected ChangeNotes newNotes(Change c) throws StorageException { return new ChangeNotes(args, c, true, null).load(); } diff --git a/javatests/com/google/gerrit/server/notedb/ChangeNotesTest.java b/javatests/com/google/gerrit/server/notedb/ChangeNotesTest.java index 1da412180f..a6c0224465 100644 --- a/javatests/com/google/gerrit/server/notedb/ChangeNotesTest.java +++ b/javatests/com/google/gerrit/server/notedb/ChangeNotesTest.java @@ -35,6 +35,7 @@ import com.google.common.collect.Iterables; import com.google.common.collect.ListMultimap; import com.google.common.collect.Lists; import com.google.gerrit.common.data.SubmitRecord; +import com.google.gerrit.exceptions.StorageException; import com.google.gerrit.mail.Address; import com.google.gerrit.reviewdb.client.Account; import com.google.gerrit.reviewdb.client.Branch; @@ -54,7 +55,6 @@ import com.google.gerrit.server.logging.RequestId; import com.google.gerrit.server.notedb.ChangeNotesCommit.ChangeNotesRevWalk; import com.google.gerrit.server.util.time.TimeUtil; import com.google.gerrit.testing.TestChanges; -import com.google.gwtorm.server.OrmException; import com.google.inject.Inject; import java.sql.Timestamp; import java.util.LinkedHashSet; @@ -993,7 +993,7 @@ public class ChangeNotesTest extends AbstractChangeNotesTest { try { newNotes(c); fail("Expected IOException"); - } catch (OrmException e) { + } catch (StorageException e) { assertCause( e, ConfigInvalidException.class, @@ -3016,7 +3016,7 @@ public class ChangeNotesTest extends AbstractChangeNotesTest { Change c = newChange(); ChangeUpdate update = newUpdate(c, changeOwner); update.setRevertOf(newChange().getId().get()); - exception.expect(OrmException.class); + exception.expect(StorageException.class); exception.expectMessage("Given ChangeUpdate is only allowed on initial commit"); update.commit(); } diff --git a/javatests/com/google/gerrit/server/notedb/IntBlobTest.java b/javatests/com/google/gerrit/server/notedb/IntBlobTest.java index 1abaa22e28..1cbe61de96 100644 --- a/javatests/com/google/gerrit/server/notedb/IntBlobTest.java +++ b/javatests/com/google/gerrit/server/notedb/IntBlobTest.java @@ -18,10 +18,10 @@ import static com.google.common.truth.Truth.assertThat; import static com.google.common.truth.Truth.assert_; import static com.google.gerrit.truth.OptionalSubject.assertThat; +import com.google.gerrit.exceptions.StorageException; import com.google.gerrit.git.LockFailureException; import com.google.gerrit.reviewdb.client.Project; import com.google.gerrit.server.extensions.events.GitReferenceUpdated; -import com.google.gwtorm.server.OrmException; import java.io.IOException; import org.eclipse.jgit.errors.IncorrectObjectTypeException; import org.eclipse.jgit.internal.storage.dfs.DfsRepositoryDescription; @@ -87,8 +87,8 @@ public class IntBlobTest { ObjectId id = tr.update(refName, tr.blob("1 2 3")); try { IntBlob.parse(repo, refName); - assert_().fail("Expected OrmException"); - } catch (OrmException e) { + assert_().fail("Expected StorageException"); + } catch (StorageException e) { assertThat(e).hasMessageThat().isEqualTo("invalid value in refs/foo blob at " + id.name()); } } diff --git a/javatests/com/google/gerrit/server/notedb/RepoSequenceTest.java b/javatests/com/google/gerrit/server/notedb/RepoSequenceTest.java index 5aad6ff147..263873d895 100644 --- a/javatests/com/google/gerrit/server/notedb/RepoSequenceTest.java +++ b/javatests/com/google/gerrit/server/notedb/RepoSequenceTest.java @@ -23,12 +23,12 @@ import com.github.rholder.retry.Retryer; import com.github.rholder.retry.RetryerBuilder; import com.github.rholder.retry.StopStrategies; import com.google.common.util.concurrent.Runnables; +import com.google.gerrit.exceptions.StorageException; import com.google.gerrit.reviewdb.client.Project; import com.google.gerrit.reviewdb.client.RefNames; import com.google.gerrit.server.extensions.events.GitReferenceUpdated; import com.google.gerrit.testing.GerritBaseTests; import com.google.gerrit.testing.InMemoryRepositoryManager; -import com.google.gwtorm.server.OrmException; import java.io.IOException; import java.util.concurrent.ExecutionException; import java.util.concurrent.atomic.AtomicBoolean; @@ -67,7 +67,7 @@ public class RepoSequenceTest extends GerritBaseTests { for (int i = 1; i <= max; i++) { try { assertThat(s.next()).named("i=" + i + " for " + name).isEqualTo(i); - } catch (OrmException e) { + } catch (StorageException e) { throw new AssertionError("failed batchSize=" + batchSize + ", i=" + i, e); } } @@ -168,7 +168,7 @@ public class RepoSequenceTest extends GerritBaseTests { @Test public void failOnInvalidValue() throws Exception { ObjectId id = writeBlob("id", "not a number"); - exception.expect(OrmException.class); + exception.expect(StorageException.class); exception.expectMessage("invalid value in refs/sequences/id blob at " + id.name()); newSequence("id", 1, 3).next(); } @@ -181,7 +181,7 @@ public class RepoSequenceTest extends GerritBaseTests { try { newSequence("id", 1, 3).next(); fail(); - } catch (OrmException e) { + } catch (StorageException e) { assertThat(e.getCause()).isInstanceOf(ExecutionException.class); assertThat(e.getCause().getCause()).isInstanceOf(IncorrectObjectTypeException.class); } @@ -200,7 +200,7 @@ public class RepoSequenceTest extends GerritBaseTests { RetryerBuilder.newBuilder() .withStopStrategy(StopStrategies.stopAfterAttempt(3)) .build()); - exception.expect(OrmException.class); + exception.expect(StorageException.class); exception.expectMessage("Failed to update refs/sequences/id: LOCK_FAILURE"); s.next(); } @@ -335,7 +335,7 @@ public class RepoSequenceTest extends GerritBaseTests { RetryerBuilder.newBuilder() .withStopStrategy(StopStrategies.stopAfterAttempt(3)) .build()); - exception.expect(OrmException.class); + exception.expect(StorageException.class); exception.expectMessage("Failed to update refs/sequences/id: LOCK_FAILURE"); s.increaseTo(2); } diff --git a/javatests/com/google/gerrit/server/query/change/BUILD b/javatests/com/google/gerrit/server/query/change/BUILD index b488e021ba..e8a63b8773 100644 --- a/javatests/com/google/gerrit/server/query/change/BUILD +++ b/javatests/com/google/gerrit/server/query/change/BUILD @@ -20,7 +20,6 @@ java_library( "//java/com/google/gerrit/server/schema", "//java/com/google/gerrit/server/util/time", "//java/com/google/gerrit/testing:gerrit-test-util", - "//java/com/google/gwtorm", "//lib:guava", "//lib/guice", "//lib/jgit/org.eclipse.jgit:jgit", @@ -42,7 +41,6 @@ junit_tests( "//java/com/google/gerrit/reviewdb:server", "//java/com/google/gerrit/server", "//java/com/google/gerrit/testing:gerrit-test-util", - "//java/com/google/gwtorm", "//lib:guava", "//lib/guice", "//lib/jgit/org.eclipse.jgit:jgit", @@ -60,13 +58,13 @@ junit_tests( ), visibility = ["//visibility:public"], deps = [ + "//java/com/google/gerrit/exceptions", "//java/com/google/gerrit/extensions:api", "//java/com/google/gerrit/proto/testing", "//java/com/google/gerrit/reviewdb:server", "//java/com/google/gerrit/server", "//java/com/google/gerrit/server/cache/testing", "//java/com/google/gerrit/testing:gerrit-test-util", - "//java/com/google/gwtorm", "//lib:guava", "//lib/jgit/org.eclipse.jgit:jgit", "//lib/truth", diff --git a/javatests/com/google/gerrit/server/query/change/RegexPathPredicateTest.java b/javatests/com/google/gerrit/server/query/change/RegexPathPredicateTest.java index 9944a42e04..0303a5a6c3 100644 --- a/javatests/com/google/gerrit/server/query/change/RegexPathPredicateTest.java +++ b/javatests/com/google/gerrit/server/query/change/RegexPathPredicateTest.java @@ -17,16 +17,16 @@ package com.google.gerrit.server.query.change; import static org.junit.Assert.assertFalse; import static org.junit.Assert.assertTrue; +import com.google.gerrit.exceptions.StorageException; import com.google.gerrit.reviewdb.client.Change; import com.google.gerrit.reviewdb.client.Project; import com.google.gerrit.testing.GerritBaseTests; -import com.google.gwtorm.server.OrmException; import java.util.Arrays; import org.junit.Test; public class RegexPathPredicateTest extends GerritBaseTests { @Test - public void prefixOnlyOptimization() throws OrmException { + public void prefixOnlyOptimization() throws StorageException { RegexPathPredicate p = predicate("^a/b/.*"); assertTrue(p.match(change("a/b/source.c"))); assertFalse(p.match(change("source.c"))); @@ -36,7 +36,7 @@ public class RegexPathPredicateTest extends GerritBaseTests { } @Test - public void prefixReducesSearchSpace() throws OrmException { + public void prefixReducesSearchSpace() throws StorageException { RegexPathPredicate p = predicate("^a/b/.*\\.[ch]"); assertTrue(p.match(change("a/b/source.c"))); assertFalse(p.match(change("a/b/source.res"))); @@ -46,7 +46,7 @@ public class RegexPathPredicateTest extends GerritBaseTests { } @Test - public void fileExtension_Constant() throws OrmException { + public void fileExtension_Constant() throws StorageException { RegexPathPredicate p = predicate("^.*\\.res"); assertTrue(p.match(change("test.res"))); assertTrue(p.match(change("foo/bar/test.res"))); @@ -54,7 +54,7 @@ public class RegexPathPredicateTest extends GerritBaseTests { } @Test - public void fileExtension_CharacterGroup() throws OrmException { + public void fileExtension_CharacterGroup() throws StorageException { RegexPathPredicate p = predicate("^.*\\.[ch]"); assertTrue(p.match(change("test.c"))); assertTrue(p.match(change("test.h"))); @@ -62,7 +62,7 @@ public class RegexPathPredicateTest extends GerritBaseTests { } @Test - public void endOfString() throws OrmException { + public void endOfString() throws StorageException { assertTrue(predicate("^a$").match(change("a"))); assertFalse(predicate("^a$").match(change("a$"))); @@ -71,7 +71,7 @@ public class RegexPathPredicateTest extends GerritBaseTests { } @Test - public void exactMatch() throws OrmException { + public void exactMatch() throws StorageException { RegexPathPredicate p = predicate("^foo.c"); assertTrue(p.match(change("foo.c"))); assertFalse(p.match(change("foo.cc"))); @@ -82,7 +82,7 @@ public class RegexPathPredicateTest extends GerritBaseTests { return new RegexPathPredicate(pattern); } - private static ChangeData change(String... files) throws OrmException { + private static ChangeData change(String... files) throws StorageException { Arrays.sort(files); ChangeData cd = ChangeData.createForTest(new Project.NameKey("project"), new Change.Id(1), 1); cd.setCurrentFilePaths(Arrays.asList(files)); diff --git a/javatests/com/google/gerrit/server/schema/NoteDbSchemaUpdaterTest.java b/javatests/com/google/gerrit/server/schema/NoteDbSchemaUpdaterTest.java index b23219bf20..af25d8ba5b 100644 --- a/javatests/com/google/gerrit/server/schema/NoteDbSchemaUpdaterTest.java +++ b/javatests/com/google/gerrit/server/schema/NoteDbSchemaUpdaterTest.java @@ -22,6 +22,7 @@ import static com.google.gerrit.server.schema.NoteDbSchemaUpdater.requiredUpgrad import com.google.common.collect.ImmutableList; import com.google.common.collect.ImmutableSortedMap; import com.google.common.collect.ImmutableSortedSet; +import com.google.gerrit.exceptions.StorageException; import com.google.gerrit.reviewdb.client.RefNames; import com.google.gerrit.server.config.AllProjectsName; import com.google.gerrit.server.config.AllUsersName; @@ -33,7 +34,6 @@ import com.google.gerrit.server.notedb.Sequences; import com.google.gerrit.testing.GerritBaseTests; import com.google.gerrit.testing.InMemoryRepositoryManager; import com.google.gerrit.testing.TestUpdateUI; -import com.google.gwtorm.server.OrmException; import java.io.IOException; import java.util.ArrayList; import java.util.List; @@ -64,8 +64,8 @@ public class NoteDbSchemaUpdaterTest extends GerritBaseTests { public void downgradeNotSupported() throws Exception { try { requiredUpgrades(14, versions(10, 11, 12, 13)); - assert_().fail("expected OrmException"); - } catch (OrmException e) { + assert_().fail("expected StorageException"); + } catch (StorageException e) { assertThat(e) .hasMessageThat() .contains("Cannot downgrade NoteDb schema from version 14 to 13"); @@ -78,8 +78,8 @@ public class NoteDbSchemaUpdaterTest extends GerritBaseTests { assertThat(requiredUpgrades(9, versions)).containsExactly(10, 11, 12).inOrder(); try { requiredUpgrades(8, versions); - assert_().fail("expected OrmException"); - } catch (OrmException e) { + assert_().fail("expected StorageException"); + } catch (StorageException e) { assertThat(e).hasMessageThat().contains("Cannot skip NoteDb schema from version 8 to 10"); } } @@ -122,21 +122,21 @@ public class NoteDbSchemaUpdaterTest extends GerritBaseTests { } @Override - public void create() throws OrmException, IOException { + public void create() throws StorageException, IOException { try (Repository repo = repoManager.createRepository(allProjectsName)) { if (initialVersion.isPresent()) { TestRepository tr = new TestRepository<>(repo); tr.update(RefNames.REFS_VERSION, tr.blob(initialVersion.get().toString())); } } catch (Exception e) { - throw new OrmException(e); + throw new StorageException(e); } repoManager.createRepository(allUsersName).close(); setUp(); } @Override - public void ensureCreated() throws OrmException, IOException { + public void ensureCreated() throws StorageException, IOException { try { repoManager.openRepository(allProjectsName).close(); } catch (RepositoryNotFoundException e) { @@ -152,7 +152,7 @@ public class NoteDbSchemaUpdaterTest extends GerritBaseTests { cfg.setString("noteDb", "changes", "disableReviewDb", "true"); } - protected void seedGroupSequenceRef() throws OrmException { + protected void seedGroupSequenceRef() throws StorageException { new RepoSequence( repoManager, GitReferenceUpdated.DISABLED, @@ -166,9 +166,9 @@ public class NoteDbSchemaUpdaterTest extends GerritBaseTests { /** * Test-specific setup. * - * @throws OrmException if an error occurs. + * @throws StorageException if an error occurs. */ - protected void setUp() throws OrmException {} + protected void setUp() throws StorageException {} ImmutableList update() throws Exception { updater.update( @@ -211,7 +211,7 @@ public class NoteDbSchemaUpdaterTest extends GerritBaseTests { TestUpdate u = new TestUpdate(Optional.empty()) { @Override - public void setUp() throws OrmException { + public void setUp() throws StorageException { setNotesMigrationConfig(); seedGroupSequenceRef(); } @@ -231,14 +231,14 @@ public class NoteDbSchemaUpdaterTest extends GerritBaseTests { TestUpdate u = new TestUpdate(Optional.empty()) { @Override - public void setUp() throws OrmException { + public void setUp() throws StorageException { seedGroupSequenceRef(); } }; try { u.update(); - assert_().fail("expected OrmException"); - } catch (OrmException e) { + assert_().fail("expected StorageException"); + } catch (StorageException e) { assertThat(e).hasMessageThat().contains("NoteDb change migration was not completed"); } assertThat(u.getMessages()).isEmpty(); @@ -256,8 +256,8 @@ public class NoteDbSchemaUpdaterTest extends GerritBaseTests { }; try { u.update(); - assert_().fail("expected OrmException"); - } catch (OrmException e) { + assert_().fail("expected StorageException"); + } catch (StorageException e) { assertThat(e).hasMessageThat().contains("upgrade to 2.16.x first"); } assertThat(u.getMessages()).isEmpty(); diff --git a/javatests/com/google/gerrit/server/schema/NoteDbSchemaVersionManagerTest.java b/javatests/com/google/gerrit/server/schema/NoteDbSchemaVersionManagerTest.java index a0176de2ca..9c62d7f870 100644 --- a/javatests/com/google/gerrit/server/schema/NoteDbSchemaVersionManagerTest.java +++ b/javatests/com/google/gerrit/server/schema/NoteDbSchemaVersionManagerTest.java @@ -18,11 +18,11 @@ import static com.google.common.truth.Truth.assertThat; import static com.google.common.truth.Truth.assert_; import static com.google.gerrit.reviewdb.client.RefNames.REFS_VERSION; +import com.google.gerrit.exceptions.StorageException; import com.google.gerrit.server.config.AllProjectsName; import com.google.gerrit.server.git.GitRepositoryManager; import com.google.gerrit.testing.GerritBaseTests; import com.google.gerrit.testing.InMemoryRepositoryManager; -import com.google.gwtorm.server.OrmException; import org.eclipse.jgit.junit.TestRepository; import org.eclipse.jgit.lib.ObjectId; import org.junit.Before; @@ -57,8 +57,8 @@ public class NoteDbSchemaVersionManagerTest extends GerritBaseTests { tr.update(REFS_VERSION, blobId); try { manager.read(); - assert_().fail("expected OrmException"); - } catch (OrmException e) { + assert_().fail("expected StorageException"); + } catch (StorageException e) { assertThat(e) .hasMessageThat() .isEqualTo("invalid value in refs/meta/version blob at " + blobId.name()); @@ -83,8 +83,8 @@ public class NoteDbSchemaVersionManagerTest extends GerritBaseTests { tr.update(REFS_VERSION, tr.blob("123")); try { manager.increment(456); - assert_().fail("expected OrmException"); - } catch (OrmException e) { + assert_().fail("expected StorageException"); + } catch (StorageException e) { assertThat(e) .hasMessageThat() .isEqualTo("Expected old version 456 for refs/meta/version, found 123"); diff --git a/javatests/com/google/gerrit/server/update/BUILD b/javatests/com/google/gerrit/server/update/BUILD index 697397af27..efe24d5369 100644 --- a/javatests/com/google/gerrit/server/update/BUILD +++ b/javatests/com/google/gerrit/server/update/BUILD @@ -12,7 +12,6 @@ junit_tests( "//java/com/google/gerrit/server/schema", "//java/com/google/gerrit/server/util/time", "//java/com/google/gerrit/testing:gerrit-test-util", - "//java/com/google/gwtorm", "//lib:guava", "//lib/guice", "//lib/jgit/org.eclipse.jgit:jgit", diff --git a/javatests/com/google/gerrit/server/util/git/BUILD b/javatests/com/google/gerrit/server/util/git/BUILD index 7a252510ba..cdc823edd5 100644 --- a/javatests/com/google/gerrit/server/util/git/BUILD +++ b/javatests/com/google/gerrit/server/util/git/BUILD @@ -12,7 +12,6 @@ junit_tests( "//java/com/google/gerrit/server/util/git", "//java/com/google/gerrit/testing:gerrit-test-util", "//java/com/google/gerrit/truth", - "//java/com/google/gwtorm", "//java/org/eclipse/jgit:server", "//lib:gson", "//lib:guava", diff --git a/plugins/BUILD b/plugins/BUILD index 4837b67449..8baa3c71fe 100644 --- a/plugins/BUILD +++ b/plugins/BUILD @@ -31,6 +31,7 @@ EXPORTS = [ "//antlr3:query_parser", "//java/com/google/gerrit/common:annotations", "//java/com/google/gerrit/common:server", + "//java/com/google/gerrit/exceptions", "//java/com/google/gerrit/extensions:api", "//java/com/google/gerrit/git", "//java/com/google/gerrit/index", @@ -50,7 +51,6 @@ EXPORTS = [ "//java/com/google/gerrit/server/util/time", "//java/com/google/gerrit/util/cli", "//java/com/google/gerrit/util/http", - "//java/com/google/gwtorm", "//lib/antlr:java-runtime", "//lib/auto:auto-value-annotations", "//lib/commons:compress", diff --git a/plugins/delete-project b/plugins/delete-project index 2488351e73..4401de0976 160000 --- a/plugins/delete-project +++ b/plugins/delete-project @@ -1 +1 @@ -Subproject commit 2488351e730e4567f6e4a96a8e13fb9bf56f9f0c +Subproject commit 4401de09767d6e8655d29377f95145840a73feaf diff --git a/plugins/replication b/plugins/replication index c0a25b0803..dc67690a5f 160000 --- a/plugins/replication +++ b/plugins/replication @@ -1 +1 @@ -Subproject commit c0a25b0803252e6eca5997766e70cbe5edbc90d6 +Subproject commit dc67690a5fed2cc339a2e8b4731e0982d3e2ca81 diff --git a/plugins/reviewnotes b/plugins/reviewnotes index d7ba4997b5..49191ba199 160000 --- a/plugins/reviewnotes +++ b/plugins/reviewnotes @@ -1 +1 @@ -Subproject commit d7ba4997b5c0038c85f6393b73a9ca16ca4fb927 +Subproject commit 49191ba1997fa2465581313da04c402af8e7c2fc diff --git a/plugins/singleusergroup b/plugins/singleusergroup index 4a63efa29d..25bcffa8e0 160000 --- a/plugins/singleusergroup +++ b/plugins/singleusergroup @@ -1 +1 @@ -Subproject commit 4a63efa29d3c48e6cda21dee7b2c9c559eddc774 +Subproject commit 25bcffa8e0a35df7f62b70b7dd47d2284f3a777a