Rename OrmException to StorageException and move to exceptions package

Subclasses are also renamed:
 * OrmDuplicateKeyException -> DuplicateKeyException
 * OrmRuntimeException -> StorageRuntimeException

Change-Id: I0e934f177e98667ec7cb9912f246ac649a4efd99
This commit is contained in:
Dave Borowitz
2019-01-15 18:45:22 -08:00
parent 9dd73c8a71
commit 62f32fcfd6
500 changed files with 1973 additions and 1941 deletions

View File

@@ -455,7 +455,7 @@ its own custom event class derived from
---- ----
import com.google.gerrit.common.EventDispatcher; import com.google.gerrit.common.EventDispatcher;
import com.google.gerrit.extensions.registration.DynamicItem; import com.google.gerrit.extensions.registration.DynamicItem;
import com.google.gwtorm.server.OrmException; import com.google.exceptions.StorageException;
import com.google.inject.Inject; import com.google.inject.Inject;
class MyPlugin { class MyPlugin {
@@ -469,7 +469,7 @@ class MyPlugin {
private void postEvent(MyPluginEvent event) { private void postEvent(MyPluginEvent event) {
try { try {
eventDispatcher.get().postEvent(event); eventDispatcher.get().postEvent(event);
} catch (OrmException e) { } catch (StorageException e) {
// error handling // error handling
} }
} }

View File

@@ -53,6 +53,7 @@ import com.google.gerrit.common.data.Permission;
import com.google.gerrit.common.data.PermissionRange; import com.google.gerrit.common.data.PermissionRange;
import com.google.gerrit.common.data.PermissionRule; import com.google.gerrit.common.data.PermissionRule;
import com.google.gerrit.common.data.PermissionRule.Action; import com.google.gerrit.common.data.PermissionRule.Action;
import com.google.gerrit.exceptions.StorageException;
import com.google.gerrit.extensions.api.GerritApi; import com.google.gerrit.extensions.api.GerritApi;
import com.google.gerrit.extensions.api.changes.ReviewInput; import com.google.gerrit.extensions.api.changes.ReviewInput;
import com.google.gerrit.extensions.api.changes.RevisionApi; import com.google.gerrit.extensions.api.changes.RevisionApi;
@@ -132,7 +133,6 @@ import com.google.gerrit.testing.FakeEmailSender;
import com.google.gerrit.testing.FakeEmailSender.Message; import com.google.gerrit.testing.FakeEmailSender.Message;
import com.google.gerrit.testing.SshMode; import com.google.gerrit.testing.SshMode;
import com.google.gson.Gson; import com.google.gson.Gson;
import com.google.gwtorm.server.OrmException;
import com.google.inject.Inject; import com.google.inject.Inject;
import com.google.inject.Module; import com.google.inject.Module;
import com.google.inject.Provider; import com.google.inject.Provider;
@@ -1087,7 +1087,7 @@ public abstract class AbstractDaemonTest {
.inOrder(); .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); return changeDataFactory.create(project, psId.getParentKey()).patchSet(psId);
} }
@@ -1416,7 +1416,7 @@ public abstract class AbstractDaemonTest {
} }
protected void watch(PushOneCommit.Result r, ProjectWatchInfoConfiguration config) protected void watch(PushOneCommit.Result r, ProjectWatchInfoConfiguration config)
throws OrmException, RestApiException { throws StorageException, RestApiException {
watch(r.getChange().project().get(), config); watch(r.getChange().project().get(), config);
} }

View File

@@ -21,6 +21,7 @@ import com.google.common.collect.ImmutableSet;
import com.google.common.collect.Sets; import com.google.common.collect.Sets;
import com.google.gerrit.common.Nullable; import com.google.gerrit.common.Nullable;
import com.google.gerrit.exceptions.NoSuchGroupException; import com.google.gerrit.exceptions.NoSuchGroupException;
import com.google.gerrit.exceptions.StorageException;
import com.google.gerrit.reviewdb.client.Account; import com.google.gerrit.reviewdb.client.Account;
import com.google.gerrit.reviewdb.client.AccountGroup; import com.google.gerrit.reviewdb.client.AccountGroup;
import com.google.gerrit.server.ServerInitiated; import com.google.gerrit.server.ServerInitiated;
@@ -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.GroupsUpdate;
import com.google.gerrit.server.group.db.InternalGroupUpdate; import com.google.gerrit.server.group.db.InternalGroupUpdate;
import com.google.gerrit.server.notedb.Sequences; import com.google.gerrit.server.notedb.Sequences;
import com.google.gwtorm.server.OrmException;
import com.google.inject.Inject; import com.google.inject.Inject;
import com.google.inject.Provider; import com.google.inject.Provider;
import com.google.inject.Singleton; import com.google.inject.Singleton;
@@ -157,7 +157,7 @@ public class AccountCreator {
} }
private void addGroupMember(AccountGroup.UUID groupUuid, Account.Id accountId) private void addGroupMember(AccountGroup.UUID groupUuid, Account.Id accountId)
throws OrmException, IOException, NoSuchGroupException, ConfigInvalidException { throws StorageException, IOException, NoSuchGroupException, ConfigInvalidException {
InternalGroupUpdate groupUpdate = InternalGroupUpdate groupUpdate =
InternalGroupUpdate.builder() InternalGroupUpdate.builder()
.setMemberModification(memberIds -> Sets.union(memberIds, ImmutableSet.of(accountId))) .setMemberModification(memberIds -> Sets.union(memberIds, ImmutableSet.of(accountId)))

View File

@@ -34,7 +34,6 @@ java_library(
"//java/com/google/gerrit/server/restapi", "//java/com/google/gerrit/server/restapi",
"//java/com/google/gerrit/sshd", "//java/com/google/gerrit/sshd",
"//java/com/google/gerrit/testing:gerrit-test-util", "//java/com/google/gerrit/testing:gerrit-test-util",
"//java/com/google/gwtorm",
"//lib:args4j", "//lib:args4j",
"//lib:gson", "//lib:gson",
"//lib:guava-retrying", "//lib:guava-retrying",
@@ -117,7 +116,6 @@ java_library2(
"//java/com/google/gerrit/server/schema", "//java/com/google/gerrit/server/schema",
"//java/com/google/gerrit/server/util/time", "//java/com/google/gerrit/server/util/time",
"//java/com/google/gerrit/sshd", "//java/com/google/gerrit/sshd",
"//java/com/google/gwtorm",
"//lib:args4j", "//lib:args4j",
"//lib:gson", "//lib:gson",
"//lib:guava-retrying", "//lib:guava-retrying",

View File

@@ -17,6 +17,8 @@ package com.google.gerrit.acceptance;
import static com.google.inject.Scopes.SINGLETON; import static com.google.inject.Scopes.SINGLETON;
import com.google.gerrit.common.Nullable; 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.extensions.events.LifecycleListener;
import com.google.gerrit.lifecycle.LifecycleModule; import com.google.gerrit.lifecycle.LifecycleModule;
import com.google.gerrit.metrics.DisabledMetricMaker; 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.SchemaCreator;
import com.google.gerrit.server.schema.SchemaModule; import com.google.gerrit.server.schema.SchemaModule;
import com.google.gerrit.testing.InMemoryRepositoryManager; 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.Inject;
import com.google.inject.ProvisionException; import com.google.inject.ProvisionException;
import java.io.IOException; import java.io.IOException;
@@ -91,8 +91,8 @@ class InMemoryTestingDatabaseModule extends LifecycleModule {
public void start() { public void start() {
try { try {
schemaCreator.ensureCreated(); schemaCreator.ensureCreated();
} catch (OrmException | IOException | ConfigInvalidException e) { } catch (StorageException | IOException | ConfigInvalidException e) {
throw new OrmRuntimeException(e); throw new StorageRuntimeException(e);
} }
} }

View File

@@ -24,6 +24,7 @@ import com.google.common.collect.ImmutableMap;
import com.google.common.collect.Iterables; import com.google.common.collect.Iterables;
import com.google.common.collect.Sets; import com.google.common.collect.Sets;
import com.google.gerrit.common.Nullable; import com.google.gerrit.common.Nullable;
import com.google.gerrit.exceptions.StorageException;
import com.google.gerrit.reviewdb.client.Account; import com.google.gerrit.reviewdb.client.Account;
import com.google.gerrit.reviewdb.client.Change; import com.google.gerrit.reviewdb.client.Change;
import com.google.gerrit.reviewdb.client.PatchSet; import com.google.gerrit.reviewdb.client.PatchSet;
@@ -32,7 +33,6 @@ import com.google.gerrit.server.notedb.ChangeNotes;
import com.google.gerrit.server.notedb.ReviewerStateInternal; import com.google.gerrit.server.notedb.ReviewerStateInternal;
import com.google.gerrit.server.query.change.ChangeData; import com.google.gerrit.server.query.change.ChangeData;
import com.google.gerrit.server.query.change.InternalChangeQuery; import com.google.gerrit.server.query.change.InternalChangeQuery;
import com.google.gwtorm.server.OrmException;
import com.google.inject.Provider; import com.google.inject.Provider;
import com.google.inject.assistedinject.Assisted; import com.google.inject.assistedinject.Assisted;
import com.google.inject.assistedinject.AssistedInject; import com.google.inject.assistedinject.AssistedInject;
@@ -334,15 +334,15 @@ public class PushOneCommit {
this.resSubj = subject; this.resSubj = subject;
} }
public ChangeData getChange() throws OrmException { public ChangeData getChange() throws StorageException {
return Iterables.getOnlyElement(queryProvider.get().byKeyPrefix(changeId)); return Iterables.getOnlyElement(queryProvider.get().byKeyPrefix(changeId));
} }
public PatchSet getPatchSet() throws OrmException { public PatchSet getPatchSet() throws StorageException {
return getChange().currentPatchSet(); return getChange().currentPatchSet();
} }
public PatchSet.Id getPatchSetId() throws OrmException { public PatchSet.Id getPatchSetId() throws StorageException {
return getChange().change().currentPatchSetId(); return getChange().change().currentPatchSetId();
} }
@@ -360,7 +360,7 @@ public class PushOneCommit {
public void assertChange( public void assertChange(
Change.Status expectedStatus, String expectedTopic, TestAccount... expectedReviewers) Change.Status expectedStatus, String expectedTopic, TestAccount... expectedReviewers)
throws OrmException { throws StorageException {
assertChange( assertChange(
expectedStatus, expectedTopic, Arrays.asList(expectedReviewers), ImmutableList.of()); expectedStatus, expectedTopic, Arrays.asList(expectedReviewers), ImmutableList.of());
} }
@@ -370,7 +370,7 @@ public class PushOneCommit {
String expectedTopic, String expectedTopic,
List<TestAccount> expectedReviewers, List<TestAccount> expectedReviewers,
List<TestAccount> expectedCcs) List<TestAccount> expectedCcs)
throws OrmException { throws StorageException {
Change c = getChange().change(); Change c = getChange().change();
assertThat(c.getSubject()).isEqualTo(resSubj); assertThat(c.getSubject()).isEqualTo(resSubj);
assertThat(c.getStatus()).isEqualTo(expectedStatus); assertThat(c.getStatus()).isEqualTo(expectedStatus);
@@ -381,7 +381,7 @@ public class PushOneCommit {
private void assertReviewers( private void assertReviewers(
Change c, ReviewerStateInternal state, List<TestAccount> expectedReviewers) Change c, ReviewerStateInternal state, List<TestAccount> expectedReviewers)
throws OrmException { throws StorageException {
Iterable<Account.Id> actualIds = Iterable<Account.Id> actualIds =
approvalsUtil.getReviewers(notesFactory.createChecked(c)).byState(state); approvalsUtil.getReviewers(notesFactory.createChecked(c)).byState(state);
assertThat(actualIds) assertThat(actualIds)

View File

@@ -16,6 +16,7 @@ package com.google.gerrit.acceptance.testsuite.account;
import static com.google.common.base.Preconditions.checkState; import static com.google.common.base.Preconditions.checkState;
import com.google.gerrit.exceptions.StorageException;
import com.google.gerrit.reviewdb.client.Account; import com.google.gerrit.reviewdb.client.Account;
import com.google.gerrit.server.ServerInitiated; import com.google.gerrit.server.ServerInitiated;
import com.google.gerrit.server.account.AccountState; import com.google.gerrit.server.account.AccountState;
@@ -24,7 +25,6 @@ import com.google.gerrit.server.account.AccountsUpdate;
import com.google.gerrit.server.account.InternalAccountUpdate; import com.google.gerrit.server.account.InternalAccountUpdate;
import com.google.gerrit.server.account.externalids.ExternalId; import com.google.gerrit.server.account.externalids.ExternalId;
import com.google.gerrit.server.notedb.Sequences; import com.google.gerrit.server.notedb.Sequences;
import com.google.gwtorm.server.OrmException;
import com.google.inject.Inject; import com.google.inject.Inject;
import java.io.IOException; import java.io.IOException;
import java.util.Optional; import java.util.Optional;
@@ -68,7 +68,7 @@ public class AccountOperationsImpl implements AccountOperations {
} }
private AccountState createAccount(AccountsUpdate.AccountUpdater accountUpdater) private AccountState createAccount(AccountsUpdate.AccountUpdater accountUpdater)
throws OrmException, IOException, ConfigInvalidException { throws StorageException, IOException, ConfigInvalidException {
Account.Id accountId = new Account.Id(seq.nextAccountId()); Account.Id accountId = new Account.Id(seq.nextAccountId());
return accountsUpdate.insert("Create Test Account", accountId, accountUpdater); return accountsUpdate.insert("Create Test Account", accountId, accountUpdater);
} }
@@ -146,7 +146,7 @@ public class AccountOperationsImpl implements AccountOperations {
} }
private void updateAccount(TestAccountUpdate accountUpdate) private void updateAccount(TestAccountUpdate accountUpdate)
throws OrmException, IOException, ConfigInvalidException { throws StorageException, IOException, ConfigInvalidException {
AccountsUpdate.AccountUpdater accountUpdater = AccountsUpdate.AccountUpdater accountUpdater =
(account, updateBuilder) -> fillBuilder(updateBuilder, accountUpdate, accountId); (account, updateBuilder) -> fillBuilder(updateBuilder, accountUpdate, accountId);
Optional<AccountState> updatedAccount = updateAccount(accountUpdater); Optional<AccountState> updatedAccount = updateAccount(accountUpdater);
@@ -154,7 +154,7 @@ public class AccountOperationsImpl implements AccountOperations {
} }
private Optional<AccountState> updateAccount(AccountsUpdate.AccountUpdater accountUpdater) private Optional<AccountState> updateAccount(AccountsUpdate.AccountUpdater accountUpdater)
throws OrmException, IOException, ConfigInvalidException { throws StorageException, IOException, ConfigInvalidException {
return accountsUpdate.update("Update Test Account", accountId, accountUpdater); return accountsUpdate.update("Update Test Account", accountId, accountUpdater);
} }

View File

@@ -16,7 +16,9 @@ package com.google.gerrit.acceptance.testsuite.group;
import static com.google.common.base.Preconditions.checkState; 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.NoSuchGroupException;
import com.google.gerrit.exceptions.StorageException;
import com.google.gerrit.reviewdb.client.AccountGroup; import com.google.gerrit.reviewdb.client.AccountGroup;
import com.google.gerrit.server.GerritPersonIdent; import com.google.gerrit.server.GerritPersonIdent;
import com.google.gerrit.server.ServerInitiated; import com.google.gerrit.server.ServerInitiated;
@@ -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.InternalGroupCreation;
import com.google.gerrit.server.group.db.InternalGroupUpdate; import com.google.gerrit.server.group.db.InternalGroupUpdate;
import com.google.gerrit.server.notedb.Sequences; 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 com.google.inject.Inject;
import java.io.IOException; import java.io.IOException;
import java.util.Optional; import java.util.Optional;
@@ -70,7 +70,7 @@ public class GroupOperationsImpl implements GroupOperations {
} }
private AccountGroup.UUID createNewGroup(TestGroupCreation groupCreation) private AccountGroup.UUID createNewGroup(TestGroupCreation groupCreation)
throws ConfigInvalidException, IOException, OrmException { throws ConfigInvalidException, IOException, StorageException {
InternalGroupCreation internalGroupCreation = toInternalGroupCreation(groupCreation); InternalGroupCreation internalGroupCreation = toInternalGroupCreation(groupCreation);
InternalGroupUpdate internalGroupUpdate = toInternalGroupUpdate(groupCreation); InternalGroupUpdate internalGroupUpdate = toInternalGroupUpdate(groupCreation);
InternalGroup internalGroup = InternalGroup internalGroup =
@@ -79,7 +79,7 @@ public class GroupOperationsImpl implements GroupOperations {
} }
private InternalGroupCreation toInternalGroupCreation(TestGroupCreation groupCreation) private InternalGroupCreation toInternalGroupCreation(TestGroupCreation groupCreation)
throws OrmException { throws StorageException {
AccountGroup.Id groupId = new AccountGroup.Id(seq.nextGroupId()); AccountGroup.Id groupId = new AccountGroup.Id(seq.nextGroupId());
String groupName = groupCreation.name().orElse("group-with-id-" + groupId.get()); String groupName = groupCreation.name().orElse("group-with-id-" + groupId.get());
AccountGroup.UUID groupUuid = GroupUUID.make(groupName, serverIdent); AccountGroup.UUID groupUuid = GroupUUID.make(groupName, serverIdent);
@@ -148,7 +148,7 @@ public class GroupOperationsImpl implements GroupOperations {
} }
private void updateGroup(TestGroupUpdate groupUpdate) private void updateGroup(TestGroupUpdate groupUpdate)
throws OrmDuplicateKeyException, NoSuchGroupException, ConfigInvalidException, IOException { throws DuplicateKeyException, NoSuchGroupException, ConfigInvalidException, IOException {
InternalGroupUpdate internalGroupUpdate = toInternalGroupUpdate(groupUpdate); InternalGroupUpdate internalGroupUpdate = toInternalGroupUpdate(groupUpdate);
groupsUpdate.updateGroup(groupUuid, internalGroupUpdate); groupsUpdate.updateGroup(groupUuid, internalGroupUpdate);
} }

View File

@@ -32,6 +32,7 @@ import com.google.gerrit.elasticsearch.ElasticMapping.MappingProperties;
import com.google.gerrit.elasticsearch.builders.QueryBuilder; import com.google.gerrit.elasticsearch.builders.QueryBuilder;
import com.google.gerrit.elasticsearch.builders.SearchSourceBuilder; import com.google.gerrit.elasticsearch.builders.SearchSourceBuilder;
import com.google.gerrit.elasticsearch.bulk.DeleteRequest; import com.google.gerrit.elasticsearch.bulk.DeleteRequest;
import com.google.gerrit.exceptions.StorageException;
import com.google.gerrit.index.FieldDef; import com.google.gerrit.index.FieldDef;
import com.google.gerrit.index.FieldType; import com.google.gerrit.index.FieldType;
import com.google.gerrit.index.Index; import com.google.gerrit.index.Index;
@@ -53,7 +54,6 @@ import com.google.gson.JsonArray;
import com.google.gson.JsonElement; import com.google.gson.JsonElement;
import com.google.gson.JsonObject; import com.google.gson.JsonObject;
import com.google.gson.JsonParser; import com.google.gson.JsonParser;
import com.google.gwtorm.server.OrmException;
import com.google.protobuf.MessageLite; import com.google.protobuf.MessageLite;
import java.io.IOException; import java.io.IOException;
import java.io.InputStream; import java.io.InputStream;
@@ -377,16 +377,16 @@ abstract class AbstractElasticIndex<K, V> implements Index<K, V> {
} }
@Override @Override
public ResultSet<V> read() throws OrmException { public ResultSet<V> read() throws StorageException {
return readImpl((doc) -> AbstractElasticIndex.this.fromDocument(doc, opts.fields())); return readImpl((doc) -> AbstractElasticIndex.this.fromDocument(doc, opts.fields()));
} }
@Override @Override
public ResultSet<FieldBundle> readRaw() throws OrmException { public ResultSet<FieldBundle> readRaw() throws StorageException {
return readImpl(AbstractElasticIndex.this::toFieldBundle); return readImpl(AbstractElasticIndex.this::toFieldBundle);
} }
private <T> ResultSet<T> readImpl(Function<JsonObject, T> mapper) throws OrmException { private <T> ResultSet<T> readImpl(Function<JsonObject, T> mapper) throws StorageException {
try { try {
String uri = getURI(index, SEARCH); String uri = getURI(index, SEARCH);
Response response = Response response =
@@ -412,7 +412,7 @@ abstract class AbstractElasticIndex<K, V> implements Index<K, V> {
} }
return new ListResultSet<>(ImmutableList.of()); return new ListResultSet<>(ImmutableList.of());
} catch (IOException e) { } catch (IOException e) {
throw new OrmException(e); throw new StorageException(e);
} }
} }
} }

View File

@@ -4,6 +4,7 @@ java_library(
visibility = ["//visibility:public"], visibility = ["//visibility:public"],
deps = [ deps = [
"//java/com/google/gerrit/common:annotations", "//java/com/google/gerrit/common:annotations",
"//java/com/google/gerrit/exceptions",
"//java/com/google/gerrit/extensions:api", "//java/com/google/gerrit/extensions:api",
"//java/com/google/gerrit/index", "//java/com/google/gerrit/index",
"//java/com/google/gerrit/index:query_exception", "//java/com/google/gerrit/index:query_exception",
@@ -12,7 +13,6 @@ java_library(
"//java/com/google/gerrit/proto", "//java/com/google/gerrit/proto",
"//java/com/google/gerrit/reviewdb:server", "//java/com/google/gerrit/reviewdb:server",
"//java/com/google/gerrit/server", "//java/com/google/gerrit/server",
"//java/com/google/gwtorm",
"//lib:gson", "//lib:gson",
"//lib:guava", "//lib:guava",
"//lib:protobuf", "//lib:protobuf",

View File

@@ -33,6 +33,7 @@ import com.google.gerrit.elasticsearch.bulk.BulkRequest;
import com.google.gerrit.elasticsearch.bulk.DeleteRequest; import com.google.gerrit.elasticsearch.bulk.DeleteRequest;
import com.google.gerrit.elasticsearch.bulk.IndexRequest; import com.google.gerrit.elasticsearch.bulk.IndexRequest;
import com.google.gerrit.elasticsearch.bulk.UpdateRequest; import com.google.gerrit.elasticsearch.bulk.UpdateRequest;
import com.google.gerrit.exceptions.StorageException;
import com.google.gerrit.index.QueryOptions; import com.google.gerrit.index.QueryOptions;
import com.google.gerrit.index.Schema; import com.google.gerrit.index.Schema;
import com.google.gerrit.index.query.DataSource; 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.JsonArray;
import com.google.gson.JsonElement; import com.google.gson.JsonElement;
import com.google.gson.JsonObject; import com.google.gson.JsonObject;
import com.google.gwtorm.server.OrmException;
import com.google.inject.Inject; import com.google.inject.Inject;
import com.google.inject.assistedinject.Assisted; import com.google.inject.assistedinject.Assisted;
import java.io.IOException; import java.io.IOException;
@@ -119,7 +119,7 @@ class ElasticChangeIndex extends AbstractElasticIndex<Change.Id, ChangeData>
insertIndex = CLOSED_CHANGES; insertIndex = CLOSED_CHANGES;
deleteIndex = OPEN_CHANGES; deleteIndex = OPEN_CHANGES;
} }
} catch (OrmException e) { } catch (StorageException e) {
throw new IOException(e); throw new IOException(e);
} }

View File

@@ -12,17 +12,17 @@
// See the License for the specific language governing permissions and // See the License for the specific language governing permissions and
// limitations under the License. // 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. */ /** 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; private static final long serialVersionUID = 1L;
public OrmDuplicateKeyException(String msg) { public DuplicateKeyException(String msg) {
super(msg); super(msg);
} }
public OrmDuplicateKeyException(String msg, Throwable why) { public DuplicateKeyException(String msg, Throwable why) {
super(msg, why); super(msg, why);
} }
} }

View File

@@ -12,21 +12,33 @@
// See the License for the specific language governing permissions and // See the License for the specific language governing permissions and
// limitations under the License. // 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.
*
* <p>This includes but is not limited to:
*
* <ul>
* <li>NoteDb exceptions
* <li>Secondary index exceptions
* <li>{@code AccountPatchReviewStore} exceptions
* <li>Wrapped JGit exceptions
* <li>Other wrapped {@code IOException}s
* </ul>
*/
public class StorageException extends Exception {
private static final long serialVersionUID = 1L; private static final long serialVersionUID = 1L;
public OrmRuntimeException(String message) { public StorageException(String message) {
super(message); super(message);
} }
public OrmRuntimeException(String message, Throwable why) { public StorageException(String message, Throwable why) {
super(message, why); super(message, why);
} }
public OrmRuntimeException(Throwable why) { public StorageException(Throwable why) {
super(why); super(why);
} }
} }

View File

@@ -12,21 +12,21 @@
// See the License for the specific language governing permissions and // See the License for the specific language governing permissions and
// limitations under the License. // limitations under the License.
package com.google.gwtorm.server; package com.google.gerrit.exceptions;
/** Any data store read or write error. */ /** Any data store read or write error. */
public class OrmException extends Exception { public class StorageRuntimeException extends RuntimeException {
private static final long serialVersionUID = 1L; private static final long serialVersionUID = 1L;
public OrmException(String message) { public StorageRuntimeException(String message) {
super(message); super(message);
} }
public OrmException(String message, Throwable why) { public StorageRuntimeException(String message, Throwable why) {
super(message, why); super(message, why);
} }
public OrmException(Throwable why) { public StorageRuntimeException(Throwable why) {
super(why); super(why);
} }
} }

View File

@@ -8,7 +8,6 @@ java_library(
"//java/com/google/gerrit/extensions:api", "//java/com/google/gerrit/extensions:api",
"//java/com/google/gerrit/reviewdb:server", "//java/com/google/gerrit/reviewdb:server",
"//java/com/google/gerrit/server", "//java/com/google/gerrit/server",
"//java/com/google/gwtorm",
"//lib:guava", "//lib:guava",
"//lib/bouncycastle:bcpg-neverlink", "//lib/bouncycastle:bcpg-neverlink",
"//lib/bouncycastle:bcprov-neverlink", "//lib/bouncycastle:bcprov-neverlink",

View File

@@ -22,6 +22,7 @@ import com.google.common.collect.ImmutableMap;
import com.google.common.collect.Maps; import com.google.common.collect.Maps;
import com.google.common.flogger.FluentLogger; import com.google.common.flogger.FluentLogger;
import com.google.common.io.BaseEncoding; import com.google.common.io.BaseEncoding;
import com.google.gerrit.exceptions.StorageException;
import com.google.gerrit.extensions.registration.DynamicItem; import com.google.gerrit.extensions.registration.DynamicItem;
import com.google.gerrit.server.IdentifiedUser; import com.google.gerrit.server.IdentifiedUser;
import com.google.gerrit.server.account.AccountState; 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.GerritServerConfig;
import com.google.gerrit.server.config.UrlFormatter; import com.google.gerrit.server.config.UrlFormatter;
import com.google.gerrit.server.query.account.InternalAccountQuery; import com.google.gerrit.server.query.account.InternalAccountQuery;
import com.google.gwtorm.server.OrmException;
import com.google.inject.Inject; import com.google.inject.Inject;
import com.google.inject.Provider; import com.google.inject.Provider;
import com.google.inject.Singleton; import com.google.inject.Singleton;
@@ -135,7 +135,7 @@ public class GerritPublicKeyChecker extends PublicKeyChecker {
return checkIdsForExpectedUser(key); return checkIdsForExpectedUser(key);
} }
return checkIdsForArbitraryUser(key); return checkIdsForArbitraryUser(key);
} catch (PGPException | OrmException e) { } catch (PGPException | StorageException e) {
String msg = "Error checking user IDs for key"; String msg = "Error checking user IDs for key";
logger.atWarning().withCause(e).log("%s %s", msg, keyIdToString(key.getKeyID())); logger.atWarning().withCause(e).log("%s %s", msg, keyIdToString(key.getKeyID()));
return CheckResult.bad(msg); return CheckResult.bad(msg);
@@ -156,7 +156,8 @@ public class GerritPublicKeyChecker extends PublicKeyChecker {
return CheckResult.bad(missingUserIds(allowedUserIds)); return CheckResult.bad(missingUserIds(allowedUserIds));
} }
private CheckResult checkIdsForArbitraryUser(PGPPublicKey key) throws PGPException, OrmException { private CheckResult checkIdsForArbitraryUser(PGPPublicKey key)
throws PGPException, StorageException {
List<AccountState> accountStates = accountQueryProvider.get().byExternalId(toExtIdKey(key)); List<AccountState> accountStates = accountQueryProvider.get().byExternalId(toExtIdKey(key));
if (accountStates.isEmpty()) { if (accountStates.isEmpty()) {
return CheckResult.bad("Key is not associated with any users"); return CheckResult.bad("Key is not associated with any users");

View File

@@ -14,6 +14,7 @@
package com.google.gerrit.gpg.api; 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.GpgKeyApi;
import com.google.gerrit.extensions.api.accounts.GpgKeysInput; import com.google.gerrit.extensions.api.accounts.GpgKeysInput;
import com.google.gerrit.extensions.common.GpgKeyInfo; import com.google.gerrit.extensions.common.GpgKeyInfo;
@@ -28,7 +29,6 @@ import com.google.gerrit.server.GpgException;
import com.google.gerrit.server.IdentifiedUser; import com.google.gerrit.server.IdentifiedUser;
import com.google.gerrit.server.account.AccountResource; import com.google.gerrit.server.account.AccountResource;
import com.google.gerrit.server.account.GpgApiAdapter; import com.google.gerrit.server.account.GpgApiAdapter;
import com.google.gwtorm.server.OrmException;
import com.google.inject.Inject; import com.google.inject.Inject;
import com.google.inject.Provider; import com.google.inject.Provider;
import java.io.IOException; import java.io.IOException;
@@ -67,7 +67,7 @@ public class GpgApiAdapterImpl implements GpgApiAdapter {
throws RestApiException, GpgException { throws RestApiException, GpgException {
try { try {
return gpgKeys.get().list().apply(account); return gpgKeys.get().list().apply(account);
} catch (OrmException | PGPException | IOException e) { } catch (StorageException | PGPException | IOException e) {
throw new GpgException(e); throw new GpgException(e);
} }
} }
@@ -81,7 +81,7 @@ public class GpgApiAdapterImpl implements GpgApiAdapter {
in.delete = delete; in.delete = delete;
try { try {
return postGpgKeys.get().apply(account, in); return postGpgKeys.get().apply(account, in);
} catch (PGPException | OrmException | IOException | ConfigInvalidException e) { } catch (PGPException | StorageException | IOException | ConfigInvalidException e) {
throw new GpgException(e); throw new GpgException(e);
} }
} }
@@ -91,7 +91,7 @@ public class GpgApiAdapterImpl implements GpgApiAdapter {
throws RestApiException, GpgException { throws RestApiException, GpgException {
try { try {
return gpgKeyApiFactory.create(gpgKeys.get().parse(account, idStr)); return gpgKeyApiFactory.create(gpgKeys.get().parse(account, idStr));
} catch (PGPException | OrmException | IOException e) { } catch (PGPException | StorageException | IOException e) {
throw new GpgException(e); throw new GpgException(e);
} }
} }

View File

@@ -14,6 +14,7 @@
package com.google.gerrit.gpg.api; 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.GpgKeyApi;
import com.google.gerrit.extensions.common.GpgKeyInfo; import com.google.gerrit.extensions.common.GpgKeyInfo;
import com.google.gerrit.extensions.common.Input; 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.DeleteGpgKey;
import com.google.gerrit.gpg.server.GpgKey; import com.google.gerrit.gpg.server.GpgKey;
import com.google.gerrit.gpg.server.GpgKeys; import com.google.gerrit.gpg.server.GpgKeys;
import com.google.gwtorm.server.OrmException;
import com.google.inject.Inject; import com.google.inject.Inject;
import com.google.inject.assistedinject.Assisted; import com.google.inject.assistedinject.Assisted;
import java.io.IOException; import java.io.IOException;
@@ -57,7 +57,7 @@ public class GpgKeyApiImpl implements GpgKeyApi {
public void delete() throws RestApiException { public void delete() throws RestApiException {
try { try {
delete.apply(rsrc, new Input()); 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); throw new RestApiException("Cannot delete GPG key", e);
} }
} }

View File

@@ -18,6 +18,7 @@ import static com.google.gerrit.gpg.PublicKeyStore.keyIdToString;
import static com.google.gerrit.server.account.externalids.ExternalId.SCHEME_GPGKEY; import static com.google.gerrit.server.account.externalids.ExternalId.SCHEME_GPGKEY;
import com.google.common.io.BaseEncoding; import com.google.common.io.BaseEncoding;
import com.google.gerrit.exceptions.StorageException;
import com.google.gerrit.extensions.common.Input; import com.google.gerrit.extensions.common.Input;
import com.google.gerrit.extensions.restapi.ResourceConflictException; import com.google.gerrit.extensions.restapi.ResourceConflictException;
import com.google.gerrit.extensions.restapi.ResourceNotFoundException; import com.google.gerrit.extensions.restapi.ResourceNotFoundException;
@@ -30,7 +31,6 @@ import com.google.gerrit.server.UserInitiated;
import com.google.gerrit.server.account.AccountsUpdate; import com.google.gerrit.server.account.AccountsUpdate;
import com.google.gerrit.server.account.externalids.ExternalId; import com.google.gerrit.server.account.externalids.ExternalId;
import com.google.gerrit.server.account.externalids.ExternalIds; import com.google.gerrit.server.account.externalids.ExternalIds;
import com.google.gwtorm.server.OrmException;
import com.google.inject.Inject; import com.google.inject.Inject;
import com.google.inject.Provider; import com.google.inject.Provider;
import java.io.IOException; import java.io.IOException;
@@ -63,7 +63,7 @@ public class DeleteGpgKey implements RestModifyView<GpgKey, Input> {
@Override @Override
public Response<?> apply(GpgKey rsrc, Input input) public Response<?> apply(GpgKey rsrc, Input input)
throws RestApiException, PGPException, OrmException, IOException, ConfigInvalidException { throws RestApiException, PGPException, StorageException, IOException, ConfigInvalidException {
PGPPublicKey key = rsrc.getKeyRing().getPublicKey(); PGPPublicKey key = rsrc.getKeyRing().getPublicKey();
String fingerprint = BaseEncoding.base16().encode(key.getFingerprint()); String fingerprint = BaseEncoding.base16().encode(key.getFingerprint());
Optional<ExternalId> extId = externalIds.get(ExternalId.Key.create(SCHEME_GPGKEY, fingerprint)); Optional<ExternalId> extId = externalIds.get(ExternalId.Key.create(SCHEME_GPGKEY, fingerprint));

View File

@@ -21,6 +21,7 @@ import com.google.common.base.CharMatcher;
import com.google.common.collect.ImmutableList; import com.google.common.collect.ImmutableList;
import com.google.common.flogger.FluentLogger; import com.google.common.flogger.FluentLogger;
import com.google.common.io.BaseEncoding; import com.google.common.io.BaseEncoding;
import com.google.gerrit.exceptions.StorageException;
import com.google.gerrit.extensions.common.GpgKeyInfo; import com.google.gerrit.extensions.common.GpgKeyInfo;
import com.google.gerrit.extensions.registration.DynamicMap; import com.google.gerrit.extensions.registration.DynamicMap;
import com.google.gerrit.extensions.restapi.AuthException; import com.google.gerrit.extensions.restapi.AuthException;
@@ -39,7 +40,6 @@ import com.google.gerrit.server.CurrentUser;
import com.google.gerrit.server.account.AccountResource; import com.google.gerrit.server.account.AccountResource;
import com.google.gerrit.server.account.externalids.ExternalId; import com.google.gerrit.server.account.externalids.ExternalId;
import com.google.gerrit.server.account.externalids.ExternalIds; import com.google.gerrit.server.account.externalids.ExternalIds;
import com.google.gwtorm.server.OrmException;
import com.google.inject.Inject; import com.google.inject.Inject;
import com.google.inject.Provider; import com.google.inject.Provider;
import com.google.inject.Singleton; import com.google.inject.Singleton;
@@ -86,7 +86,7 @@ public class GpgKeys implements ChildCollection<AccountResource, GpgKey> {
@Override @Override
public GpgKey parse(AccountResource parent, IdString id) public GpgKey parse(AccountResource parent, IdString id)
throws ResourceNotFoundException, PGPException, OrmException, IOException { throws ResourceNotFoundException, PGPException, StorageException, IOException {
checkVisible(self, parent); checkVisible(self, parent);
ExternalId gpgKeyExtId = findGpgKey(id.get(), getGpgExtIds(parent)); ExternalId gpgKeyExtId = findGpgKey(id.get(), getGpgExtIds(parent));
@@ -142,7 +142,7 @@ public class GpgKeys implements ChildCollection<AccountResource, GpgKey> {
public class ListGpgKeys implements RestReadView<AccountResource> { public class ListGpgKeys implements RestReadView<AccountResource> {
@Override @Override
public Map<String, GpgKeyInfo> apply(AccountResource rsrc) public Map<String, GpgKeyInfo> apply(AccountResource rsrc)
throws OrmException, PGPException, IOException, ResourceNotFoundException { throws StorageException, PGPException, IOException, ResourceNotFoundException {
checkVisible(self, rsrc); checkVisible(self, rsrc);
Map<String, GpgKeyInfo> keys = new HashMap<>(); Map<String, GpgKeyInfo> keys = new HashMap<>();
try (PublicKeyStore store = storeProvider.get()) { try (PublicKeyStore store = storeProvider.get()) {

View File

@@ -27,6 +27,7 @@ import com.google.common.collect.Maps;
import com.google.common.flogger.FluentLogger; import com.google.common.flogger.FluentLogger;
import com.google.common.io.BaseEncoding; import com.google.common.io.BaseEncoding;
import com.google.gerrit.exceptions.EmailException; import com.google.gerrit.exceptions.EmailException;
import com.google.gerrit.exceptions.StorageException;
import com.google.gerrit.extensions.api.accounts.GpgKeysInput; import com.google.gerrit.extensions.api.accounts.GpgKeysInput;
import com.google.gerrit.extensions.common.GpgKeyInfo; import com.google.gerrit.extensions.common.GpgKeyInfo;
import com.google.gerrit.extensions.restapi.BadRequestException; import com.google.gerrit.extensions.restapi.BadRequestException;
@@ -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.account.externalids.ExternalIds;
import com.google.gerrit.server.mail.send.AddKeySender; import com.google.gerrit.server.mail.send.AddKeySender;
import com.google.gerrit.server.query.account.InternalAccountQuery; import com.google.gerrit.server.query.account.InternalAccountQuery;
import com.google.gwtorm.server.OrmException;
import com.google.inject.Inject; import com.google.inject.Inject;
import com.google.inject.Provider; import com.google.inject.Provider;
import com.google.inject.Singleton; import com.google.inject.Singleton;
@@ -108,7 +108,7 @@ public class PostGpgKeys implements RestModifyView<AccountResource, GpgKeysInput
@Override @Override
public Map<String, GpgKeyInfo> apply(AccountResource rsrc, GpgKeysInput input) public Map<String, GpgKeyInfo> apply(AccountResource rsrc, GpgKeysInput input)
throws ResourceNotFoundException, BadRequestException, ResourceConflictException, throws ResourceNotFoundException, BadRequestException, ResourceConflictException,
PGPException, OrmException, IOException, ConfigInvalidException { PGPException, StorageException, IOException, ConfigInvalidException {
GpgKeys.checkVisible(self, rsrc); GpgKeys.checkVisible(self, rsrc);
Collection<ExternalId> existingExtIds = Collection<ExternalId> existingExtIds =
@@ -249,7 +249,7 @@ public class PostGpgKeys implements RestModifyView<AccountResource, GpgKeysInput
return ExternalId.Key.create(SCHEME_GPGKEY, BaseEncoding.base16().encode(fp)); return ExternalId.Key.create(SCHEME_GPGKEY, BaseEncoding.base16().encode(fp));
} }
private Account getAccountByExternalId(ExternalId.Key extIdKey) throws OrmException { private Account getAccountByExternalId(ExternalId.Key extIdKey) throws StorageException {
List<AccountState> accountStates = accountQueryProvider.get().byExternalId(extIdKey); List<AccountState> accountStates = accountQueryProvider.get().byExternalId(extIdKey);
if (accountStates.isEmpty()) { if (accountStates.isEmpty()) {

View File

@@ -10,6 +10,7 @@ java_library(
deps = [ deps = [
"//java/com/google/gerrit/common:annotations", "//java/com/google/gerrit/common:annotations",
"//java/com/google/gerrit/common:server", "//java/com/google/gerrit/common:server",
"//java/com/google/gerrit/exceptions",
"//java/com/google/gerrit/extensions:api", "//java/com/google/gerrit/extensions:api",
"//java/com/google/gerrit/git", "//java/com/google/gerrit/git",
"//java/com/google/gerrit/json", "//java/com/google/gerrit/json",
@@ -26,7 +27,6 @@ java_library(
"//java/com/google/gerrit/server/util/time", "//java/com/google/gerrit/server/util/time",
"//java/com/google/gerrit/util/cli", "//java/com/google/gerrit/util/cli",
"//java/com/google/gerrit/util/http", "//java/com/google/gerrit/util/http",
"//java/com/google/gwtorm",
"//java/org/eclipse/jgit:server", "//java/org/eclipse/jgit:server",
"//lib:args4j", "//lib:args4j",
"//lib:gson", "//lib:gson",

View File

@@ -15,13 +15,13 @@
package com.google.gerrit.httpd; package com.google.gerrit.httpd;
import com.google.gerrit.common.PageLinks; 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.ResourceConflictException;
import com.google.gerrit.extensions.restapi.ResourceNotFoundException; import com.google.gerrit.extensions.restapi.ResourceNotFoundException;
import com.google.gerrit.reviewdb.client.Change; import com.google.gerrit.reviewdb.client.Change;
import com.google.gerrit.server.change.ChangeResource; import com.google.gerrit.server.change.ChangeResource;
import com.google.gerrit.server.permissions.PermissionBackendException; import com.google.gerrit.server.permissions.PermissionBackendException;
import com.google.gerrit.server.restapi.change.ChangesCollection; import com.google.gerrit.server.restapi.change.ChangesCollection;
import com.google.gwtorm.server.OrmException;
import com.google.inject.Inject; import com.google.inject.Inject;
import com.google.inject.Singleton; import com.google.inject.Singleton;
import java.io.IOException; import java.io.IOException;
@@ -61,7 +61,7 @@ public class NumericChangeIdRedirectServlet extends HttpServlet {
} catch (ResourceConflictException | ResourceNotFoundException e) { } catch (ResourceConflictException | ResourceNotFoundException e) {
rsp.sendError(HttpServletResponse.SC_NOT_FOUND); rsp.sendError(HttpServletResponse.SC_NOT_FOUND);
return; return;
} catch (OrmException | PermissionBackendException e) { } catch (StorageException | PermissionBackendException e) {
throw new IOException("Unable to lookup change " + id.id, e); throw new IOException("Unable to lookup change " + id.id, e);
} }
String path = String path =

View File

@@ -19,6 +19,7 @@ import static javax.servlet.http.HttpServletResponse.SC_FORBIDDEN;
import static javax.servlet.http.HttpServletResponse.SC_INTERNAL_SERVER_ERROR; import static javax.servlet.http.HttpServletResponse.SC_INTERNAL_SERVER_ERROR;
import com.google.common.flogger.FluentLogger; import com.google.common.flogger.FluentLogger;
import com.google.gerrit.exceptions.StorageException;
import com.google.gerrit.extensions.registration.DynamicItem; import com.google.gerrit.extensions.registration.DynamicItem;
import com.google.gerrit.extensions.restapi.AuthException; import com.google.gerrit.extensions.restapi.AuthException;
import com.google.gerrit.extensions.restapi.UnprocessableEntityException; 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.GlobalPermission;
import com.google.gerrit.server.permissions.PermissionBackend; import com.google.gerrit.server.permissions.PermissionBackend;
import com.google.gerrit.server.permissions.PermissionBackendException; import com.google.gerrit.server.permissions.PermissionBackendException;
import com.google.gwtorm.server.OrmException;
import com.google.inject.Inject; import com.google.inject.Inject;
import com.google.inject.Singleton; import com.google.inject.Singleton;
import com.google.inject.servlet.ServletModule; import com.google.inject.servlet.ServletModule;
@@ -110,7 +110,7 @@ class RunAsFilter implements Filter {
} catch (UnprocessableEntityException e) { } catch (UnprocessableEntityException e) {
replyError(req, res, SC_FORBIDDEN, "no account matches " + RUN_AS, null); replyError(req, res, SC_FORBIDDEN, "no account matches " + RUN_AS, null);
return; return;
} catch (OrmException | IOException | ConfigInvalidException e) { } catch (StorageException | IOException | ConfigInvalidException e) {
logger.atWarning().withCause(e).log("cannot resolve account for %s", RUN_AS); logger.atWarning().withCause(e).log("cannot resolve account for %s", RUN_AS);
replyError(req, res, SC_INTERNAL_SERVER_ERROR, "cannot resolve " + RUN_AS, e); replyError(req, res, SC_INTERNAL_SERVER_ERROR, "cannot resolve " + RUN_AS, e);
return; return;

View File

@@ -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 static com.google.gerrit.server.account.externalids.ExternalId.SCHEME_UUID;
import com.google.gerrit.common.PageLinks; import com.google.gerrit.common.PageLinks;
import com.google.gerrit.exceptions.StorageException;
import com.google.gerrit.extensions.registration.DynamicItem; import com.google.gerrit.extensions.registration.DynamicItem;
import com.google.gerrit.httpd.HtmlDomUtil; import com.google.gerrit.httpd.HtmlDomUtil;
import com.google.gerrit.httpd.LoginUrlToken; 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.account.externalids.ExternalId;
import com.google.gerrit.server.query.account.InternalAccountQuery; import com.google.gerrit.server.query.account.InternalAccountQuery;
import com.google.gerrit.util.http.CacheHeaders; import com.google.gerrit.util.http.CacheHeaders;
import com.google.gwtorm.server.OrmException;
import com.google.inject.Inject; import com.google.inject.Inject;
import com.google.inject.Provider; import com.google.inject.Provider;
import com.google.inject.Singleton; import com.google.inject.Singleton;
@@ -200,7 +200,7 @@ class BecomeAnyAccountLoginServlet extends HttpServlet {
return null; return null;
} }
return auth(accountStates.get(0).getAccount().getId()); return auth(accountStates.get(0).getAccount().getId());
} catch (OrmException e) { } catch (StorageException e) {
getServletContext().log("cannot query account index", e); getServletContext().log("cannot query account index", e);
return null; return null;
} }
@@ -211,7 +211,7 @@ class BecomeAnyAccountLoginServlet extends HttpServlet {
Optional<AccountState> match = Optional<AccountState> match =
queryProvider.get().byPreferredEmail(email).stream().findFirst(); queryProvider.get().byPreferredEmail(email).stream().findFirst();
return auth(match); return auth(match);
} catch (OrmException e) { } catch (StorageException e) {
getServletContext().log("cannot query database", e); getServletContext().log("cannot query database", e);
return Optional.empty(); return Optional.empty();
} }

View File

@@ -19,6 +19,7 @@ import static java.nio.charset.StandardCharsets.UTF_8;
import com.google.common.flogger.FluentLogger; import com.google.common.flogger.FluentLogger;
import com.google.gerrit.common.PageLinks; import com.google.gerrit.common.PageLinks;
import com.google.gerrit.exceptions.StorageException;
import com.google.gerrit.extensions.registration.DynamicItem; import com.google.gerrit.extensions.registration.DynamicItem;
import com.google.gerrit.httpd.CanonicalWebUrl; import com.google.gerrit.httpd.CanonicalWebUrl;
import com.google.gerrit.httpd.HtmlDomUtil; 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.account.externalids.ExternalId;
import com.google.gerrit.server.config.AuthConfig; import com.google.gerrit.server.config.AuthConfig;
import com.google.gerrit.util.http.CacheHeaders; import com.google.gerrit.util.http.CacheHeaders;
import com.google.gwtorm.server.OrmException;
import com.google.inject.Inject; import com.google.inject.Inject;
import com.google.inject.Singleton; import com.google.inject.Singleton;
import java.io.IOException; import java.io.IOException;
@@ -128,7 +128,7 @@ class HttpLoginServlet extends HttpServlet {
logger.atFine().log( logger.atFine().log(
"Associating external identity \"%s\" to user \"%s\"", remoteExternalId, user); "Associating external identity \"%s\" to user \"%s\"", remoteExternalId, user);
updateRemoteExternalId(arsp, remoteExternalId); updateRemoteExternalId(arsp, remoteExternalId);
} catch (AccountException | OrmException | ConfigInvalidException e) { } catch (AccountException | StorageException | ConfigInvalidException e) {
logger.atSevere().withCause(e).log( logger.atSevere().withCause(e).log(
"Unable to associate external identity \"%s\" to user \"%s\"", remoteExternalId, user); "Unable to associate external identity \"%s\" to user \"%s\"", remoteExternalId, user);
rsp.sendError(HttpServletResponse.SC_FORBIDDEN); rsp.sendError(HttpServletResponse.SC_FORBIDDEN);
@@ -152,7 +152,7 @@ class HttpLoginServlet extends HttpServlet {
} }
private void updateRemoteExternalId(AuthResult arsp, String remoteAuthToken) private void updateRemoteExternalId(AuthResult arsp, String remoteAuthToken)
throws AccountException, OrmException, IOException, ConfigInvalidException { throws AccountException, StorageException, IOException, ConfigInvalidException {
accountManager.updateLink( accountManager.updateLink(
arsp.getAccountId(), arsp.getAccountId(),
new AuthRequest(ExternalId.Key.create(SCHEME_EXTERNAL, remoteAuthToken))); new AuthRequest(ExternalId.Key.create(SCHEME_EXTERNAL, remoteAuthToken)));

View File

@@ -6,12 +6,12 @@ java_library(
visibility = ["//visibility:public"], visibility = ["//visibility:public"],
deps = [ deps = [
"//java/com/google/gerrit/common:annotations", "//java/com/google/gerrit/common:annotations",
"//java/com/google/gerrit/exceptions",
"//java/com/google/gerrit/extensions:api", "//java/com/google/gerrit/extensions:api",
"//java/com/google/gerrit/httpd", "//java/com/google/gerrit/httpd",
"//java/com/google/gerrit/reviewdb:server", "//java/com/google/gerrit/reviewdb:server",
"//java/com/google/gerrit/server", "//java/com/google/gerrit/server",
"//java/com/google/gerrit/server/audit", "//java/com/google/gerrit/server/audit",
"//java/com/google/gwtorm",
"//lib:gson", "//lib:gson",
"//lib:guava", "//lib:guava",
"//lib:servlet-api-3_1", "//lib:servlet-api-3_1",

View File

@@ -19,6 +19,7 @@ import static javax.servlet.http.HttpServletResponse.SC_UNAUTHORIZED;
import com.google.common.base.CharMatcher; import com.google.common.base.CharMatcher;
import com.google.common.base.Strings; import com.google.common.base.Strings;
import com.google.common.flogger.FluentLogger; import com.google.common.flogger.FluentLogger;
import com.google.gerrit.exceptions.StorageException;
import com.google.gerrit.extensions.auth.oauth.OAuthServiceProvider; import com.google.gerrit.extensions.auth.oauth.OAuthServiceProvider;
import com.google.gerrit.extensions.auth.oauth.OAuthToken; import com.google.gerrit.extensions.auth.oauth.OAuthToken;
import com.google.gerrit.extensions.auth.oauth.OAuthUserInfo; 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.AuthResult;
import com.google.gerrit.server.account.externalids.ExternalId; import com.google.gerrit.server.account.externalids.ExternalId;
import com.google.gerrit.server.auth.oauth.OAuthTokenCache; import com.google.gerrit.server.auth.oauth.OAuthTokenCache;
import com.google.gwtorm.server.OrmException;
import com.google.inject.Inject; import com.google.inject.Inject;
import com.google.inject.Provider; import com.google.inject.Provider;
import com.google.inject.servlet.SessionScoped; import com.google.inject.servlet.SessionScoped;
@@ -188,7 +188,7 @@ class OAuthSession {
logger.atInfo().log("OAuth2: linking claimed identity to %s", claimedId.get().toString()); logger.atInfo().log("OAuth2: linking claimed identity to %s", claimedId.get().toString());
try { try {
accountManager.link(claimedId.get(), req); accountManager.link(claimedId.get(), req);
} catch (OrmException | ConfigInvalidException e) { } catch (StorageException | ConfigInvalidException e) {
logger.atSevere().log( logger.atSevere().log(
"Cannot link: %s to user identity:\n Claimed ID: %s is %s", "Cannot link: %s to user identity:\n Claimed ID: %s is %s",
user.getExternalId(), claimedId.get(), claimedIdentifier); user.getExternalId(), claimedId.get(), claimedIdentifier);
@@ -203,7 +203,7 @@ class OAuthSession {
throws AccountException, IOException { throws AccountException, IOException {
try { try {
accountManager.link(identifiedUser.get().getAccountId(), areq); accountManager.link(identifiedUser.get().getAccountId(), areq);
} catch (OrmException | ConfigInvalidException e) { } catch (StorageException | ConfigInvalidException e) {
logger.atSevere().log( logger.atSevere().log(
"Cannot link: %s to user identity: %s", "Cannot link: %s to user identity: %s",
user.getExternalId(), identifiedUser.get().getAccountId()); user.getExternalId(), identifiedUser.get().getAccountId());

View File

@@ -8,6 +8,7 @@ java_library(
# We want all these deps to be provided_deps # We want all these deps to be provided_deps
"//java/com/google/gerrit/common:annotations", "//java/com/google/gerrit/common:annotations",
"//java/com/google/gerrit/common:server", "//java/com/google/gerrit/common:server",
"//java/com/google/gerrit/exceptions",
"//java/com/google/gerrit/extensions:api", "//java/com/google/gerrit/extensions:api",
"//java/com/google/gerrit/httpd", "//java/com/google/gerrit/httpd",
"//java/com/google/gerrit/reviewdb:server", "//java/com/google/gerrit/reviewdb:server",

View File

@@ -18,6 +18,7 @@ import static javax.servlet.http.HttpServletResponse.SC_UNAUTHORIZED;
import com.google.common.base.Strings; import com.google.common.base.Strings;
import com.google.common.flogger.FluentLogger; import com.google.common.flogger.FluentLogger;
import com.google.gerrit.exceptions.StorageException;
import com.google.gerrit.extensions.auth.oauth.OAuthServiceProvider; import com.google.gerrit.extensions.auth.oauth.OAuthServiceProvider;
import com.google.gerrit.extensions.auth.oauth.OAuthToken; import com.google.gerrit.extensions.auth.oauth.OAuthToken;
import com.google.gerrit.extensions.auth.oauth.OAuthUserInfo; 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.AccountManager;
import com.google.gerrit.server.account.AuthResult; import com.google.gerrit.server.account.AuthResult;
import com.google.gerrit.server.account.externalids.ExternalId; import com.google.gerrit.server.account.externalids.ExternalId;
import com.google.gwtorm.server.OrmException;
import com.google.inject.Inject; import com.google.inject.Inject;
import com.google.inject.Provider; import com.google.inject.Provider;
import com.google.inject.servlet.SessionScoped; import com.google.inject.servlet.SessionScoped;
@@ -164,7 +164,7 @@ class OAuthSessionOverOpenID {
logger.atFine().log("Claimed account already exists: link to it."); logger.atFine().log("Claimed account already exists: link to it.");
try { try {
accountManager.link(claimedId.get(), areq); accountManager.link(claimedId.get(), areq);
} catch (OrmException | ConfigInvalidException e) { } catch (StorageException | ConfigInvalidException e) {
logger.atSevere().log( logger.atSevere().log(
"Cannot link: %s to user identity:\n Claimed ID: %s is %s", "Cannot link: %s to user identity:\n Claimed ID: %s is %s",
user.getExternalId(), claimedId.get(), claimedIdentifier); user.getExternalId(), claimedId.get(), claimedIdentifier);
@@ -178,7 +178,7 @@ class OAuthSessionOverOpenID {
try { try {
logger.atFine().log("Linking \"%s\" to \"%s\"", user.getExternalId(), accountId); logger.atFine().log("Linking \"%s\" to \"%s\"", user.getExternalId(), accountId);
accountManager.link(accountId, areq); accountManager.link(accountId, areq);
} catch (OrmException | ConfigInvalidException e) { } catch (StorageException | ConfigInvalidException e) {
logger.atSevere().log( logger.atSevere().log(
"Cannot link: %s to user identity: %s", user.getExternalId(), accountId); "Cannot link: %s to user identity: %s", user.getExternalId(), accountId);
rsp.sendError(HttpServletResponse.SC_FORBIDDEN); rsp.sendError(HttpServletResponse.SC_FORBIDDEN);

View File

@@ -25,7 +25,6 @@ java_library(
"//java/com/google/gerrit/server/restapi", "//java/com/google/gerrit/server/restapi",
"//java/com/google/gerrit/server/schema", "//java/com/google/gerrit/server/schema",
"//java/com/google/gerrit/sshd", "//java/com/google/gerrit/sshd",
"//java/com/google/gwtorm",
"//lib:guava", "//lib:guava",
"//lib:servlet-api-3_1", "//lib:servlet-api-3_1",
"//lib/flogger:api", "//lib/flogger:api",

View File

@@ -14,6 +14,7 @@
package com.google.gerrit.httpd.raw; 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.AuthException;
import com.google.gerrit.extensions.restapi.ResourceConflictException; import com.google.gerrit.extensions.restapi.ResourceConflictException;
import com.google.gerrit.extensions.restapi.Url; 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.permissions.PermissionBackendException;
import com.google.gerrit.server.project.NoSuchChangeException; import com.google.gerrit.server.project.NoSuchChangeException;
import com.google.gerrit.server.project.ProjectCache; import com.google.gerrit.server.project.ProjectCache;
import com.google.gwtorm.server.OrmException;
import com.google.inject.Inject; import com.google.inject.Inject;
import com.google.inject.Singleton; import com.google.inject.Singleton;
import java.io.IOException; import java.io.IOException;
@@ -145,7 +145,7 @@ public class CatServlet extends HttpServlet {
} catch (ResourceConflictException | NoSuchChangeException | AuthException e) { } catch (ResourceConflictException | NoSuchChangeException | AuthException e) {
rsp.sendError(HttpServletResponse.SC_NOT_FOUND); rsp.sendError(HttpServletResponse.SC_NOT_FOUND);
return; return;
} catch (OrmException | PermissionBackendException | IOException e) { } catch (StorageException | PermissionBackendException | IOException e) {
getServletContext().log("Cannot query database", e); getServletContext().log("Cannot query database", e);
rsp.sendError(HttpServletResponse.SC_INTERNAL_SERVER_ERROR); rsp.sendError(HttpServletResponse.SC_INTERNAL_SERVER_ERROR);
return; return;

View File

@@ -20,12 +20,12 @@ java_library(
":query_exception", ":query_exception",
"//antlr3:query_parser", "//antlr3:query_parser",
"//java/com/google/gerrit/common:annotations", "//java/com/google/gerrit/common:annotations",
"//java/com/google/gerrit/exceptions",
"//java/com/google/gerrit/extensions:api", "//java/com/google/gerrit/extensions:api",
"//java/com/google/gerrit/json", "//java/com/google/gerrit/json",
"//java/com/google/gerrit/metrics", "//java/com/google/gerrit/metrics",
"//java/com/google/gerrit/reviewdb:server", "//java/com/google/gerrit/reviewdb:server",
"//java/com/google/gerrit/server/logging", "//java/com/google/gerrit/server/logging",
"//java/com/google/gwtorm",
"//lib:guava", "//lib:guava",
"//lib/antlr:java-runtime", "//lib/antlr:java-runtime",
"//lib/auto:auto-value", "//lib/auto:auto-value",

View File

@@ -19,7 +19,7 @@ import static java.util.Objects.requireNonNull;
import com.google.common.base.CharMatcher; import com.google.common.base.CharMatcher;
import com.google.gerrit.common.Nullable; import com.google.gerrit.common.Nullable;
import com.google.gwtorm.server.OrmException; import com.google.gerrit.exceptions.StorageException;
import java.io.IOException; import java.io.IOException;
import java.sql.Timestamp; import java.sql.Timestamp;
@@ -62,7 +62,7 @@ public final class FieldDef<I, T> {
@FunctionalInterface @FunctionalInterface
public interface Getter<I, T> { public interface Getter<I, T> {
@Nullable @Nullable
T get(I input) throws OrmException, IOException; T get(I input) throws StorageException, IOException;
} }
public static class Builder<T> { public static class Builder<T> {
@@ -133,14 +133,14 @@ public final class FieldDef<I, T> {
* *
* @param input input object. * @param input input object.
* @return the field value(s) to index. * @return the field value(s) to index.
* @throws OrmException * @throws StorageException
*/ */
@Nullable @Nullable
public T get(I input) throws OrmException { public T get(I input) throws StorageException {
try { try {
return getter.get(input); return getter.get(input);
} catch (IOException e) { } catch (IOException e) {
throw new OrmException(e); throw new StorageException(e);
} }
} }

View File

@@ -15,12 +15,12 @@
package com.google.gerrit.index; package com.google.gerrit.index;
import com.google.common.collect.ImmutableList; 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.DataSource;
import com.google.gerrit.index.query.FieldBundle; import com.google.gerrit.index.query.FieldBundle;
import com.google.gerrit.index.query.IndexPredicate; import com.google.gerrit.index.query.IndexPredicate;
import com.google.gerrit.index.query.Predicate; import com.google.gerrit.index.query.Predicate;
import com.google.gerrit.index.query.QueryParseException; import com.google.gerrit.index.query.QueryParseException;
import com.google.gwtorm.server.OrmException;
import java.io.IOException; import java.io.IOException;
import java.util.Optional; import java.util.Optional;
@@ -100,7 +100,7 @@ public interface Index<K, V> {
results = getSource(keyPredicate(key), opts).read().toList(); results = getSource(keyPredicate(key), opts).read().toList();
} catch (QueryParseException e) { } catch (QueryParseException e) {
throw new IOException("Unexpected QueryParseException during get()", e); throw new IOException("Unexpected QueryParseException during get()", e);
} catch (OrmException e) { } catch (StorageException e) {
throw new IOException(e); throw new IOException(e);
} }
if (results.size() > 1) { if (results.size() > 1) {
@@ -125,7 +125,7 @@ public interface Index<K, V> {
results = getSource(keyPredicate(key), opts).readRaw().toList(); results = getSource(keyPredicate(key), opts).readRaw().toList();
} catch (QueryParseException e) { } catch (QueryParseException e) {
throw new IOException("Unexpected QueryParseException during get()", e); throw new IOException("Unexpected QueryParseException during get()", e);
} catch (OrmException e) { } catch (StorageException e) {
throw new IOException(e); throw new IOException(e);
} }
if (results.size() > 1) { if (results.size() > 1) {

View File

@@ -22,7 +22,7 @@ import com.google.common.collect.FluentIterable;
import com.google.common.collect.ImmutableList; import com.google.common.collect.ImmutableList;
import com.google.common.collect.ImmutableMap; import com.google.common.collect.ImmutableMap;
import com.google.common.flogger.FluentLogger; 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.ArrayList;
import java.util.Arrays; import java.util.Arrays;
import java.util.Collections; import java.util.Collections;
@@ -179,7 +179,7 @@ public class Schema<T> {
Object v; Object v;
try { try {
v = f.get(obj); v = f.get(obj);
} catch (OrmException e) { } catch (StorageException e) {
logger.atSevere().withCause(e).log( logger.atSevere().withCause(e).log(
"error getting field %s of %s", f.getName(), obj); "error getting field %s of %s", f.getName(), obj);
return null; return null;

View File

@@ -16,7 +16,7 @@ package com.google.gerrit.index.query;
import static com.google.common.base.Preconditions.checkState; import static com.google.common.base.Preconditions.checkState;
import com.google.gwtorm.server.OrmException; import com.google.gerrit.exceptions.StorageException;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Arrays; import java.util.Arrays;
import java.util.Collection; import java.util.Collection;
@@ -82,7 +82,7 @@ public class AndPredicate<T> extends Predicate<T> implements Matchable<T> {
} }
@Override @Override
public boolean match(T object) throws OrmException { public boolean match(T object) throws StorageException {
for (Predicate<T> c : children) { for (Predicate<T> c : children) {
checkState( checkState(
c.isMatchable(), c.isMatchable(),

View File

@@ -21,8 +21,8 @@ import com.google.common.base.Throwables;
import com.google.common.collect.FluentIterable; import com.google.common.collect.FluentIterable;
import com.google.common.collect.ImmutableList; import com.google.common.collect.ImmutableList;
import com.google.common.collect.Iterables; import com.google.common.collect.Iterables;
import com.google.gwtorm.server.OrmException; import com.google.gerrit.exceptions.StorageException;
import com.google.gwtorm.server.OrmRuntimeException; import com.google.gerrit.exceptions.StorageRuntimeException;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Collection; import java.util.Collection;
import java.util.Comparator; import java.util.Comparator;
@@ -76,26 +76,26 @@ public class AndSource<T> extends AndPredicate<T>
} }
@Override @Override
public ResultSet<T> read() throws OrmException { public ResultSet<T> read() throws StorageException {
try { try {
return readImpl(); return readImpl();
} catch (OrmRuntimeException err) { } catch (StorageRuntimeException err) {
if (err.getCause() != null) { 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 @Override
public ResultSet<FieldBundle> readRaw() throws OrmException { public ResultSet<FieldBundle> readRaw() throws StorageException {
// TOOD(hiesel): Implement // TOOD(hiesel): Implement
throw new UnsupportedOperationException("not implemented"); throw new UnsupportedOperationException("not implemented");
} }
private ResultSet<T> readImpl() throws OrmException { private ResultSet<T> readImpl() throws StorageException {
if (source == null) { if (source == null) {
throw new OrmException("No DataSource: " + this); throw new StorageException("No DataSource: " + this);
} }
List<T> r = new ArrayList<>(); List<T> r = new ArrayList<>();
T last = null; T last = null;
@@ -147,7 +147,7 @@ public class AndSource<T> extends AndPredicate<T>
} }
@Override @Override
public boolean match(T object) throws OrmException { public boolean match(T object) throws StorageException {
if (isVisibleToPredicate != null && !isVisibleToPredicate.match(object)) { if (isVisibleToPredicate != null && !isVisibleToPredicate.match(object)) {
return false; return false;
} }
@@ -164,7 +164,7 @@ public class AndSource<T> extends AndPredicate<T>
.transformAndConcat(this::transformBuffer); .transformAndConcat(this::transformBuffer);
} }
protected List<T> transformBuffer(List<T> buffer) throws OrmRuntimeException { protected List<T> transformBuffer(List<T> buffer) throws StorageRuntimeException {
return buffer; return buffer;
} }

View File

@@ -14,15 +14,15 @@
package com.google.gerrit.index.query; package com.google.gerrit.index.query;
import com.google.gwtorm.server.OrmException; import com.google.gerrit.exceptions.StorageException;
public interface DataSource<T> { public interface DataSource<T> {
/** @return an estimate of the number of results from {@link #read()}. */ /** @return an estimate of the number of results from {@link #read()}. */
int getCardinality(); int getCardinality();
/** @return read from the database and return the results. */ /** @return read from the database and return the results. */
ResultSet<T> read() throws OrmException; ResultSet<T> read() throws StorageException;
/** @return read from the database and return the raw results. */ /** @return read from the database and return the raw results. */
ResultSet<FieldBundle> readRaw() throws OrmException; ResultSet<FieldBundle> readRaw() throws StorageException;
} }

View File

@@ -16,9 +16,9 @@ package com.google.gerrit.index.query;
import com.google.common.base.MoreObjects; import com.google.common.base.MoreObjects;
import com.google.common.collect.ImmutableList; import com.google.common.collect.ImmutableList;
import com.google.gerrit.exceptions.StorageException;
import com.google.gerrit.index.Index; import com.google.gerrit.index.Index;
import com.google.gerrit.index.QueryOptions; import com.google.gerrit.index.QueryOptions;
import com.google.gwtorm.server.OrmException;
import java.util.Collection; import java.util.Collection;
import java.util.List; import java.util.List;
@@ -77,17 +77,17 @@ public class IndexedQuery<I, T> extends Predicate<T> implements DataSource<T>, P
} }
@Override @Override
public ResultSet<T> read() throws OrmException { public ResultSet<T> read() throws StorageException {
return source.read(); return source.read();
} }
@Override @Override
public ResultSet<FieldBundle> readRaw() throws OrmException { public ResultSet<FieldBundle> readRaw() throws StorageException {
return source.readRaw(); return source.readRaw();
} }
@Override @Override
public ResultSet<T> restart(int start) throws OrmException { public ResultSet<T> restart(int start) throws StorageException {
opts = opts.withStart(start); opts = opts.withStart(start);
try { try {
source = index.getSource(pred, opts); source = index.getSource(pred, opts);
@@ -95,7 +95,7 @@ public class IndexedQuery<I, T> extends Predicate<T> implements DataSource<T>, P
// Don't need to show this exception to the user; the only thing that // 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 // changed about pred was its start, and any other QPEs that might happen
// should have already thrown from the constructor. // 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 // Don't convert start to a limit, since the caller of this method (see
// AndSource) has calculated the actual number to skip. // AndSource) has calculated the actual number to skip.

View File

@@ -14,9 +14,9 @@
package com.google.gerrit.index.query; package com.google.gerrit.index.query;
import com.google.gerrit.exceptions.StorageException;
import com.google.gerrit.index.FieldDef; import com.google.gerrit.index.FieldDef;
import com.google.gerrit.index.query.RangeUtil.Range; import com.google.gerrit.index.query.RangeUtil.Range;
import com.google.gwtorm.server.OrmException;
public abstract class IntegerRangePredicate<T> extends IndexPredicate<T> { public abstract class IntegerRangePredicate<T> extends IndexPredicate<T> {
private final Range range; private final Range range;
@@ -30,9 +30,9 @@ public abstract class IntegerRangePredicate<T> extends IndexPredicate<T> {
} }
} }
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); Integer valueInt = getValueInt(object);
if (valueInt == null) { if (valueInt == null) {
return false; return false;

View File

@@ -20,12 +20,12 @@ import static java.util.stream.Collectors.toSet;
import com.google.common.collect.ImmutableList; import com.google.common.collect.ImmutableList;
import com.google.common.collect.ImmutableSet; import com.google.common.collect.ImmutableSet;
import com.google.common.collect.Lists; import com.google.common.collect.Lists;
import com.google.gerrit.exceptions.StorageException;
import com.google.gerrit.index.FieldDef; import com.google.gerrit.index.FieldDef;
import com.google.gerrit.index.Index; import com.google.gerrit.index.Index;
import com.google.gerrit.index.IndexCollection; import com.google.gerrit.index.IndexCollection;
import com.google.gerrit.index.IndexConfig; import com.google.gerrit.index.IndexConfig;
import com.google.gerrit.index.Schema; import com.google.gerrit.index.Schema;
import com.google.gwtorm.server.OrmException;
import java.util.Arrays; import java.util.Arrays;
import java.util.List; import java.util.List;
import java.util.function.Supplier; import java.util.function.Supplier;
@@ -88,15 +88,15 @@ public class InternalQuery<T, Q extends InternalQuery<T, Q>> {
return self(); return self();
} }
public final List<T> query(Predicate<T> p) throws OrmException { public final List<T> query(Predicate<T> p) throws StorageException {
return queryResults(p).entities(); return queryResults(p).entities();
} }
final QueryResult<T> queryResults(Predicate<T> p) throws OrmException { final QueryResult<T> queryResults(Predicate<T> p) throws StorageException {
try { try {
return queryProcessor.query(p); return queryProcessor.query(p);
} catch (QueryParseException e) { } catch (QueryParseException e) {
throw new OrmException(e); throw new StorageException(e);
} }
} }
@@ -110,11 +110,11 @@ public class InternalQuery<T, Q extends InternalQuery<T, Q>> {
* @return results of the queries, one list of results per input query, in the same order as the * @return results of the queries, one list of results per input query, in the same order as the
* input. * input.
*/ */
public final List<List<T>> query(List<Predicate<T>> queries) throws OrmException { public final List<List<T>> query(List<Predicate<T>> queries) throws StorageException {
try { try {
return Lists.transform(queryProcessor.query(queries), QueryResult::entities); return Lists.transform(queryProcessor.query(queries), QueryResult::entities);
} catch (QueryParseException e) { } catch (QueryParseException e) {
throw new OrmException(e); throw new StorageException(e);
} }
} }
@@ -144,11 +144,11 @@ public class InternalQuery<T, Q extends InternalQuery<T, Q>> {
* @param predicate predicate to search for. * @param predicate predicate to search for.
* @param <T> result type. * @param <T> result type.
* @return exhaustive list of results, subject to the race condition described above. * @return exhaustive list of results, subject to the race condition described above.
* @throws OrmException if an error occurred. * @throws StorageException if an error occurred.
*/ */
protected static <T> ImmutableList<T> queryExhaustively( protected static <T> ImmutableList<T> queryExhaustively(
Supplier<? extends InternalQuery<T, ?>> querySupplier, Predicate<T> predicate) Supplier<? extends InternalQuery<T, ?>> querySupplier, Predicate<T> predicate)
throws OrmException { throws StorageException {
ImmutableList.Builder<T> b = null; ImmutableList.Builder<T> b = null;
int start = 0; int start = 0;
while (true) { while (true) {

View File

@@ -14,15 +14,15 @@
package com.google.gerrit.index.query; package com.google.gerrit.index.query;
import com.google.gwtorm.server.OrmException; import com.google.gerrit.exceptions.StorageException;
public interface Matchable<T> { public interface Matchable<T> {
/** /**
* Does this predicate match this object? * Does this predicate match this object?
* *
* @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. */ /** @return a cost estimate to run this predicate, higher figures cost more. */
int getCost(); int getCost();

View File

@@ -16,7 +16,7 @@ package com.google.gerrit.index.query;
import static com.google.common.base.Preconditions.checkState; import static com.google.common.base.Preconditions.checkState;
import com.google.gwtorm.server.OrmException; import com.google.gerrit.exceptions.StorageException;
import java.util.Collection; import java.util.Collection;
import java.util.Collections; import java.util.Collections;
import java.util.List; import java.util.List;
@@ -64,7 +64,7 @@ public class NotPredicate<T> extends Predicate<T> implements Matchable<T> {
} }
@Override @Override
public boolean match(T object) throws OrmException { public boolean match(T object) throws StorageException {
checkState( checkState(
that.isMatchable(), that.isMatchable(),
"match invoked, but child predicate %s doesn't implement %s", "match invoked, but child predicate %s doesn't implement %s",

View File

@@ -16,7 +16,7 @@ package com.google.gerrit.index.query;
import static com.google.common.base.Preconditions.checkState; import static com.google.common.base.Preconditions.checkState;
import com.google.gwtorm.server.OrmException; import com.google.gerrit.exceptions.StorageException;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Arrays; import java.util.Arrays;
import java.util.Collection; import java.util.Collection;
@@ -82,7 +82,7 @@ public class OrPredicate<T> extends Predicate<T> implements Matchable<T> {
} }
@Override @Override
public boolean match(T object) throws OrmException { public boolean match(T object) throws StorageException {
for (Predicate<T> c : children) { for (Predicate<T> c : children) {
checkState( checkState(
c.isMatchable(), c.isMatchable(),

View File

@@ -14,11 +14,11 @@
package com.google.gerrit.index.query; package com.google.gerrit.index.query;
import com.google.gerrit.exceptions.StorageException;
import com.google.gerrit.index.QueryOptions; import com.google.gerrit.index.QueryOptions;
import com.google.gwtorm.server.OrmException;
public interface Paginated<T> { public interface Paginated<T> {
QueryOptions getOptions(); QueryOptions getOptions();
ResultSet<T> restart(int start) throws OrmException; ResultSet<T> restart(int start) throws StorageException;
} }

View File

@@ -26,6 +26,8 @@ import com.google.common.collect.ImmutableSet;
import com.google.common.collect.Ordering; import com.google.common.collect.Ordering;
import com.google.common.flogger.FluentLogger; import com.google.common.flogger.FluentLogger;
import com.google.gerrit.common.Nullable; import com.google.gerrit.common.Nullable;
import com.google.gerrit.exceptions.StorageException;
import com.google.gerrit.exceptions.StorageRuntimeException;
import com.google.gerrit.index.Index; import com.google.gerrit.index.Index;
import com.google.gerrit.index.IndexCollection; import com.google.gerrit.index.IndexCollection;
import com.google.gerrit.index.IndexConfig; 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.MetricMaker;
import com.google.gerrit.metrics.Timer1; import com.google.gerrit.metrics.Timer1;
import com.google.gerrit.server.logging.CallerFinder; 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.ArrayList;
import java.util.List; import java.util.List;
import java.util.Optional; import java.util.Optional;
@@ -173,7 +173,7 @@ public abstract class QueryProcessor<T> {
* @param query the query. * @param query the query.
* @return results of the query. * @return results of the query.
*/ */
public QueryResult<T> query(Predicate<T> query) throws OrmException, QueryParseException { public QueryResult<T> query(Predicate<T> query) throws StorageException, QueryParseException {
return query(ImmutableList.of(query)).get(0); return query(ImmutableList.of(query)).get(0);
} }
@@ -189,12 +189,12 @@ public abstract class QueryProcessor<T> {
* input. * input.
*/ */
public List<QueryResult<T>> query(List<Predicate<T>> queries) public List<QueryResult<T>> query(List<Predicate<T>> queries)
throws OrmException, QueryParseException { throws StorageException, QueryParseException {
try { try {
return query(null, queries); return query(null, queries);
} catch (OrmRuntimeException e) { } catch (StorageRuntimeException e) {
throw new OrmException(e.getMessage(), e); throw new StorageException(e.getMessage(), e);
} catch (OrmException e) { } catch (StorageException e) {
if (e.getCause() != null) { if (e.getCause() != null) {
Throwables.throwIfInstanceOf(e.getCause(), QueryParseException.class); Throwables.throwIfInstanceOf(e.getCause(), QueryParseException.class);
} }
@@ -204,7 +204,7 @@ public abstract class QueryProcessor<T> {
private List<QueryResult<T>> query( private List<QueryResult<T>> query(
@Nullable List<String> queryStrings, List<Predicate<T>> queries) @Nullable List<String> queryStrings, List<Predicate<T>> queries)
throws OrmException, QueryParseException { throws StorageException, QueryParseException {
long startNanos = System.nanoTime(); long startNanos = System.nanoTime();
checkState(!used.getAndSet(true), "%s has already been used", getClass().getSimpleName()); checkState(!used.getAndSet(true), "%s has already been used", getClass().getSimpleName());
int cnt = queries.size(); int cnt = queries.size();
@@ -287,7 +287,7 @@ public abstract class QueryProcessor<T> {
// Only measure successful queries that actually touched the index. // Only measure successful queries that actually touched the index.
metrics.executionTime.record( metrics.executionTime.record(
schemaDef.getName(), System.nanoTime() - startNanos, TimeUnit.NANOSECONDS); schemaDef.getName(), System.nanoTime() - startNanos, TimeUnit.NANOSECONDS);
} catch (OrmException | OrmRuntimeException e) { } catch (StorageException | StorageRuntimeException e) {
Optional<QueryParseException> qpe = findQueryParseException(e); Optional<QueryParseException> qpe = findQueryParseException(e);
if (qpe.isPresent()) { if (qpe.isPresent()) {
throw new QueryParseException(qpe.get().getMessage(), e); throw new QueryParseException(qpe.get().getMessage(), e);

View File

@@ -31,6 +31,7 @@ import com.google.common.util.concurrent.ListeningExecutorService;
import com.google.common.util.concurrent.MoreExecutors; import com.google.common.util.concurrent.MoreExecutors;
import com.google.common.util.concurrent.ThreadFactoryBuilder; import com.google.common.util.concurrent.ThreadFactoryBuilder;
import com.google.gerrit.common.Nullable; import com.google.gerrit.common.Nullable;
import com.google.gerrit.exceptions.StorageException;
import com.google.gerrit.index.FieldDef; import com.google.gerrit.index.FieldDef;
import com.google.gerrit.index.FieldType; import com.google.gerrit.index.FieldType;
import com.google.gerrit.index.Index; 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.index.IndexUtils;
import com.google.gerrit.server.logging.LoggingContextAwareExecutorService; import com.google.gerrit.server.logging.LoggingContextAwareExecutorService;
import com.google.gerrit.server.logging.LoggingContextAwareScheduledExecutorService; import com.google.gerrit.server.logging.LoggingContextAwareScheduledExecutorService;
import com.google.gwtorm.server.OrmException;
import java.io.IOException; import java.io.IOException;
import java.sql.Timestamp; import java.sql.Timestamp;
import java.util.Map; import java.util.Map;
@@ -486,16 +486,16 @@ public abstract class AbstractLuceneIndex<K, V> implements Index<K, V> {
} }
@Override @Override
public ResultSet<V> read() throws OrmException { public ResultSet<V> read() throws StorageException {
return readImpl(AbstractLuceneIndex.this::fromDocument); return readImpl(AbstractLuceneIndex.this::fromDocument);
} }
@Override @Override
public ResultSet<FieldBundle> readRaw() throws OrmException { public ResultSet<FieldBundle> readRaw() throws StorageException {
return readImpl(AbstractLuceneIndex.this::toFieldBundle); return readImpl(AbstractLuceneIndex.this::toFieldBundle);
} }
private <T> ResultSet<T> readImpl(Function<Document, T> mapper) throws OrmException { private <T> ResultSet<T> readImpl(Function<Document, T> mapper) throws StorageException {
IndexSearcher searcher = null; IndexSearcher searcher = null;
try { try {
searcher = acquire(); searcher = acquire();
@@ -512,7 +512,7 @@ public abstract class AbstractLuceneIndex<K, V> implements Index<K, V> {
} }
return new ListResultSet<>(b.build()); return new ListResultSet<>(b.build());
} catch (IOException e) { } catch (IOException e) {
throw new OrmException(e); throw new StorageException(e);
} finally { } finally {
if (searcher != null) { if (searcher != null) {
try { try {

View File

@@ -9,7 +9,6 @@ java_library(
"//java/com/google/gerrit/index:query_exception", "//java/com/google/gerrit/index:query_exception",
"//java/com/google/gerrit/reviewdb:server", "//java/com/google/gerrit/reviewdb:server",
"//java/com/google/gerrit/server", "//java/com/google/gerrit/server",
"//java/com/google/gwtorm",
"//lib:guava", "//lib:guava",
"//lib/lucene:lucene-core-and-backward-codecs", "//lib/lucene:lucene-core-and-backward-codecs",
], ],
@@ -26,6 +25,7 @@ java_library(
":query_builder", ":query_builder",
"//java/com/google/gerrit/common:annotations", "//java/com/google/gerrit/common:annotations",
"//java/com/google/gerrit/common:server", "//java/com/google/gerrit/common:server",
"//java/com/google/gerrit/exceptions",
"//java/com/google/gerrit/extensions:api", "//java/com/google/gerrit/extensions:api",
"//java/com/google/gerrit/index", "//java/com/google/gerrit/index",
"//java/com/google/gerrit/index:query_exception", "//java/com/google/gerrit/index:query_exception",
@@ -35,7 +35,6 @@ java_library(
"//java/com/google/gerrit/reviewdb:server", "//java/com/google/gerrit/reviewdb:server",
"//java/com/google/gerrit/server", "//java/com/google/gerrit/server",
"//java/com/google/gerrit/server/logging", "//java/com/google/gerrit/server/logging",
"//java/com/google/gwtorm",
"//lib:guava", "//lib:guava",
"//lib:protobuf", "//lib:protobuf",
"//lib/flogger:api", "//lib/flogger:api",

View File

@@ -36,6 +36,8 @@ import com.google.common.collect.Sets;
import com.google.common.flogger.FluentLogger; import com.google.common.flogger.FluentLogger;
import com.google.common.util.concurrent.Futures; import com.google.common.util.concurrent.Futures;
import com.google.common.util.concurrent.ListeningExecutorService; import com.google.common.util.concurrent.ListeningExecutorService;
import com.google.gerrit.exceptions.StorageException;
import com.google.gerrit.exceptions.StorageRuntimeException;
import com.google.gerrit.index.QueryOptions; import com.google.gerrit.index.QueryOptions;
import com.google.gerrit.index.Schema; import com.google.gerrit.index.Schema;
import com.google.gerrit.index.query.FieldBundle; 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.project.SubmitRuleOptions;
import com.google.gerrit.server.query.change.ChangeData; import com.google.gerrit.server.query.change.ChangeData;
import com.google.gerrit.server.query.change.ChangeDataSource; 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.Inject;
import com.google.inject.assistedinject.Assisted; import com.google.inject.assistedinject.Assisted;
import com.google.protobuf.MessageLite; import com.google.protobuf.MessageLite;
@@ -212,7 +212,7 @@ public class LuceneChangeIndex implements ChangeIndex {
} else { } else {
Futures.allAsList(openIndex.delete(id), closedIndex.replace(id, doc)).get(); Futures.allAsList(openIndex.delete(id), closedIndex.replace(id, doc)).get();
} }
} catch (OrmException | ExecutionException | InterruptedException e) { } catch (StorageException | ExecutionException | InterruptedException e) {
throw new IOException(e); throw new IOException(e);
} }
} }
@@ -303,10 +303,10 @@ public class LuceneChangeIndex implements ChangeIndex {
} }
@Override @Override
public ResultSet<ChangeData> read() throws OrmException { public ResultSet<ChangeData> read() throws StorageException {
if (Thread.interrupted()) { if (Thread.interrupted()) {
Thread.currentThread().interrupt(); Thread.currentThread().interrupt();
throw new OrmException("interrupted"); throw new StorageException("interrupted");
} }
final Set<String> fields = IndexUtils.changeFields(opts); final Set<String> fields = IndexUtils.changeFields(opts);
@@ -327,12 +327,12 @@ public class LuceneChangeIndex implements ChangeIndex {
} }
@Override @Override
public ResultSet<FieldBundle> readRaw() throws OrmException { public ResultSet<FieldBundle> readRaw() throws StorageException {
List<Document> documents; List<Document> documents;
try { try {
documents = doRead(IndexUtils.changeFields(opts)); documents = doRead(IndexUtils.changeFields(opts));
} catch (IOException e) { } catch (IOException e) {
throw new OrmException(e); throw new StorageException(e);
} }
ImmutableList<FieldBundle> fieldBundles = ImmutableList<FieldBundle> fieldBundles =
documents.stream().map(rawDocumentMapper).collect(toImmutableList()); documents.stream().map(rawDocumentMapper).collect(toImmutableList());
@@ -415,10 +415,10 @@ public class LuceneChangeIndex implements ChangeIndex {
return result.build(); return result.build();
} catch (InterruptedException e) { } catch (InterruptedException e) {
close(); close();
throw new OrmRuntimeException(e); throw new StorageRuntimeException(e);
} catch (ExecutionException e) { } catch (ExecutionException e) {
Throwables.throwIfUnchecked(e.getCause()); Throwables.throwIfUnchecked(e.getCause());
throw new OrmRuntimeException(e.getCause()); throw new StorageRuntimeException(e.getCause());
} }
} }

View File

@@ -18,6 +18,7 @@ java_library(
"//java/com/google/gerrit/common:annotations", "//java/com/google/gerrit/common:annotations",
"//java/com/google/gerrit/common:server", "//java/com/google/gerrit/common:server",
"//java/com/google/gerrit/elasticsearch", "//java/com/google/gerrit/elasticsearch",
"//java/com/google/gerrit/exceptions",
"//java/com/google/gerrit/extensions:api", "//java/com/google/gerrit/extensions:api",
"//java/com/google/gerrit/gpg", "//java/com/google/gerrit/gpg",
"//java/com/google/gerrit/httpd", "//java/com/google/gerrit/httpd",
@@ -47,7 +48,6 @@ java_library(
"//java/com/google/gerrit/server/util/time", "//java/com/google/gerrit/server/util/time",
"//java/com/google/gerrit/sshd", "//java/com/google/gerrit/sshd",
"//java/com/google/gerrit/util/http", "//java/com/google/gerrit/util/http",
"//java/com/google/gwtorm",
"//lib:args4j", "//lib:args4j",
"//lib:guava", "//lib:guava",
"//lib:protobuf", "//lib:protobuf",

View File

@@ -16,6 +16,7 @@ package com.google.gerrit.pgm;
import static com.google.gerrit.server.account.externalids.ExternalId.SCHEME_GERRIT; 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.extensions.config.FactoryModule;
import com.google.gerrit.lifecycle.LifecycleManager; import com.google.gerrit.lifecycle.LifecycleManager;
import com.google.gerrit.pgm.util.SiteProgram; 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.git.meta.MetaDataUpdate;
import com.google.gerrit.server.index.account.AccountSchemaDefinitions; import com.google.gerrit.server.index.account.AccountSchemaDefinitions;
import com.google.gerrit.server.schema.NoteDbSchemaVersionCheck; import com.google.gerrit.server.schema.NoteDbSchemaVersionCheck;
import com.google.gwtorm.server.OrmDuplicateKeyException;
import com.google.inject.Inject; import com.google.inject.Inject;
import com.google.inject.Injector; import com.google.inject.Injector;
import com.google.inject.Provider; import com.google.inject.Provider;
@@ -96,7 +96,7 @@ public class LocalUsernamesToLowerCase extends SiteProgram {
} }
private void convertLocalUserToLowerCase(ExternalIdNotes extIdNotes, ExternalId extId) private void convertLocalUserToLowerCase(ExternalIdNotes extIdNotes, ExternalId extId)
throws OrmDuplicateKeyException, IOException { throws DuplicateKeyException, IOException {
if (extId.isScheme(SCHEME_GERRIT)) { if (extId.isScheme(SCHEME_GERRIT)) {
String localUser = extId.key().id(); String localUser = extId.key().id();
String localUserLowerCase = localUser.toLowerCase(Locale.US); String localUserLowerCase = localUser.toLowerCase(Locale.US);

View File

@@ -21,7 +21,6 @@ java_library(
"//java/com/google/gerrit/server/ioutil", "//java/com/google/gerrit/server/ioutil",
"//java/com/google/gerrit/server/schema", "//java/com/google/gerrit/server/schema",
"//java/com/google/gerrit/server/util/time", "//java/com/google/gerrit/server/util/time",
"//java/com/google/gwtorm",
"//lib:guava", "//lib:guava",
"//lib:h2", "//lib:h2",
"//lib/commons:validator", "//lib/commons:validator",

View File

@@ -22,6 +22,7 @@ import com.google.common.base.Strings;
import com.google.common.flogger.FluentLogger; import com.google.common.flogger.FluentLogger;
import com.google.gerrit.common.Die; import com.google.gerrit.common.Die;
import com.google.gerrit.common.IoUtil; import com.google.gerrit.common.IoUtil;
import com.google.gerrit.exceptions.StorageException;
import com.google.gerrit.metrics.DisabledMetricMaker; import com.google.gerrit.metrics.DisabledMetricMaker;
import com.google.gerrit.metrics.MetricMaker; import com.google.gerrit.metrics.MetricMaker;
import com.google.gerrit.pgm.init.api.ConsoleUI; import com.google.gerrit.pgm.init.api.ConsoleUI;
@@ -44,7 +45,6 @@ import com.google.gerrit.server.schema.UpdateUI;
import com.google.gerrit.server.securestore.SecureStore; import com.google.gerrit.server.securestore.SecureStore;
import com.google.gerrit.server.securestore.SecureStoreClassName; import com.google.gerrit.server.securestore.SecureStoreClassName;
import com.google.gerrit.server.securestore.SecureStoreProvider; import com.google.gerrit.server.securestore.SecureStoreProvider;
import com.google.gwtorm.server.OrmException;
import com.google.inject.AbstractModule; import com.google.inject.AbstractModule;
import com.google.inject.CreationException; import com.google.inject.CreationException;
import com.google.inject.Guice; import com.google.inject.Guice;
@@ -350,7 +350,7 @@ public class BaseInit extends SiteProgram {
this.repositoryManager = repositoryManager; this.repositoryManager = repositoryManager;
} }
void upgradeSchema() throws OrmException { void upgradeSchema() throws StorageException {
noteDbSchemaUpdater.update(new UpdateUIImpl(ui)); noteDbSchemaUpdater.update(new UpdateUIImpl(ui));
} }

View File

@@ -14,6 +14,7 @@
package com.google.gerrit.pgm.init; package com.google.gerrit.pgm.init;
import com.google.gerrit.exceptions.StorageException;
import com.google.gerrit.pgm.init.api.AllUsersNameOnInitProvider; import com.google.gerrit.pgm.init.api.AllUsersNameOnInitProvider;
import com.google.gerrit.pgm.init.api.InitFlags; import com.google.gerrit.pgm.init.api.InitFlags;
import com.google.gerrit.server.GerritPersonIdentProvider; import com.google.gerrit.server.GerritPersonIdentProvider;
@@ -23,7 +24,6 @@ import com.google.gerrit.server.config.AllUsersName;
import com.google.gerrit.server.config.SitePaths; import com.google.gerrit.server.config.SitePaths;
import com.google.gerrit.server.extensions.events.GitReferenceUpdated; import com.google.gerrit.server.extensions.events.GitReferenceUpdated;
import com.google.gerrit.server.git.meta.MetaDataUpdate; import com.google.gerrit.server.git.meta.MetaDataUpdate;
import com.google.gwtorm.server.OrmException;
import com.google.inject.Inject; import com.google.inject.Inject;
import java.io.File; import java.io.File;
import java.io.IOException; import java.io.IOException;
@@ -49,7 +49,7 @@ public class ExternalIdsOnInit {
} }
public synchronized void insert(String commitMessage, Collection<ExternalId> extIds) public synchronized void insert(String commitMessage, Collection<ExternalId> extIds)
throws OrmException, IOException, ConfigInvalidException { throws StorageException, IOException, ConfigInvalidException {
File path = getPath(); File path = getPath();
if (path != null) { if (path != null) {
try (Repository allUsersRepo = new FileRepository(path)) { try (Repository allUsersRepo = new FileRepository(path)) {

View File

@@ -5,9 +5,9 @@ java_library(
deps = [ deps = [
"//java/com/google/gerrit/common:annotations", "//java/com/google/gerrit/common:annotations",
"//java/com/google/gerrit/common:server", "//java/com/google/gerrit/common:server",
"//java/com/google/gerrit/exceptions",
"//java/com/google/gerrit/reviewdb:server", "//java/com/google/gerrit/reviewdb:server",
"//java/com/google/gerrit/server", "//java/com/google/gerrit/server",
"//java/com/google/gwtorm",
"//lib:guava", "//lib:guava",
"//lib/flogger:api", "//lib/flogger:api",
"//lib/guice", "//lib/guice",

View File

@@ -14,12 +14,12 @@
package com.google.gerrit.pgm.init.api; package com.google.gerrit.pgm.init.api;
import com.google.gerrit.exceptions.StorageException;
import com.google.gerrit.reviewdb.client.Project; import com.google.gerrit.reviewdb.client.Project;
import com.google.gerrit.server.extensions.events.GitReferenceUpdated; import com.google.gerrit.server.extensions.events.GitReferenceUpdated;
import com.google.gerrit.server.git.GitRepositoryManager; import com.google.gerrit.server.git.GitRepositoryManager;
import com.google.gerrit.server.notedb.RepoSequence; import com.google.gerrit.server.notedb.RepoSequence;
import com.google.gerrit.server.notedb.Sequences; import com.google.gerrit.server.notedb.Sequences;
import com.google.gwtorm.server.OrmException;
import com.google.inject.Inject; import com.google.inject.Inject;
import com.google.inject.Singleton; import com.google.inject.Singleton;
@@ -34,7 +34,7 @@ public class SequencesOnInit {
this.allUsersName = allUsersName; this.allUsersName = allUsersName;
} }
public int nextAccountId() throws OrmException { public int nextAccountId() throws StorageException {
RepoSequence accountSeq = RepoSequence accountSeq =
new RepoSequence( new RepoSequence(
repoManager, repoManager,

View File

@@ -17,7 +17,6 @@ java_library(
"//java/com/google/gerrit/server/restapi", "//java/com/google/gerrit/server/restapi",
"//java/com/google/gerrit/server/schema", "//java/com/google/gerrit/server/schema",
"//java/com/google/gerrit/util/cli", "//java/com/google/gerrit/util/cli",
"//java/com/google/gwtorm",
"//lib:args4j", "//lib:args4j",
"//lib:guava", "//lib:guava",
"//lib/flogger:api", "//lib/flogger:api",

View File

@@ -22,6 +22,7 @@ import com.google.common.collect.ListMultimap;
import com.google.common.collect.Table; import com.google.common.collect.Table;
import com.google.gerrit.common.Nullable; import com.google.gerrit.common.Nullable;
import com.google.gerrit.common.data.LabelType; import com.google.gerrit.common.data.LabelType;
import com.google.gerrit.exceptions.StorageException;
import com.google.gerrit.extensions.client.ChangeKind; import com.google.gerrit.extensions.client.ChangeKind;
import com.google.gerrit.reviewdb.client.Account; import com.google.gerrit.reviewdb.client.Account;
import com.google.gerrit.reviewdb.client.PatchSet; import com.google.gerrit.reviewdb.client.PatchSet;
@@ -32,7 +33,6 @@ import com.google.gerrit.server.notedb.ChangeNotes;
import com.google.gerrit.server.project.ProjectCache; import com.google.gerrit.server.project.ProjectCache;
import com.google.gerrit.server.project.ProjectState; import com.google.gerrit.server.project.ProjectState;
import com.google.gerrit.server.query.change.ChangeData; import com.google.gerrit.server.query.change.ChangeData;
import com.google.gwtorm.server.OrmException;
import com.google.inject.Inject; import com.google.inject.Inject;
import com.google.inject.Singleton; import com.google.inject.Singleton;
import java.io.IOException; import java.io.IOException;
@@ -74,7 +74,7 @@ public class ApprovalCopier {
Iterable<PatchSetApproval> getForPatchSet( Iterable<PatchSetApproval> getForPatchSet(
ChangeNotes notes, PatchSet.Id psId, @Nullable RevWalk rw, @Nullable Config repoConfig) ChangeNotes notes, PatchSet.Id psId, @Nullable RevWalk rw, @Nullable Config repoConfig)
throws OrmException { throws StorageException {
return getForPatchSet(notes, psId, rw, repoConfig, Collections.emptyList()); return getForPatchSet(notes, psId, rw, repoConfig, Collections.emptyList());
} }
@@ -84,7 +84,7 @@ public class ApprovalCopier {
@Nullable RevWalk rw, @Nullable RevWalk rw,
@Nullable Config repoConfig, @Nullable Config repoConfig,
Iterable<PatchSetApproval> dontCopy) Iterable<PatchSetApproval> dontCopy)
throws OrmException { throws StorageException {
PatchSet ps = psUtil.get(notes, psId); PatchSet ps = psUtil.get(notes, psId);
if (ps == null) { if (ps == null) {
return Collections.emptyList(); return Collections.emptyList();
@@ -98,7 +98,7 @@ public class ApprovalCopier {
@Nullable RevWalk rw, @Nullable RevWalk rw,
@Nullable Config repoConfig, @Nullable Config repoConfig,
Iterable<PatchSetApproval> dontCopy) Iterable<PatchSetApproval> dontCopy)
throws OrmException { throws StorageException {
requireNonNull(ps, "ps should not be null"); requireNonNull(ps, "ps should not be null");
ChangeData cd = changeDataFactory.create(notes); ChangeData cd = changeDataFactory.create(notes);
try { try {
@@ -153,11 +153,11 @@ public class ApprovalCopier {
} }
return labelNormalizer.normalize(notes, byUser.values()).getNormalized(); return labelNormalizer.normalize(notes, byUser.values()).getNormalized();
} catch (IOException e) { } catch (IOException e) {
throw new OrmException(e); throw new StorageException(e);
} }
} }
private static TreeMap<Integer, PatchSet> getPatchSets(ChangeData cd) throws OrmException { private static TreeMap<Integer, PatchSet> getPatchSets(ChangeData cd) throws StorageException {
Collection<PatchSet> patchSets = cd.patchSets(); Collection<PatchSet> patchSets = cd.patchSets();
TreeMap<Integer, PatchSet> result = new TreeMap<>(); TreeMap<Integer, PatchSet> result = new TreeMap<>();
for (PatchSet ps : patchSets) { for (PatchSet ps : patchSets) {

View File

@@ -29,6 +29,7 @@ import com.google.common.primitives.Shorts;
import com.google.gerrit.common.Nullable; import com.google.gerrit.common.Nullable;
import com.google.gerrit.common.data.LabelType; import com.google.gerrit.common.data.LabelType;
import com.google.gerrit.common.data.LabelTypes; 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.AuthException;
import com.google.gerrit.extensions.restapi.BadRequestException; import com.google.gerrit.extensions.restapi.BadRequestException;
import com.google.gerrit.extensions.restapi.RestApiException; 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.permissions.PermissionBackendException;
import com.google.gerrit.server.project.ProjectCache; import com.google.gerrit.server.project.ProjectCache;
import com.google.gerrit.server.util.LabelVote; import com.google.gerrit.server.util.LabelVote;
import com.google.gwtorm.server.OrmException;
import com.google.inject.Inject; import com.google.inject.Inject;
import com.google.inject.Singleton; import com.google.inject.Singleton;
import java.io.IOException; import java.io.IOException;
@@ -112,9 +112,9 @@ public class ApprovalsUtil {
* *
* @param notes change notes. * @param notes change notes.
* @return reviewers for the 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) throws OrmException { public ReviewerSet getReviewers(ChangeNotes notes) throws StorageException {
return notes.load().getReviewers(); return notes.load().getReviewers();
} }
@@ -123,10 +123,10 @@ public class ApprovalsUtil {
* *
* @param allApprovals all approvals to consider; must all belong to the same change. * @param allApprovals all approvals to consider; must all belong to the same change.
* @return reviewers for the change. * @return reviewers for the change.
* @throws 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<PatchSetApproval> allApprovals) public ReviewerSet getReviewers(ChangeNotes notes, Iterable<PatchSetApproval> allApprovals)
throws OrmException { throws StorageException {
return notes.load().getReviewers(); return notes.load().getReviewers();
} }
@@ -135,9 +135,9 @@ public class ApprovalsUtil {
* *
* @param notes change notes. * @param notes change notes.
* @return reviewer updates for the change. * @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<ReviewerStatusUpdate> getReviewerUpdates(ChangeNotes notes) throws OrmException { public List<ReviewerStatusUpdate> getReviewerUpdates(ChangeNotes notes) throws StorageException {
return notes.load().getReviewerUpdates(); return notes.load().getReviewerUpdates();
} }
@@ -166,7 +166,7 @@ public class ApprovalsUtil {
LabelTypes labelTypes, LabelTypes labelTypes,
Change change, Change change,
Iterable<Account.Id> wantReviewers) Iterable<Account.Id> wantReviewers)
throws OrmException { throws StorageException {
PatchSet.Id psId = change.currentPatchSetId(); PatchSet.Id psId = change.currentPatchSetId();
Collection<Account.Id> existingReviewers; Collection<Account.Id> existingReviewers;
existingReviewers = notes.load().getReviewers().byState(REVIEWER); existingReviewers = notes.load().getReviewers().byState(REVIEWER);
@@ -245,10 +245,11 @@ public class ApprovalsUtil {
* @param update change update. * @param update change update.
* @param wantCCs accounts to CC. * @param wantCCs accounts to CC.
* @return whether a change was made. * @return whether a change was made.
* @throws OrmException * @throws StorageException
*/ */
public Collection<Account.Id> addCcs( public Collection<Account.Id> addCcs(
ChangeNotes notes, ChangeUpdate update, Collection<Account.Id> wantCCs) throws OrmException { ChangeNotes notes, ChangeUpdate update, Collection<Account.Id> wantCCs)
throws StorageException {
return addCcs(update, wantCCs, notes.load().getReviewers()); return addCcs(update, wantCCs, notes.load().getReviewers());
} }
@@ -272,7 +273,7 @@ public class ApprovalsUtil {
* @param user user adding approvals. * @param user user adding approvals.
* @param approvals approvals to add. * @param approvals approvals to add.
* @throws RestApiException * @throws RestApiException
* @throws OrmException * @throws StorageException
*/ */
public Iterable<PatchSetApproval> addApprovalsForNewPatchSet( public Iterable<PatchSetApproval> addApprovalsForNewPatchSet(
ChangeUpdate update, ChangeUpdate update,
@@ -280,7 +281,7 @@ public class ApprovalsUtil {
PatchSet ps, PatchSet ps,
CurrentUser user, CurrentUser user,
Map<String, Short> approvals) Map<String, Short> approvals)
throws RestApiException, OrmException, PermissionBackendException { throws RestApiException, StorageException, PermissionBackendException {
Account.Id accountId = user.getAccountId(); Account.Id accountId = user.getAccountId();
checkArgument( checkArgument(
accountId.equals(ps.getUploader()), accountId.equals(ps.getUploader()),
@@ -331,13 +332,13 @@ public class ApprovalsUtil {
} }
public ListMultimap<PatchSet.Id, PatchSetApproval> byChange(ChangeNotes notes) public ListMultimap<PatchSet.Id, PatchSetApproval> byChange(ChangeNotes notes)
throws OrmException { throws StorageException {
return notes.load().getApprovals(); return notes.load().getApprovals();
} }
public Iterable<PatchSetApproval> byPatchSet( public Iterable<PatchSetApproval> byPatchSet(
ChangeNotes notes, PatchSet.Id psId, @Nullable RevWalk rw, @Nullable Config repoConfig) ChangeNotes notes, PatchSet.Id psId, @Nullable RevWalk rw, @Nullable Config repoConfig)
throws OrmException { throws StorageException {
return copier.getForPatchSet(notes, psId, rw, repoConfig); return copier.getForPatchSet(notes, psId, rw, repoConfig);
} }
@@ -347,7 +348,7 @@ public class ApprovalsUtil {
Account.Id accountId, Account.Id accountId,
@Nullable RevWalk rw, @Nullable RevWalk rw,
@Nullable Config repoConfig) @Nullable Config repoConfig)
throws OrmException { throws StorageException {
return filterApprovals(byPatchSet(notes, psId, rw, repoConfig), accountId); return filterApprovals(byPatchSet(notes, psId, rw, repoConfig), accountId);
} }
@@ -358,7 +359,7 @@ public class ApprovalsUtil {
try { try {
// Submit approval is never copied, so bypass expensive byPatchSet call. // Submit approval is never copied, so bypass expensive byPatchSet call.
return getSubmitter(c, byChange(notes).get(c)); return getSubmitter(c, byChange(notes).get(c));
} catch (OrmException e) { } catch (StorageException e) {
return null; return null;
} }
} }

View File

@@ -18,6 +18,7 @@ import static com.google.common.base.Preconditions.checkState;
import static java.util.Objects.requireNonNull; import static java.util.Objects.requireNonNull;
import com.google.gerrit.common.Nullable; import com.google.gerrit.common.Nullable;
import com.google.gerrit.exceptions.StorageException;
import com.google.gerrit.extensions.common.ChangeMessageInfo; import com.google.gerrit.extensions.common.ChangeMessageInfo;
import com.google.gerrit.reviewdb.client.Account; import com.google.gerrit.reviewdb.client.Account;
import com.google.gerrit.reviewdb.client.ChangeMessage; import com.google.gerrit.reviewdb.client.ChangeMessage;
@@ -26,7 +27,6 @@ import com.google.gerrit.server.account.AccountLoader;
import com.google.gerrit.server.notedb.ChangeNotes; import com.google.gerrit.server.notedb.ChangeNotes;
import com.google.gerrit.server.notedb.ChangeUpdate; import com.google.gerrit.server.notedb.ChangeUpdate;
import com.google.gerrit.server.update.ChangeContext; import com.google.gerrit.server.update.ChangeContext;
import com.google.gwtorm.server.OrmException;
import com.google.inject.Singleton; import com.google.inject.Singleton;
import java.sql.Timestamp; import java.sql.Timestamp;
import java.util.List; import java.util.List;
@@ -87,7 +87,7 @@ public class ChangeMessagesUtil {
return workInProgress ? TAG_UPLOADED_WIP_PATCH_SET : TAG_UPLOADED_PATCH_SET; return workInProgress ? TAG_UPLOADED_WIP_PATCH_SET : TAG_UPLOADED_PATCH_SET;
} }
public List<ChangeMessage> byChange(ChangeNotes notes) throws OrmException { public List<ChangeMessage> byChange(ChangeNotes notes) throws StorageException {
return notes.load().getChangeMessages(); return notes.load().getChangeMessages();
} }

View File

@@ -23,6 +23,7 @@ import com.google.common.collect.FluentIterable;
import com.google.common.collect.Lists; import com.google.common.collect.Lists;
import com.google.common.collect.Ordering; import com.google.common.collect.Ordering;
import com.google.gerrit.common.Nullable; import com.google.gerrit.common.Nullable;
import com.google.gerrit.exceptions.StorageException;
import com.google.gerrit.extensions.client.Side; import com.google.gerrit.extensions.client.Side;
import com.google.gerrit.extensions.common.CommentInfo; import com.google.gerrit.extensions.common.CommentInfo;
import com.google.gerrit.extensions.restapi.UnprocessableEntityException; 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.PatchListCache;
import com.google.gerrit.server.patch.PatchListNotAvailableException; import com.google.gerrit.server.patch.PatchListNotAvailableException;
import com.google.gerrit.server.update.ChangeContext; import com.google.gerrit.server.update.ChangeContext;
import com.google.gwtorm.server.OrmException;
import com.google.inject.Inject; import com.google.inject.Inject;
import com.google.inject.Singleton; import com.google.inject.Singleton;
import java.io.IOException; import java.io.IOException;
@@ -124,7 +124,7 @@ public class CommentsUtil {
String message, String message,
@Nullable Boolean unresolved, @Nullable Boolean unresolved,
@Nullable String parentUuid) @Nullable String parentUuid)
throws OrmException, UnprocessableEntityException { throws StorageException, UnprocessableEntityException {
if (unresolved == null) { if (unresolved == null) {
if (parentUuid == null) { if (parentUuid == null) {
// Default to false if comment is not descended from another. // Default to false if comment is not descended from another.
@@ -175,28 +175,29 @@ public class CommentsUtil {
return c; return c;
} }
public Optional<Comment> getPublished(ChangeNotes notes, Comment.Key key) throws OrmException { public Optional<Comment> getPublished(ChangeNotes notes, Comment.Key key)
throws StorageException {
return publishedByChange(notes).stream().filter(c -> key.equals(c.key)).findFirst(); return publishedByChange(notes).stream().filter(c -> key.equals(c.key)).findFirst();
} }
public Optional<Comment> getDraft(ChangeNotes notes, IdentifiedUser user, Comment.Key key) public Optional<Comment> getDraft(ChangeNotes notes, IdentifiedUser user, Comment.Key key)
throws OrmException { throws StorageException {
return draftByChangeAuthor(notes, user.getAccountId()).stream() return draftByChangeAuthor(notes, user.getAccountId()).stream()
.filter(c -> key.equals(c.key)) .filter(c -> key.equals(c.key))
.findFirst(); .findFirst();
} }
public List<Comment> publishedByChange(ChangeNotes notes) throws OrmException { public List<Comment> publishedByChange(ChangeNotes notes) throws StorageException {
notes.load(); notes.load();
return sort(Lists.newArrayList(notes.getComments().values())); return sort(Lists.newArrayList(notes.getComments().values()));
} }
public List<RobotComment> robotCommentsByChange(ChangeNotes notes) throws OrmException { public List<RobotComment> robotCommentsByChange(ChangeNotes notes) throws StorageException {
notes.load(); notes.load();
return sort(Lists.newArrayList(notes.getRobotComments().values())); return sort(Lists.newArrayList(notes.getRobotComments().values()));
} }
public List<Comment> draftByChange(ChangeNotes notes) throws OrmException { public List<Comment> draftByChange(ChangeNotes notes) throws StorageException {
List<Comment> comments = new ArrayList<>(); List<Comment> comments = new ArrayList<>();
for (Ref ref : getDraftRefs(notes.getChangeId())) { for (Ref ref : getDraftRefs(notes.getChangeId())) {
Account.Id account = Account.Id.fromRefSuffix(ref.getName()); Account.Id account = Account.Id.fromRefSuffix(ref.getName());
@@ -207,7 +208,7 @@ public class CommentsUtil {
return sort(comments); return sort(comments);
} }
public List<Comment> byPatchSet(ChangeNotes notes, PatchSet.Id psId) throws OrmException { public List<Comment> byPatchSet(ChangeNotes notes, PatchSet.Id psId) throws StorageException {
List<Comment> comments = new ArrayList<>(); List<Comment> comments = new ArrayList<>();
comments.addAll(publishedByPatchSet(notes, psId)); comments.addAll(publishedByPatchSet(notes, psId));
@@ -220,18 +221,19 @@ public class CommentsUtil {
return sort(comments); return sort(comments);
} }
public List<Comment> publishedByChangeFile(ChangeNotes notes, String file) throws OrmException { public List<Comment> publishedByChangeFile(ChangeNotes notes, String file)
throws StorageException {
return commentsOnFile(notes.load().getComments().values(), file); return commentsOnFile(notes.load().getComments().values(), file);
} }
public List<Comment> publishedByPatchSet(ChangeNotes notes, PatchSet.Id psId) public List<Comment> publishedByPatchSet(ChangeNotes notes, PatchSet.Id psId)
throws OrmException { throws StorageException {
return removeCommentsOnAncestorOfCommitMessage( return removeCommentsOnAncestorOfCommitMessage(
commentsOnPatchSet(notes.load().getComments().values(), psId)); commentsOnPatchSet(notes.load().getComments().values(), psId));
} }
public List<RobotComment> robotCommentsByPatchSet(ChangeNotes notes, PatchSet.Id psId) public List<RobotComment> robotCommentsByPatchSet(ChangeNotes notes, PatchSet.Id psId)
throws OrmException { throws StorageException {
return commentsOnPatchSet(notes.load().getRobotComments().values(), psId); return commentsOnPatchSet(notes.load().getRobotComments().values(), psId);
} }
@@ -249,17 +251,17 @@ public class CommentsUtil {
} }
public List<Comment> draftByPatchSetAuthor(PatchSet.Id psId, Account.Id author, ChangeNotes notes) public List<Comment> draftByPatchSetAuthor(PatchSet.Id psId, Account.Id author, ChangeNotes notes)
throws OrmException { throws StorageException {
return commentsOnPatchSet(notes.load().getDraftComments(author).values(), psId); return commentsOnPatchSet(notes.load().getDraftComments(author).values(), psId);
} }
public List<Comment> draftByChangeFileAuthor(ChangeNotes notes, String file, Account.Id author) public List<Comment> draftByChangeFileAuthor(ChangeNotes notes, String file, Account.Id author)
throws OrmException { throws StorageException {
return commentsOnFile(notes.load().getDraftComments(author).values(), file); return commentsOnFile(notes.load().getDraftComments(author).values(), file);
} }
public List<Comment> draftByChangeAuthor(ChangeNotes notes, Account.Id author) public List<Comment> draftByChangeAuthor(ChangeNotes notes, Account.Id author)
throws OrmException { throws StorageException {
List<Comment> comments = new ArrayList<>(); List<Comment> comments = new ArrayList<>();
comments.addAll(notes.getDraftComments(author).values()); comments.addAll(notes.getDraftComments(author).values());
return sort(comments); return sort(comments);
@@ -343,11 +345,11 @@ public class CommentsUtil {
* @param changeId change ID. * @param changeId change ID.
* @return raw refs from All-Users repo. * @return raw refs from All-Users repo.
*/ */
public Collection<Ref> getDraftRefs(Change.Id changeId) throws OrmException { public Collection<Ref> getDraftRefs(Change.Id changeId) throws StorageException {
try (Repository repo = repoManager.openRepository(allUsers)) { try (Repository repo = repoManager.openRepository(allUsers)) {
return getDraftRefs(repo, changeId); return getDraftRefs(repo, changeId);
} catch (IOException e) { } catch (IOException e) {
throw new OrmException(e); throw new StorageException(e);
} }
} }

View File

@@ -22,6 +22,7 @@ import com.google.common.collect.ImmutableMap;
import com.google.common.collect.Maps; import com.google.common.collect.Maps;
import com.google.gerrit.common.data.LabelFunction; import com.google.gerrit.common.data.LabelFunction;
import com.google.gerrit.common.data.LabelType; import com.google.gerrit.common.data.LabelType;
import com.google.gerrit.exceptions.StorageException;
import com.google.gerrit.extensions.restapi.ResourceConflictException; import com.google.gerrit.extensions.restapi.ResourceConflictException;
import com.google.gerrit.reviewdb.client.Change; import com.google.gerrit.reviewdb.client.Change;
import com.google.gerrit.reviewdb.client.PatchSet; import com.google.gerrit.reviewdb.client.PatchSet;
@@ -33,7 +34,6 @@ import com.google.gerrit.server.notedb.ChangeNotes;
import com.google.gerrit.server.notedb.ChangeUpdate; import com.google.gerrit.server.notedb.ChangeUpdate;
import com.google.gerrit.server.project.ProjectCache; import com.google.gerrit.server.project.ProjectCache;
import com.google.gerrit.server.project.ProjectState; import com.google.gerrit.server.project.ProjectState;
import com.google.gwtorm.server.OrmException;
import com.google.inject.Inject; import com.google.inject.Inject;
import com.google.inject.Provider; import com.google.inject.Provider;
import com.google.inject.Singleton; import com.google.inject.Singleton;
@@ -63,24 +63,25 @@ public class PatchSetUtil {
this.repoManager = repoManager; this.repoManager = repoManager;
} }
public PatchSet current(ChangeNotes notes) throws OrmException { public PatchSet current(ChangeNotes notes) throws StorageException {
return get(notes, notes.getChange().currentPatchSetId()); 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); return notes.load().getPatchSets().get(psId);
} }
public ImmutableCollection<PatchSet> byChange(ChangeNotes notes) throws OrmException { public ImmutableCollection<PatchSet> byChange(ChangeNotes notes) throws StorageException {
return notes.load().getPatchSets().values(); return notes.load().getPatchSets().values();
} }
public ImmutableMap<PatchSet.Id, PatchSet> byChangeAsMap(ChangeNotes notes) throws OrmException { public ImmutableMap<PatchSet.Id, PatchSet> byChangeAsMap(ChangeNotes notes)
throws StorageException {
return notes.load().getPatchSets(); return notes.load().getPatchSets();
} }
public ImmutableMap<PatchSet.Id, PatchSet> getAsMap( public ImmutableMap<PatchSet.Id, PatchSet> getAsMap(
ChangeNotes notes, Set<PatchSet.Id> patchSetIds) throws OrmException { ChangeNotes notes, Set<PatchSet.Id> patchSetIds) throws StorageException {
return ImmutableMap.copyOf(Maps.filterKeys(notes.load().getPatchSets(), patchSetIds::contains)); 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. */ /** Check if the current patch set of the change is locked. */
public void checkPatchSetNotLocked(ChangeNotes notes) public void checkPatchSetNotLocked(ChangeNotes notes)
throws OrmException, IOException, ResourceConflictException { throws StorageException, IOException, ResourceConflictException {
if (isPatchSetLocked(notes)) { if (isPatchSetLocked(notes)) {
throw new ResourceConflictException( throw new ResourceConflictException(
String.format("The current patch set of change %s is locked", notes.getChangeId())); String.format("The current patch set of change %s is locked", notes.getChangeId()));
@@ -143,7 +144,7 @@ public class PatchSetUtil {
} }
/** Is the current patch set locked against state changes? */ /** Is the current patch set locked against state changes? */
public boolean isPatchSetLocked(ChangeNotes notes) throws OrmException, IOException { public boolean isPatchSetLocked(ChangeNotes notes) throws StorageException, IOException {
Change change = notes.getChange(); Change change = notes.getChange();
if (change.isMerged()) { if (change.isMerged()) {
return false; return false;

View File

@@ -19,13 +19,13 @@ import static com.google.gerrit.reviewdb.client.PatchLineComment.Status.PUBLISHE
import static java.util.stream.Collectors.toSet; import static java.util.stream.Collectors.toSet;
import com.google.gerrit.common.Nullable; 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.Comment;
import com.google.gerrit.reviewdb.client.PatchSet; import com.google.gerrit.reviewdb.client.PatchSet;
import com.google.gerrit.server.notedb.ChangeNotes; import com.google.gerrit.server.notedb.ChangeNotes;
import com.google.gerrit.server.patch.PatchListCache; import com.google.gerrit.server.patch.PatchListCache;
import com.google.gerrit.server.patch.PatchListNotAvailableException; import com.google.gerrit.server.patch.PatchListNotAvailableException;
import com.google.gerrit.server.update.ChangeContext; import com.google.gerrit.server.update.ChangeContext;
import com.google.gwtorm.server.OrmException;
import com.google.inject.Inject; import com.google.inject.Inject;
import com.google.inject.Singleton; import com.google.inject.Singleton;
import java.util.Collection; import java.util.Collection;
@@ -47,7 +47,7 @@ public class PublishCommentUtil {
public void publish( public void publish(
ChangeContext ctx, PatchSet.Id psId, Collection<Comment> drafts, @Nullable String tag) ChangeContext ctx, PatchSet.Id psId, Collection<Comment> drafts, @Nullable String tag)
throws OrmException { throws StorageException {
ChangeNotes notes = ctx.getNotes(); ChangeNotes notes = ctx.getNotes();
checkArgument(notes != null); checkArgument(notes != null);
if (drafts.isEmpty()) { if (drafts.isEmpty()) {
@@ -59,7 +59,7 @@ public class PublishCommentUtil {
for (Comment d : drafts) { for (Comment d : drafts) {
PatchSet ps = patchSets.get(psId(notes, d)); PatchSet ps = patchSets.get(psId(notes, d));
if (ps == null) { if (ps == null) {
throw new OrmException("patch set " + ps + " not found"); throw new StorageException("patch set " + ps + " not found");
} }
d.writtenOn = ctx.getWhen(); d.writtenOn = ctx.getWhen();
d.tag = tag; d.tag = tag;
@@ -69,7 +69,7 @@ public class PublishCommentUtil {
try { try {
CommentsUtil.setCommentRevId(d, patchListCache, notes.getChange(), ps); CommentsUtil.setCommentRevId(d, patchListCache, notes.getChange(), ps);
} catch (PatchListNotAvailableException e) { } catch (PatchListNotAvailableException e) {
throw new OrmException(e); throw new StorageException(e);
} }
} }
commentsUtil.putComments(ctx.getUpdate(psId), PUBLISHED, drafts); commentsUtil.putComments(ctx.getUpdate(psId), PUBLISHED, drafts);

View File

@@ -31,6 +31,7 @@ import com.google.common.collect.Sets;
import com.google.common.flogger.FluentLogger; import com.google.common.flogger.FluentLogger;
import com.google.common.primitives.Ints; import com.google.common.primitives.Ints;
import com.google.gerrit.common.Nullable; import com.google.gerrit.common.Nullable;
import com.google.gerrit.exceptions.StorageException;
import com.google.gerrit.reviewdb.client.Account; import com.google.gerrit.reviewdb.client.Account;
import com.google.gerrit.reviewdb.client.Change; import com.google.gerrit.reviewdb.client.Change;
import com.google.gerrit.reviewdb.client.Project; 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.project.NoSuchChangeException;
import com.google.gerrit.server.query.change.ChangeData; import com.google.gerrit.server.query.change.ChangeData;
import com.google.gerrit.server.query.change.InternalChangeQuery; import com.google.gerrit.server.query.change.InternalChangeQuery;
import com.google.gwtorm.server.OrmException;
import com.google.inject.Inject; import com.google.inject.Inject;
import com.google.inject.Provider; import com.google.inject.Provider;
import com.google.inject.Singleton; import com.google.inject.Singleton;
@@ -187,11 +187,11 @@ public class StarredChangesUtil {
} }
public ImmutableSortedSet<String> getLabels(Account.Id accountId, Change.Id changeId) public ImmutableSortedSet<String> getLabels(Account.Id accountId, Change.Id changeId)
throws OrmException { throws StorageException {
try (Repository repo = repoManager.openRepository(allUsers)) { try (Repository repo = repoManager.openRepository(allUsers)) {
return readLabels(repo, RefNames.refsStarredChanges(changeId, accountId)).labels(); return readLabels(repo, RefNames.refsStarredChanges(changeId, accountId)).labels();
} catch (IOException e) { } catch (IOException e) {
throw new OrmException( throw new StorageException(
String.format( String.format(
"Reading stars from change %d for account %d failed", "Reading stars from change %d for account %d failed",
changeId.get(), accountId.get()), changeId.get(), accountId.get()),
@@ -205,7 +205,7 @@ public class StarredChangesUtil {
Change.Id changeId, Change.Id changeId,
Set<String> labelsToAdd, Set<String> labelsToAdd,
Set<String> labelsToRemove) Set<String> labelsToRemove)
throws OrmException, IllegalLabelException { throws StorageException, IllegalLabelException {
try (Repository repo = repoManager.openRepository(allUsers)) { try (Repository repo = repoManager.openRepository(allUsers)) {
String refName = RefNames.refsStarredChanges(changeId, accountId); String refName = RefNames.refsStarredChanges(changeId, accountId);
StarRef old = readLabels(repo, refName); StarRef old = readLabels(repo, refName);
@@ -228,13 +228,13 @@ public class StarredChangesUtil {
indexer.index(project, changeId); indexer.index(project, changeId);
return ImmutableSortedSet.copyOf(labels); return ImmutableSortedSet.copyOf(labels);
} catch (IOException e) { } catch (IOException e) {
throw new OrmException( throw new StorageException(
String.format("Star change %d for account %d failed", changeId.get(), accountId.get()), String.format("Star change %d for account %d failed", changeId.get(), accountId.get()),
e); 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); try (Repository repo = repoManager.openRepository(allUsers);
RevWalk rw = new RevWalk(repo)) { RevWalk rw = new RevWalk(repo)) {
BatchRefUpdate batchUpdate = repo.getRefDatabase().newBatchUpdate(); BatchRefUpdate batchUpdate = repo.getRefDatabase().newBatchUpdate();
@@ -257,11 +257,11 @@ public class StarredChangesUtil {
} }
indexer.index(project, changeId); indexer.index(project, changeId);
} catch (IOException e) { } 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<Account.Id, StarRef> byChange(Change.Id changeId) throws OrmException { public ImmutableMap<Account.Id, StarRef> byChange(Change.Id changeId) throws StorageException {
try (Repository repo = repoManager.openRepository(allUsers)) { try (Repository repo = repoManager.openRepository(allUsers)) {
ImmutableMap.Builder<Account.Id, StarRef> builder = ImmutableMap.builder(); ImmutableMap.Builder<Account.Id, StarRef> builder = ImmutableMap.builder();
for (String refPart : getRefNames(repo, RefNames.refsStarredChangesPrefix(changeId))) { for (String refPart : getRefNames(repo, RefNames.refsStarredChangesPrefix(changeId))) {
@@ -274,13 +274,13 @@ public class StarredChangesUtil {
} }
return builder.build(); return builder.build();
} catch (IOException e) { } catch (IOException e) {
throw new OrmException( throw new StorageException(
String.format("Get accounts that starred change %d failed", changeId.get()), e); String.format("Get accounts that starred change %d failed", changeId.get()), e);
} }
} }
public ImmutableListMultimap<Account.Id, String> byChangeFromIndex(Change.Id changeId) public ImmutableListMultimap<Account.Id, String> byChangeFromIndex(Change.Id changeId)
throws OrmException { throws StorageException {
List<ChangeData> changeData = List<ChangeData> changeData =
queryProvider queryProvider
.get() .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( star(
rsrc.getUser().asIdentifiedUser().getAccountId(), rsrc.getUser().asIdentifiedUser().getAccountId(),
rsrc.getProject(), rsrc.getProject(),
@@ -320,7 +320,7 @@ public class StarredChangesUtil {
ImmutableSet.of()); ImmutableSet.of());
} }
public void unignore(ChangeResource rsrc) throws OrmException, IllegalLabelException { public void unignore(ChangeResource rsrc) throws StorageException, IllegalLabelException {
star( star(
rsrc.getUser().asIdentifiedUser().getAccountId(), rsrc.getUser().asIdentifiedUser().getAccountId(),
rsrc.getProject(), rsrc.getProject(),
@@ -329,11 +329,11 @@ public class StarredChangesUtil {
ImmutableSet.of(IGNORE_LABEL)); 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); 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()); return isIgnoredBy(rsrc.getChange().getId(), rsrc.getUser().asIdentifiedUser().getAccountId());
} }
@@ -353,7 +353,7 @@ public class StarredChangesUtil {
return UNREVIEWED_LABEL + "/" + ps; return UNREVIEWED_LABEL + "/" + ps;
} }
public void markAsReviewed(ChangeResource rsrc) throws OrmException, IllegalLabelException { public void markAsReviewed(ChangeResource rsrc) throws StorageException, IllegalLabelException {
star( star(
rsrc.getUser().asIdentifiedUser().getAccountId(), rsrc.getUser().asIdentifiedUser().getAccountId(),
rsrc.getProject(), rsrc.getProject(),
@@ -362,7 +362,7 @@ public class StarredChangesUtil {
ImmutableSet.of(getUnreviewedLabel(rsrc.getChange()))); ImmutableSet.of(getUnreviewedLabel(rsrc.getChange())));
} }
public void markAsUnreviewed(ChangeResource rsrc) throws OrmException, IllegalLabelException { public void markAsUnreviewed(ChangeResource rsrc) throws StorageException, IllegalLabelException {
star( star(
rsrc.getUser().asIdentifiedUser().getAccountId(), rsrc.getUser().asIdentifiedUser().getAccountId(),
rsrc.getProject(), rsrc.getProject(),
@@ -444,7 +444,7 @@ public class StarredChangesUtil {
private void updateLabels( private void updateLabels(
Repository repo, String refName, ObjectId oldObjectId, Collection<String> labels) Repository repo, String refName, ObjectId oldObjectId, Collection<String> labels)
throws IOException, OrmException, InvalidLabelsException { throws IOException, StorageException, InvalidLabelsException {
try (TraceTimer traceTimer = try (TraceTimer traceTimer =
TraceContext.newTimer("Update star labels in %s (labels=%s)", refName, labels); TraceContext.newTimer("Update star labels in %s (labels=%s)", refName, labels);
RevWalk rw = new RevWalk(repo)) { RevWalk rw = new RevWalk(repo)) {
@@ -471,14 +471,14 @@ public class StarredChangesUtil {
case REJECTED_MISSING_OBJECT: case REJECTED_MISSING_OBJECT:
case REJECTED_OTHER_REASON: case REJECTED_OTHER_REASON:
default: default:
throw new OrmException( throw new StorageException(
String.format("Update star labels on ref %s failed: %s", refName, result.name())); String.format("Update star labels on ref %s failed: %s", refName, result.name()));
} }
} }
} }
private void deleteRef(Repository repo, String refName, ObjectId oldObjectId) private void deleteRef(Repository repo, String refName, ObjectId oldObjectId)
throws IOException, OrmException { throws IOException, StorageException {
if (ObjectId.zeroId().equals(oldObjectId)) { if (ObjectId.zeroId().equals(oldObjectId)) {
// ref doesn't exist // ref doesn't exist
return; return;
@@ -507,7 +507,7 @@ public class StarredChangesUtil {
case REJECTED_MISSING_OBJECT: case REJECTED_MISSING_OBJECT:
case REJECTED_OTHER_REASON: case REJECTED_OTHER_REASON:
default: default:
throw new OrmException( throw new StorageException(
String.format("Delete star ref %s failed: %s", refName, result.name())); String.format("Delete star ref %s failed: %s", refName, result.name()));
} }
} }

View File

@@ -21,6 +21,7 @@ import com.google.common.base.Strings;
import com.google.common.collect.ImmutableList; import com.google.common.collect.ImmutableList;
import com.google.common.collect.ImmutableMap; import com.google.common.collect.ImmutableMap;
import com.google.common.collect.ImmutableSet; 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.DiffPreferencesInfo;
import com.google.gerrit.extensions.client.EditPreferencesInfo; import com.google.gerrit.extensions.client.EditPreferencesInfo;
import com.google.gerrit.extensions.client.GeneralPreferencesInfo; 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.MetaDataUpdate;
import com.google.gerrit.server.git.meta.VersionedMetaData; import com.google.gerrit.server.git.meta.VersionedMetaData;
import com.google.gerrit.server.util.time.TimeUtil; import com.google.gerrit.server.util.time.TimeUtil;
import com.google.gwtorm.server.OrmDuplicateKeyException;
import java.io.IOException; import java.io.IOException;
import java.sql.Timestamp; import java.sql.Timestamp;
import java.util.ArrayList; import java.util.ArrayList;
@@ -200,9 +200,9 @@ public class AccountConfig extends VersionedMetaData implements ValidationError.
* Creates a new account. * Creates a new account.
* *
* @return the 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()); return getNewAccount(TimeUtil.nowTs());
} }
@@ -210,12 +210,12 @@ public class AccountConfig extends VersionedMetaData implements ValidationError.
* Creates a new account. * Creates a new account.
* *
* @return the 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(); checkLoaded();
if (revision != null) { 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 = this.loadedAccountProperties =
Optional.of(new AccountProperties(accountId, registeredOn, new Config(), null)); Optional.of(new AccountProperties(accountId, registeredOn, new Config(), null));

View File

@@ -26,6 +26,7 @@ import com.google.gerrit.common.data.AccessSection;
import com.google.gerrit.common.data.GlobalCapability; import com.google.gerrit.common.data.GlobalCapability;
import com.google.gerrit.common.data.Permission; import com.google.gerrit.common.data.Permission;
import com.google.gerrit.exceptions.NoSuchGroupException; import com.google.gerrit.exceptions.NoSuchGroupException;
import com.google.gerrit.exceptions.StorageException;
import com.google.gerrit.extensions.client.AccountFieldName; import com.google.gerrit.extensions.client.AccountFieldName;
import com.google.gerrit.reviewdb.client.Account; import com.google.gerrit.reviewdb.client.Account;
import com.google.gerrit.reviewdb.client.AccountGroup; import com.google.gerrit.reviewdb.client.AccountGroup;
@@ -42,7 +43,6 @@ import com.google.gerrit.server.group.db.InternalGroupUpdate;
import com.google.gerrit.server.notedb.Sequences; import com.google.gerrit.server.notedb.Sequences;
import com.google.gerrit.server.project.ProjectCache; import com.google.gerrit.server.project.ProjectCache;
import com.google.gerrit.server.ssh.SshKeyCache; import com.google.gerrit.server.ssh.SshKeyCache;
import com.google.gwtorm.server.OrmException;
import com.google.inject.Inject; import com.google.inject.Inject;
import com.google.inject.Provider; import com.google.inject.Provider;
import com.google.inject.Singleton; import com.google.inject.Singleton;
@@ -163,7 +163,7 @@ public class AccountManager {
// return the identity to the caller. // return the identity to the caller.
update(who, extId); update(who, extId);
return new AuthResult(extId.accountId(), who.getExternalIdKey(), false); return new AuthResult(extId.accountId(), who.getExternalIdKey(), false);
} catch (OrmException | ConfigInvalidException e) { } catch (StorageException | ConfigInvalidException e) {
throw new AccountException("Authentication error", e); throw new AccountException("Authentication error", e);
} }
} }
@@ -214,7 +214,7 @@ public class AccountManager {
} }
private void update(AuthRequest who, ExternalId extId) private void update(AuthRequest who, ExternalId extId)
throws OrmException, IOException, ConfigInvalidException, AccountException { throws StorageException, IOException, ConfigInvalidException, AccountException {
IdentifiedUser user = userFactory.create(extId.accountId()); IdentifiedUser user = userFactory.create(extId.accountId());
List<Consumer<InternalAccountUpdate.Builder>> accountUpdates = new ArrayList<>(); List<Consumer<InternalAccountUpdate.Builder>> accountUpdates = new ArrayList<>();
@@ -266,12 +266,12 @@ public class AccountManager {
user.getAccountId(), user.getAccountId(),
AccountUpdater.joinConsumers(accountUpdates)) AccountUpdater.joinConsumers(accountUpdates))
.orElseThrow( .orElseThrow(
() -> new OrmException("Account " + user.getAccountId() + " has been deleted")); () -> new StorageException("Account " + user.getAccountId() + " has been deleted"));
} }
} }
private AuthResult create(AuthRequest who) private AuthResult create(AuthRequest who)
throws OrmException, AccountException, IOException, ConfigInvalidException { throws StorageException, AccountException, IOException, ConfigInvalidException {
Account.Id newId = new Account.Id(sequences.nextAccountId()); Account.Id newId = new Account.Id(sequences.nextAccountId());
logger.atFine().log("Assigning new Id %s to account", newId); logger.atFine().log("Assigning new Id %s to account", newId);
@@ -375,7 +375,7 @@ public class AccountManager {
} }
private void addGroupMember(AccountGroup.UUID groupUuid, IdentifiedUser user) private void addGroupMember(AccountGroup.UUID groupUuid, IdentifiedUser user)
throws OrmException, IOException, ConfigInvalidException, AccountException { throws StorageException, IOException, ConfigInvalidException, AccountException {
// The user initiated this request by logging in. -> Attribute all modifications to that user. // The user initiated this request by logging in. -> Attribute all modifications to that user.
GroupsUpdate groupsUpdate = groupsUpdateFactory.create(user); GroupsUpdate groupsUpdate = groupsUpdateFactory.create(user);
InternalGroupUpdate groupUpdate = InternalGroupUpdate groupUpdate =
@@ -400,7 +400,7 @@ public class AccountManager {
* this time. * this time.
*/ */
public AuthResult link(Account.Id to, AuthRequest who) public AuthResult link(Account.Id to, AuthRequest who)
throws AccountException, OrmException, IOException, ConfigInvalidException { throws AccountException, StorageException, IOException, ConfigInvalidException {
Optional<ExternalId> optionalExtId = externalIds.get(who.getExternalIdKey()); Optional<ExternalId> optionalExtId = externalIds.get(who.getExternalIdKey());
if (optionalExtId.isPresent()) { if (optionalExtId.isPresent()) {
ExternalId extId = optionalExtId.get(); ExternalId extId = optionalExtId.get();
@@ -437,12 +437,12 @@ public class AccountManager {
* @param to account to link the identity onto. * @param to account to link the identity onto.
* @param who the additional identity. * @param who the additional identity.
* @return the result of linking the identity to the user. * @return the result of linking the identity to the user.
* @throws OrmException * @throws StorageException
* @throws AccountException the identity belongs to a different account, or it cannot be linked at * @throws AccountException the identity belongs to a different account, or it cannot be linked at
* this time. * this time.
*/ */
public AuthResult updateLink(Account.Id to, AuthRequest who) public AuthResult updateLink(Account.Id to, AuthRequest who)
throws OrmException, AccountException, IOException, ConfigInvalidException { throws StorageException, AccountException, IOException, ConfigInvalidException {
accountsUpdateProvider accountsUpdateProvider
.get() .get()
.update( .update(
@@ -474,7 +474,7 @@ public class AccountManager {
* found * found
*/ */
public void unlink(Account.Id from, ExternalId.Key extIdKey) public void unlink(Account.Id from, ExternalId.Key extIdKey)
throws AccountException, OrmException, IOException, ConfigInvalidException { throws AccountException, StorageException, IOException, ConfigInvalidException {
unlink(from, ImmutableList.of(extIdKey)); unlink(from, ImmutableList.of(extIdKey));
} }
@@ -487,7 +487,7 @@ public class AccountManager {
* identity was not found * identity was not found
*/ */
public void unlink(Account.Id from, Collection<ExternalId.Key> extIdKeys) public void unlink(Account.Id from, Collection<ExternalId.Key> extIdKeys)
throws AccountException, OrmException, IOException, ConfigInvalidException { throws AccountException, StorageException, IOException, ConfigInvalidException {
if (extIdKeys.isEmpty()) { if (extIdKeys.isEmpty()) {
return; return;
} }

View File

@@ -26,6 +26,7 @@ import com.google.common.base.Suppliers;
import com.google.common.collect.ImmutableList; import com.google.common.collect.ImmutableList;
import com.google.common.collect.ImmutableSet; import com.google.common.collect.ImmutableSet;
import com.google.common.collect.Streams; import com.google.common.collect.Streams;
import com.google.gerrit.exceptions.StorageException;
import com.google.gerrit.extensions.restapi.UnprocessableEntityException; import com.google.gerrit.extensions.restapi.UnprocessableEntityException;
import com.google.gerrit.index.Schema; import com.google.gerrit.index.Schema;
import com.google.gerrit.reviewdb.client.Account; import com.google.gerrit.reviewdb.client.Account;
@@ -34,7 +35,6 @@ import com.google.gerrit.server.IdentifiedUser;
import com.google.gerrit.server.account.externalids.ExternalId; import com.google.gerrit.server.account.externalids.ExternalId;
import com.google.gerrit.server.config.AnonymousCowardName; import com.google.gerrit.server.config.AnonymousCowardName;
import com.google.gerrit.server.query.account.InternalAccountQuery; import com.google.gerrit.server.query.account.InternalAccountQuery;
import com.google.gwtorm.server.OrmException;
import com.google.inject.Inject; import com.google.inject.Inject;
import com.google.inject.Provider; import com.google.inject.Provider;
import com.google.inject.Singleton; import com.google.inject.Singleton;
@@ -216,14 +216,15 @@ public class AccountResolver {
return false; return false;
} }
Optional<I> tryParse(String input) throws IOException, OrmException; Optional<I> tryParse(String input) throws IOException, StorageException;
Stream<AccountState> search(I input) throws OrmException, IOException, ConfigInvalidException; Stream<AccountState> search(I input)
throws StorageException, IOException, ConfigInvalidException;
boolean shortCircuitIfNoResults(); boolean shortCircuitIfNoResults();
default Optional<Stream<AccountState>> trySearch(String input) default Optional<Stream<AccountState>> trySearch(String input)
throws OrmException, IOException, ConfigInvalidException { throws StorageException, IOException, ConfigInvalidException {
Optional<I> parsed = tryParse(input); Optional<I> parsed = tryParse(input);
return parsed.isPresent() ? Optional.of(search(parsed.get())) : Optional.empty(); return parsed.isPresent() ? Optional.of(search(parsed.get())) : Optional.empty();
} }
@@ -335,7 +336,7 @@ public class AccountResolver {
} }
@Override @Override
public Stream<AccountState> search(String nameOrEmail) throws OrmException, IOException { public Stream<AccountState> search(String nameOrEmail) throws StorageException, IOException {
// TODO(dborowitz): This would probably work as a Searcher<Address> // TODO(dborowitz): This would probably work as a Searcher<Address>
int lt = nameOrEmail.indexOf('<'); int lt = nameOrEmail.indexOf('<');
int gt = nameOrEmail.indexOf('>'); int gt = nameOrEmail.indexOf('>');
@@ -368,7 +369,7 @@ public class AccountResolver {
} }
@Override @Override
public Stream<AccountState> search(String input) throws OrmException, IOException { public Stream<AccountState> search(String input) throws StorageException, IOException {
return toAccountStates(emails.getAccountFor(input)); return toAccountStates(emails.getAccountFor(input));
} }
@@ -397,7 +398,7 @@ public class AccountResolver {
} }
@Override @Override
public Optional<AccountState> tryParse(String input) throws OrmException { public Optional<AccountState> tryParse(String input) throws StorageException {
List<AccountState> results = List<AccountState> results =
accountQueryProvider.get().enforceVisibility(true).byFullName(input); accountQueryProvider.get().enforceVisibility(true).byFullName(input);
return results.size() == 1 ? Optional.of(results.get(0)) : Optional.empty(); return results.size() == 1 ? Optional.of(results.get(0)) : Optional.empty();
@@ -426,7 +427,7 @@ public class AccountResolver {
} }
@Override @Override
public Stream<AccountState> search(String input) throws OrmException { public Stream<AccountState> search(String input) throws StorageException {
// At this point we have no clue. Just perform a whole bunch of suggestions and pray we come // At this point we have no clue. Just perform a whole bunch of suggestions and pray we come
// up with a reasonable result list. // up with a reasonable result list.
// TODO(dborowitz): This doesn't match the documentation; consider whether it's possible to be // TODO(dborowitz): This doesn't match the documentation; consider whether it's possible to be
@@ -513,11 +514,11 @@ public class AccountResolver {
* *
* @param input input string. * @param input input string.
* @return a result describing matching accounts. Never null even if the result set is empty. * @return a result describing matching accounts. Never null even if the result set is empty.
* @throws OrmException if an error occurs. * @throws StorageException if an error occurs.
* @throws ConfigInvalidException if an error occurs. * @throws ConfigInvalidException if an error occurs.
* @throws IOException if an error occurs. * @throws IOException if an error occurs.
*/ */
public Result resolve(String input) throws OrmException, ConfigInvalidException, IOException { public Result resolve(String input) throws StorageException, ConfigInvalidException, IOException {
return searchImpl(input, searchers, visibilitySupplier()); return searchImpl(input, searchers, visibilitySupplier());
} }
@@ -539,7 +540,7 @@ public class AccountResolver {
* *
* @param input input string. * @param input input string.
* @return a result describing matching accounts. Never null even if the result set is empty. * @return a result describing matching accounts. Never null even if the result set is empty.
* @throws OrmException if an error occurs. * @throws StorageException if an error occurs.
* @throws ConfigInvalidException if an error occurs. * @throws ConfigInvalidException if an error occurs.
* @throws IOException if an error occurs. * @throws IOException if an error occurs.
* @deprecated for use only by MailUtil for parsing commit footers; that class needs to be * @deprecated for use only by MailUtil for parsing commit footers; that class needs to be
@@ -547,7 +548,7 @@ public class AccountResolver {
*/ */
@Deprecated @Deprecated
public Result resolveByNameOrEmail(String input) public Result resolveByNameOrEmail(String input)
throws OrmException, ConfigInvalidException, IOException { throws StorageException, ConfigInvalidException, IOException {
return searchImpl(input, nameOrEmailSearchers, visibilitySupplier()); return searchImpl(input, nameOrEmailSearchers, visibilitySupplier());
} }
@@ -560,7 +561,7 @@ public class AccountResolver {
String input, String input,
ImmutableList<Searcher<?>> searchers, ImmutableList<Searcher<?>> searchers,
Supplier<Predicate<AccountState>> visibilitySupplier) Supplier<Predicate<AccountState>> visibilitySupplier)
throws OrmException, ConfigInvalidException, IOException { throws StorageException, ConfigInvalidException, IOException {
visibilitySupplier = Suppliers.memoize(visibilitySupplier::get); visibilitySupplier = Suppliers.memoize(visibilitySupplier::get);
List<AccountState> inactive = new ArrayList<>(); List<AccountState> inactive = new ArrayList<>();

View File

@@ -24,6 +24,8 @@ import com.google.common.base.Throwables;
import com.google.common.collect.Iterables; import com.google.common.collect.Iterables;
import com.google.common.collect.Lists; import com.google.common.collect.Lists;
import com.google.common.util.concurrent.Runnables; 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.LockFailureException;
import com.google.gerrit.git.RefUpdateUtil; import com.google.gerrit.git.RefUpdateUtil;
import com.google.gerrit.reviewdb.client.Account; 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;
import com.google.gerrit.server.update.RetryHelper.Action; import com.google.gerrit.server.update.RetryHelper.Action;
import com.google.gerrit.server.update.RetryHelper.ActionType; 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.Provider;
import com.google.inject.assistedinject.Assisted; import com.google.inject.assistedinject.Assisted;
import com.google.inject.assistedinject.AssistedInject; import com.google.inject.assistedinject.AssistedInject;
@@ -293,14 +293,14 @@ public class AccountsUpdate {
* @param accountId ID of the new account * @param accountId ID of the new account
* @param init consumer to populate the new account * @param init consumer to populate the new account
* @return the newly created 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 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 * @throws ConfigInvalidException if any of the account fields has an invalid value
*/ */
public AccountState insert( public AccountState insert(
String message, Account.Id accountId, Consumer<InternalAccountUpdate.Builder> init) String message, Account.Id accountId, Consumer<InternalAccountUpdate.Builder> init)
throws OrmException, IOException, ConfigInvalidException { throws StorageException, IOException, ConfigInvalidException {
return insert(message, accountId, AccountUpdater.fromConsumer(init)); return insert(message, accountId, AccountUpdater.fromConsumer(init));
} }
@@ -311,13 +311,13 @@ public class AccountsUpdate {
* @param accountId ID of the new account * @param accountId ID of the new account
* @param updater updater to populate the new account * @param updater updater to populate the new account
* @return the newly created 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 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 * @throws ConfigInvalidException if any of the account fields has an invalid value
*/ */
public AccountState insert(String message, Account.Id accountId, AccountUpdater updater) public AccountState insert(String message, Account.Id accountId, AccountUpdater updater)
throws OrmException, IOException, ConfigInvalidException { throws StorageException, IOException, ConfigInvalidException {
return updateAccount( return updateAccount(
r -> { r -> {
AccountConfig accountConfig = read(r, accountId); 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 IOException if updating the user branch fails due to an IO error
* @throws LockFailureException if updating the user branch still fails due to concurrent updates * @throws LockFailureException if updating the user branch still fails due to concurrent updates
* after the retry timeout exceeded * after the retry timeout exceeded
* @throws 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 * @throws ConfigInvalidException if any of the account fields has an invalid value
*/ */
public Optional<AccountState> update( public Optional<AccountState> update(
String message, Account.Id accountId, Consumer<InternalAccountUpdate.Builder> update) String message, Account.Id accountId, Consumer<InternalAccountUpdate.Builder> update)
throws OrmException, LockFailureException, IOException, ConfigInvalidException { throws StorageException, LockFailureException, IOException, ConfigInvalidException {
return update(message, accountId, AccountUpdater.fromConsumer(update)); 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 IOException if updating the user branch fails due to an IO error
* @throws LockFailureException if updating the user branch still fails due to concurrent updates * @throws LockFailureException if updating the user branch still fails due to concurrent updates
* after the retry timeout exceeded * after the retry timeout exceeded
* @throws 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 * @throws ConfigInvalidException if any of the account fields has an invalid value
*/ */
public Optional<AccountState> update(String message, Account.Id accountId, AccountUpdater updater) public Optional<AccountState> update(String message, Account.Id accountId, AccountUpdater updater)
throws OrmException, LockFailureException, IOException, ConfigInvalidException { throws StorageException, LockFailureException, IOException, ConfigInvalidException {
return updateAccount( return updateAccount(
r -> { r -> {
AccountConfig accountConfig = read(r, accountId); AccountConfig accountConfig = read(r, accountId);
@@ -407,7 +407,7 @@ public class AccountsUpdate {
} }
private Optional<AccountState> updateAccount(AccountUpdate accountUpdate) private Optional<AccountState> updateAccount(AccountUpdate accountUpdate)
throws IOException, ConfigInvalidException, OrmException { throws IOException, ConfigInvalidException, StorageException {
return executeAccountUpdate( return executeAccountUpdate(
() -> { () -> {
try (Repository allUsersRepo = repoManager.openRepository(allUsersName)) { try (Repository allUsersRepo = repoManager.openRepository(allUsersName)) {
@@ -423,7 +423,7 @@ public class AccountsUpdate {
} }
private Optional<AccountState> executeAccountUpdate(Action<Optional<AccountState>> action) private Optional<AccountState> executeAccountUpdate(Action<Optional<AccountState>> action)
throws IOException, ConfigInvalidException, OrmException { throws IOException, ConfigInvalidException, StorageException {
try { try {
return retryHelper.execute( return retryHelper.execute(
ActionType.ACCOUNT_UPDATE, action, LockFailureException.class::isInstance); ActionType.ACCOUNT_UPDATE, action, LockFailureException.class::isInstance);
@@ -431,8 +431,8 @@ public class AccountsUpdate {
Throwables.throwIfUnchecked(e); Throwables.throwIfUnchecked(e);
Throwables.throwIfInstanceOf(e, IOException.class); Throwables.throwIfInstanceOf(e, IOException.class);
Throwables.throwIfInstanceOf(e, ConfigInvalidException.class); Throwables.throwIfInstanceOf(e, ConfigInvalidException.class);
Throwables.throwIfInstanceOf(e, OrmException.class); Throwables.throwIfInstanceOf(e, StorageException.class);
throw new OrmException(e); throw new StorageException(e);
} }
} }
@@ -441,7 +441,7 @@ public class AccountsUpdate {
Optional<ObjectId> rev, Optional<ObjectId> rev,
Account.Id accountId, Account.Id accountId,
InternalAccountUpdate update) InternalAccountUpdate update)
throws IOException, ConfigInvalidException, OrmDuplicateKeyException { throws IOException, ConfigInvalidException, DuplicateKeyException {
ExternalIdNotes.checkSameAccount( ExternalIdNotes.checkSameAccount(
Iterables.concat( Iterables.concat(
update.getCreatedExternalIds(), update.getCreatedExternalIds(),
@@ -563,7 +563,7 @@ public class AccountsUpdate {
@FunctionalInterface @FunctionalInterface
private static interface AccountUpdate { private static interface AccountUpdate {
UpdatedAccount update(Repository allUsersRepo) UpdatedAccount update(Repository allUsersRepo)
throws IOException, ConfigInvalidException, OrmException; throws IOException, ConfigInvalidException, StorageException;
} }
private static class UpdatedAccount { private static class UpdatedAccount {

View File

@@ -16,11 +16,11 @@ package com.google.gerrit.server.account;
import com.google.common.annotations.VisibleForTesting; import com.google.common.annotations.VisibleForTesting;
import com.google.common.base.Strings; 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.AccountFieldName;
import com.google.gerrit.extensions.client.AuthType; import com.google.gerrit.extensions.client.AuthType;
import com.google.gerrit.reviewdb.client.Account; import com.google.gerrit.reviewdb.client.Account;
import com.google.gerrit.server.config.AuthConfig; import com.google.gerrit.server.config.AuthConfig;
import com.google.gwtorm.server.OrmException;
import com.google.inject.Inject; import com.google.inject.Inject;
import com.google.inject.Provider; import com.google.inject.Provider;
import com.google.inject.Singleton; import com.google.inject.Singleton;
@@ -87,7 +87,7 @@ public class DefaultRealm extends AbstractRealm {
if (1 == c.size()) { if (1 == c.size()) {
return c.iterator().next(); return c.iterator().next();
} }
} catch (OrmException e) { } catch (StorageException e) {
throw new IOException("Failed to query accounts by email", e); throw new IOException("Failed to query accounts by email", e);
} }
} }

View File

@@ -20,6 +20,7 @@ import com.google.common.base.Throwables;
import com.google.common.collect.ImmutableSet; import com.google.common.collect.ImmutableSet;
import com.google.common.collect.ImmutableSetMultimap; import com.google.common.collect.ImmutableSetMultimap;
import com.google.common.collect.Streams; import com.google.common.collect.Streams;
import com.google.gerrit.exceptions.StorageException;
import com.google.gerrit.reviewdb.client.Account; import com.google.gerrit.reviewdb.client.Account;
import com.google.gerrit.server.account.externalids.ExternalId; import com.google.gerrit.server.account.externalids.ExternalId;
import com.google.gerrit.server.account.externalids.ExternalIds; 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;
import com.google.gerrit.server.update.RetryHelper.Action; import com.google.gerrit.server.update.RetryHelper.Action;
import com.google.gerrit.server.update.RetryHelper.ActionType; import com.google.gerrit.server.update.RetryHelper.ActionType;
import com.google.gwtorm.server.OrmException;
import com.google.inject.Inject; import com.google.inject.Inject;
import com.google.inject.Provider; import com.google.inject.Provider;
import com.google.inject.Singleton; import com.google.inject.Singleton;
@@ -69,7 +69,7 @@ public class Emails {
* *
* @see #getAccountsFor(String...) * @see #getAccountsFor(String...)
*/ */
public ImmutableSet<Account.Id> getAccountFor(String email) throws IOException, OrmException { public ImmutableSet<Account.Id> getAccountFor(String email) throws IOException, StorageException {
return Streams.concat( return Streams.concat(
externalIds.byEmail(email).stream().map(ExternalId::accountId), externalIds.byEmail(email).stream().map(ExternalId::accountId),
executeIndexQuery(() -> queryProvider.get().byPreferredEmail(email).stream()) executeIndexQuery(() -> queryProvider.get().byPreferredEmail(email).stream())
@@ -83,7 +83,7 @@ public class Emails {
* @see #getAccountFor(String) * @see #getAccountFor(String)
*/ */
public ImmutableSetMultimap<String, Account.Id> getAccountsFor(String... emails) public ImmutableSetMultimap<String, Account.Id> getAccountsFor(String... emails)
throws IOException, OrmException { throws IOException, StorageException {
ImmutableSetMultimap.Builder<String, Account.Id> builder = ImmutableSetMultimap.builder(); ImmutableSetMultimap.Builder<String, Account.Id> builder = ImmutableSetMultimap.builder();
externalIds.byEmails(emails).entries().stream() externalIds.byEmails(emails).entries().stream()
.forEach(e -> builder.put(e.getKey(), e.getValue().accountId())); .forEach(e -> builder.put(e.getKey(), e.getValue().accountId()));
@@ -102,13 +102,14 @@ public class Emails {
return externalIds.byEmail(email).stream().map(ExternalId::accountId).collect(toImmutableSet()); return externalIds.byEmail(email).stream().map(ExternalId::accountId).collect(toImmutableSet());
} }
private <T> T executeIndexQuery(Action<T> action) throws OrmException { private <T> T executeIndexQuery(Action<T> action) throws StorageException {
try { try {
return retryHelper.execute(ActionType.INDEX_QUERY, action, OrmException.class::isInstance); return retryHelper.execute(
ActionType.INDEX_QUERY, action, StorageException.class::isInstance);
} catch (Exception e) { } catch (Exception e) {
Throwables.throwIfUnchecked(e); Throwables.throwIfUnchecked(e);
Throwables.throwIfInstanceOf(e, OrmException.class); Throwables.throwIfInstanceOf(e, StorageException.class);
throw new OrmException(e); throw new StorageException(e);
} }
} }
} }

View File

@@ -22,6 +22,7 @@ import com.google.common.cache.LoadingCache;
import com.google.common.collect.ImmutableList; import com.google.common.collect.ImmutableList;
import com.google.common.collect.ImmutableSet; import com.google.common.collect.ImmutableSet;
import com.google.common.flogger.FluentLogger; import com.google.common.flogger.FluentLogger;
import com.google.gerrit.exceptions.StorageException;
import com.google.gerrit.reviewdb.client.Account; import com.google.gerrit.reviewdb.client.Account;
import com.google.gerrit.reviewdb.client.AccountGroup; import com.google.gerrit.reviewdb.client.AccountGroup;
import com.google.gerrit.server.cache.CacheModule; import com.google.gerrit.server.cache.CacheModule;
@@ -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;
import com.google.gerrit.server.logging.TraceContext.TraceTimer; import com.google.gerrit.server.logging.TraceContext.TraceTimer;
import com.google.gerrit.server.query.group.InternalGroupQuery; import com.google.gerrit.server.query.group.InternalGroupQuery;
import com.google.gwtorm.server.OrmException;
import com.google.inject.Inject; import com.google.inject.Inject;
import com.google.inject.Module; import com.google.inject.Module;
import com.google.inject.Provider; import com.google.inject.Provider;
@@ -152,7 +152,7 @@ public class GroupIncludeCacheImpl implements GroupIncludeCache {
} }
@Override @Override
public ImmutableSet<AccountGroup.UUID> load(Account.Id memberId) throws OrmException { public ImmutableSet<AccountGroup.UUID> load(Account.Id memberId) throws StorageException {
try (TraceTimer timer = TraceContext.newTimer("Loading groups with member %s", memberId)) { try (TraceTimer timer = TraceContext.newTimer("Loading groups with member %s", memberId)) {
return groupQueryProvider.get().byMember(memberId).stream() return groupQueryProvider.get().byMember(memberId).stream()
.map(InternalGroup::getGroupUUID) .map(InternalGroup::getGroupUUID)
@@ -171,7 +171,7 @@ public class GroupIncludeCacheImpl implements GroupIncludeCache {
} }
@Override @Override
public ImmutableList<AccountGroup.UUID> load(AccountGroup.UUID key) throws OrmException { public ImmutableList<AccountGroup.UUID> load(AccountGroup.UUID key) throws StorageException {
try (TraceTimer timer = TraceContext.newTimer("Loading parent groups of %s", key)) { try (TraceTimer timer = TraceContext.newTimer("Loading parent groups of %s", key)) {
return groupQueryProvider.get().bySubgroup(key).stream() return groupQueryProvider.get().bySubgroup(key).stream()
.map(InternalGroup::getGroupUUID) .map(InternalGroup::getGroupUUID)

View File

@@ -14,6 +14,7 @@
package com.google.gerrit.server.account; package com.google.gerrit.server.account;
import com.google.gerrit.exceptions.StorageException;
import com.google.gerrit.extensions.restapi.ResourceConflictException; import com.google.gerrit.extensions.restapi.ResourceConflictException;
import com.google.gerrit.extensions.restapi.ResourceNotFoundException; import com.google.gerrit.extensions.restapi.ResourceNotFoundException;
import com.google.gerrit.extensions.restapi.Response; import com.google.gerrit.extensions.restapi.Response;
@@ -23,7 +24,6 @@ import com.google.gerrit.server.ServerInitiated;
import com.google.gerrit.server.plugincontext.PluginSetContext; import com.google.gerrit.server.plugincontext.PluginSetContext;
import com.google.gerrit.server.validators.AccountActivationValidationListener; import com.google.gerrit.server.validators.AccountActivationValidationListener;
import com.google.gerrit.server.validators.ValidationException; import com.google.gerrit.server.validators.ValidationException;
import com.google.gwtorm.server.OrmException;
import com.google.inject.Inject; import com.google.inject.Inject;
import com.google.inject.Provider; import com.google.inject.Provider;
import com.google.inject.Singleton; import com.google.inject.Singleton;
@@ -48,7 +48,7 @@ public class SetInactiveFlag {
} }
public Response<?> deactivate(Account.Id accountId) public Response<?> deactivate(Account.Id accountId)
throws RestApiException, IOException, ConfigInvalidException, OrmException { throws RestApiException, IOException, ConfigInvalidException, StorageException {
AtomicBoolean alreadyInactive = new AtomicBoolean(false); AtomicBoolean alreadyInactive = new AtomicBoolean(false);
AtomicReference<Optional<RestApiException>> exception = new AtomicReference<>(Optional.empty()); AtomicReference<Optional<RestApiException>> exception = new AtomicReference<>(Optional.empty());
accountsUpdateProvider accountsUpdateProvider
@@ -81,7 +81,7 @@ public class SetInactiveFlag {
} }
public Response<String> activate(Account.Id accountId) public Response<String> activate(Account.Id accountId)
throws RestApiException, IOException, ConfigInvalidException, OrmException { throws RestApiException, IOException, ConfigInvalidException, StorageException {
AtomicBoolean alreadyActive = new AtomicBoolean(false); AtomicBoolean alreadyActive = new AtomicBoolean(false);
AtomicReference<Optional<RestApiException>> exception = new AtomicReference<>(Optional.empty()); AtomicReference<Optional<RestApiException>> exception = new AtomicReference<>(Optional.empty());
accountsUpdateProvider accountsUpdateProvider

View File

@@ -14,13 +14,13 @@
package com.google.gerrit.server.account.externalids; 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 * Exception that is thrown if an external ID cannot be inserted because an external ID with the
* same key already exists. * same key already exists.
*/ */
public class DuplicateExternalIdKeyException extends OrmDuplicateKeyException { public class DuplicateExternalIdKeyException extends DuplicateKeyException {
private static final long serialVersionUID = 1L; private static final long serialVersionUID = 1L;
private final ExternalId.Key duplicateKey; private final ExternalId.Key duplicateKey;

View File

@@ -7,13 +7,13 @@ java_library(
deps = [ deps = [
"//java/com/google/gerrit/common:annotations", "//java/com/google/gerrit/common:annotations",
"//java/com/google/gerrit/common:server", "//java/com/google/gerrit/common:server",
"//java/com/google/gerrit/exceptions",
"//java/com/google/gerrit/extensions:api", "//java/com/google/gerrit/extensions:api",
"//java/com/google/gerrit/lifecycle", "//java/com/google/gerrit/lifecycle",
"//java/com/google/gerrit/reviewdb:server", "//java/com/google/gerrit/reviewdb:server",
"//java/com/google/gerrit/server", "//java/com/google/gerrit/server",
"//java/com/google/gerrit/server/restapi", "//java/com/google/gerrit/server/restapi",
"//java/com/google/gerrit/util/cli", "//java/com/google/gerrit/util/cli",
"//java/com/google/gwtorm",
"//lib:args4j", "//lib:args4j",
"//lib:guava", "//lib:guava",
"//lib:servlet-api-3_1", "//lib:servlet-api-3_1",

View File

@@ -19,6 +19,7 @@ import static com.google.gerrit.server.api.ApiUtil.asRestApiException;
import com.google.common.collect.ImmutableListMultimap; import com.google.common.collect.ImmutableListMultimap;
import com.google.common.collect.ListMultimap; import com.google.common.collect.ListMultimap;
import com.google.gerrit.common.Nullable; import com.google.gerrit.common.Nullable;
import com.google.gerrit.exceptions.StorageException;
import com.google.gerrit.extensions.api.changes.AbandonInput; import com.google.gerrit.extensions.api.changes.AbandonInput;
import com.google.gerrit.extensions.api.changes.AddReviewerInput; import com.google.gerrit.extensions.api.changes.AddReviewerInput;
import com.google.gerrit.extensions.api.changes.AddReviewerResult; import com.google.gerrit.extensions.api.changes.AddReviewerResult;
@@ -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.SuggestChangeReviewers;
import com.google.gerrit.server.restapi.change.Unignore; import com.google.gerrit.server.restapi.change.Unignore;
import com.google.gerrit.util.cli.CmdLineParser; import com.google.gerrit.util.cli.CmdLineParser;
import com.google.gwtorm.server.OrmException;
import com.google.inject.Inject; import com.google.inject.Inject;
import com.google.inject.Injector; import com.google.inject.Injector;
import com.google.inject.Provider; import com.google.inject.Provider;
@@ -613,7 +613,7 @@ class ChangeApiImpl implements ChangeApi {
} else { } else {
unignore.apply(change, new Input()); unignore.apply(change, new Input());
} }
} catch (OrmException | IllegalLabelException e) { } catch (StorageException | IllegalLabelException e) {
throw asRestApiException("Cannot ignore change", e); throw asRestApiException("Cannot ignore change", e);
} }
} }
@@ -622,7 +622,7 @@ class ChangeApiImpl implements ChangeApi {
public boolean ignored() throws RestApiException { public boolean ignored() throws RestApiException {
try { try {
return stars.isIgnored(change); return stars.isIgnored(change);
} catch (OrmException e) { } catch (StorageException e) {
throw asRestApiException("Cannot check if ignored", e); throw asRestApiException("Cannot check if ignored", e);
} }
} }
@@ -637,7 +637,7 @@ class ChangeApiImpl implements ChangeApi {
} else { } else {
markAsUnreviewed.apply(change, new Input()); markAsUnreviewed.apply(change, new Input());
} }
} catch (OrmException | IllegalLabelException e) { } catch (StorageException | IllegalLabelException e) {
throw asRestApiException( throw asRestApiException(
"Cannot mark change as " + (reviewed ? "reviewed" : "unreviewed"), e); "Cannot mark change as " + (reviewed ? "reviewed" : "unreviewed"), e);
} }

View File

@@ -16,6 +16,7 @@ package com.google.gerrit.server.api.changes;
import static com.google.gerrit.server.api.ApiUtil.asRestApiException; import static com.google.gerrit.server.api.ApiUtil.asRestApiException;
import com.google.gerrit.exceptions.StorageException;
import com.google.gerrit.extensions.api.changes.ChangeEditApi; import com.google.gerrit.extensions.api.changes.ChangeEditApi;
import com.google.gerrit.extensions.api.changes.PublishChangeEditInput; import com.google.gerrit.extensions.api.changes.PublishChangeEditInput;
import com.google.gerrit.extensions.client.ChangeEditDetailOption; import com.google.gerrit.extensions.client.ChangeEditDetailOption;
@@ -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.DeleteChangeEdit;
import com.google.gerrit.server.restapi.change.PublishChangeEdit; import com.google.gerrit.server.restapi.change.PublishChangeEdit;
import com.google.gerrit.server.restapi.change.RebaseChangeEdit; import com.google.gerrit.server.restapi.change.RebaseChangeEdit;
import com.google.gwtorm.server.OrmException;
import com.google.inject.Inject; import com.google.inject.Inject;
import com.google.inject.Provider; import com.google.inject.Provider;
import com.google.inject.assistedinject.Assisted; import com.google.inject.assistedinject.Assisted;
@@ -242,7 +242,7 @@ public class ChangeEditApiImpl implements ChangeEditApi {
} }
private ChangeEditResource getChangeEditResource(String filePath) private ChangeEditResource getChangeEditResource(String filePath)
throws ResourceNotFoundException, AuthException, IOException, OrmException { throws ResourceNotFoundException, AuthException, IOException, StorageException {
return changeEdits.parse(changeResource, IdString.fromDecoded(filePath)); return changeEdits.parse(changeResource, IdString.fromDecoded(filePath));
} }
} }

View File

@@ -16,6 +16,7 @@ package com.google.gerrit.server.api.projects;
import static com.google.gerrit.server.api.ApiUtil.asRestApiException; import static com.google.gerrit.server.api.ApiUtil.asRestApiException;
import com.google.gerrit.exceptions.StorageException;
import com.google.gerrit.extensions.api.projects.ProjectApi; import com.google.gerrit.extensions.api.projects.ProjectApi;
import com.google.gerrit.extensions.api.projects.ProjectInput; import com.google.gerrit.extensions.api.projects.ProjectInput;
import com.google.gerrit.extensions.api.projects.Projects; 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.ListProjects.FilterType;
import com.google.gerrit.server.restapi.project.ProjectsCollection; import com.google.gerrit.server.restapi.project.ProjectsCollection;
import com.google.gerrit.server.restapi.project.QueryProjects; import com.google.gerrit.server.restapi.project.QueryProjects;
import com.google.gwtorm.server.OrmException;
import com.google.inject.Inject; import com.google.inject.Inject;
import com.google.inject.Provider; import com.google.inject.Provider;
import com.google.inject.Singleton; import com.google.inject.Singleton;
@@ -155,7 +155,7 @@ class ProjectsImpl implements Projects {
.withLimit(r.getLimit()) .withLimit(r.getLimit())
.withStart(r.getStart()) .withStart(r.getStart())
.apply(); .apply();
} catch (OrmException e) { } catch (StorageException e) {
throw new RestApiException("Cannot query projects", e); throw new RestApiException("Cannot query projects", e);
} }
} }

View File

@@ -16,6 +16,7 @@ package com.google.gerrit.server.args4j;
import static com.google.gerrit.util.cli.Localizable.localizable; 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.client.AuthType;
import com.google.gerrit.extensions.restapi.UnprocessableEntityException; import com.google.gerrit.extensions.restapi.UnprocessableEntityException;
import com.google.gerrit.reviewdb.client.Account; import com.google.gerrit.reviewdb.client.Account;
@@ -25,7 +26,6 @@ import com.google.gerrit.server.account.AccountResolver;
import com.google.gerrit.server.account.AuthRequest; import com.google.gerrit.server.account.AuthRequest;
import com.google.gerrit.server.account.externalids.ExternalId; import com.google.gerrit.server.account.externalids.ExternalId;
import com.google.gerrit.server.config.AuthConfig; import com.google.gerrit.server.config.AuthConfig;
import com.google.gwtorm.server.OrmException;
import com.google.inject.Inject; import com.google.inject.Inject;
import com.google.inject.assistedinject.Assisted; import com.google.inject.assistedinject.Assisted;
import java.io.IOException; import java.io.IOException;
@@ -81,7 +81,7 @@ public class AccountIdHandler extends OptionHandler<Account.Id> {
throw new CmdLineException(owner, localizable("user \"%s\" not found"), token); throw new CmdLineException(owner, localizable("user \"%s\" not found"), token);
} }
} }
} catch (OrmException e) { } catch (StorageException e) {
throw new CmdLineException(owner, localizable("database is down")); throw new CmdLineException(owner, localizable("database is down"));
} catch (IOException e) { } catch (IOException e) {
throw new CmdLineException(owner, "Failed to load account", e); throw new CmdLineException(owner, "Failed to load account", e);

View File

@@ -17,12 +17,12 @@ package com.google.gerrit.server.args4j;
import static com.google.gerrit.util.cli.Localizable.localizable; import static com.google.gerrit.util.cli.Localizable.localizable;
import com.google.common.base.Splitter; 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.Branch;
import com.google.gerrit.reviewdb.client.Change; import com.google.gerrit.reviewdb.client.Change;
import com.google.gerrit.reviewdb.client.Project; import com.google.gerrit.reviewdb.client.Project;
import com.google.gerrit.server.query.change.ChangeData; import com.google.gerrit.server.query.change.ChangeData;
import com.google.gerrit.server.query.change.InternalChangeQuery; import com.google.gerrit.server.query.change.InternalChangeQuery;
import com.google.gwtorm.server.OrmException;
import com.google.inject.Inject; import com.google.inject.Inject;
import com.google.inject.Provider; import com.google.inject.Provider;
import com.google.inject.assistedinject.Assisted; import com.google.inject.assistedinject.Assisted;
@@ -67,7 +67,7 @@ public class ChangeIdHandler extends OptionHandler<Change.Id> {
} }
} catch (IllegalArgumentException e) { } catch (IllegalArgumentException e) {
throw new CmdLineException(owner, localizable("Change-Id is not valid")); 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()); throw new CmdLineException(owner, localizable("Database error: %s"), e.getMessage());
} }

View File

@@ -21,7 +21,6 @@ java_library(
"//java/com/google/gerrit/server/util/time", "//java/com/google/gerrit/server/util/time",
"//java/com/google/gerrit/util/cli", "//java/com/google/gerrit/util/cli",
"//java/com/google/gerrit/util/ssl", "//java/com/google/gerrit/util/ssl",
"//java/com/google/gwtorm",
"//java/org/apache/commons/net", "//java/org/apache/commons/net",
"//java/org/eclipse/jgit:server", "//java/org/eclipse/jgit:server",
"//lib:args4j", "//lib:args4j",

View File

@@ -17,6 +17,7 @@ package com.google.gerrit.server.change;
import com.google.common.base.Strings; import com.google.common.base.Strings;
import com.google.common.flogger.FluentLogger; import com.google.common.flogger.FluentLogger;
import com.google.gerrit.common.Nullable; import com.google.gerrit.common.Nullable;
import com.google.gerrit.exceptions.StorageException;
import com.google.gerrit.extensions.restapi.ResourceConflictException; import com.google.gerrit.extensions.restapi.ResourceConflictException;
import com.google.gerrit.reviewdb.client.Change; import com.google.gerrit.reviewdb.client.Change;
import com.google.gerrit.reviewdb.client.ChangeMessage; import com.google.gerrit.reviewdb.client.ChangeMessage;
@@ -32,7 +33,6 @@ import com.google.gerrit.server.notedb.ChangeUpdate;
import com.google.gerrit.server.update.BatchUpdateOp; import com.google.gerrit.server.update.BatchUpdateOp;
import com.google.gerrit.server.update.ChangeContext; import com.google.gerrit.server.update.ChangeContext;
import com.google.gerrit.server.update.Context; import com.google.gerrit.server.update.Context;
import com.google.gwtorm.server.OrmException;
import com.google.inject.Inject; import com.google.inject.Inject;
import com.google.inject.assistedinject.Assisted; import com.google.inject.assistedinject.Assisted;
@@ -79,7 +79,8 @@ public class AbandonOp implements BatchUpdateOp {
} }
@Override @Override
public boolean updateChange(ChangeContext ctx) throws OrmException, ResourceConflictException { public boolean updateChange(ChangeContext ctx)
throws StorageException, ResourceConflictException {
change = ctx.getChange(); change = ctx.getChange();
PatchSet.Id psId = change.currentPatchSetId(); PatchSet.Id psId = change.currentPatchSetId();
ChangeUpdate update = ctx.getUpdate(psId); ChangeUpdate update = ctx.getUpdate(psId);
@@ -108,7 +109,7 @@ public class AbandonOp implements BatchUpdateOp {
} }
@Override @Override
public void postUpdate(Context ctx) throws OrmException { public void postUpdate(Context ctx) throws StorageException {
NotifyResolver.Result notify = ctx.getNotify(change.getId()); NotifyResolver.Result notify = ctx.getNotify(change.getId());
try { try {
ReplyToChangeSender cm = abandonedSenderFactory.create(ctx.getProject(), change.getId()); ReplyToChangeSender cm = abandonedSenderFactory.create(ctx.getProject(), change.getId());

View File

@@ -17,6 +17,7 @@ package com.google.gerrit.server.change;
import com.google.common.collect.ImmutableListMultimap; import com.google.common.collect.ImmutableListMultimap;
import com.google.common.collect.ListMultimap; import com.google.common.collect.ListMultimap;
import com.google.common.flogger.FluentLogger; import com.google.common.flogger.FluentLogger;
import com.google.gerrit.exceptions.StorageException;
import com.google.gerrit.index.query.QueryParseException; import com.google.gerrit.index.query.QueryParseException;
import com.google.gerrit.reviewdb.client.Project; import com.google.gerrit.reviewdb.client.Project;
import com.google.gerrit.server.InternalUser; 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.ChangeQueryBuilder;
import com.google.gerrit.server.query.change.ChangeQueryProcessor; import com.google.gerrit.server.query.change.ChangeQueryProcessor;
import com.google.gerrit.server.update.BatchUpdate; import com.google.gerrit.server.update.BatchUpdate;
import com.google.gwtorm.server.OrmException;
import com.google.inject.Inject; import com.google.inject.Inject;
import com.google.inject.Provider; import com.google.inject.Provider;
import com.google.inject.Singleton; import com.google.inject.Singleton;
@@ -96,14 +96,14 @@ public class AbandonUtil {
} }
} }
logger.atInfo().log("Auto-Abandoned %d of %d changes.", count, changesToAbandon.size()); 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( logger.atSevere().withCause(e).log(
"Failed to query inactive open changes for auto-abandoning."); "Failed to query inactive open changes for auto-abandoning.");
} }
} }
private Collection<ChangeData> getValidChanges(Collection<ChangeData> changes, String query) private Collection<ChangeData> getValidChanges(Collection<ChangeData> changes, String query)
throws OrmException, QueryParseException { throws StorageException, QueryParseException {
Collection<ChangeData> validChanges = new ArrayList<>(); Collection<ChangeData> validChanges = new ArrayList<>();
for (ChangeData cd : changes) { for (ChangeData cd : changes) {
String newQuery = query + " change:" + cd.getId(); String newQuery = query + " change:" + cd.getId();

View File

@@ -16,9 +16,9 @@ package com.google.gerrit.server.change;
import com.google.auto.value.AutoValue; import com.google.auto.value.AutoValue;
import com.google.common.collect.ImmutableSet; import com.google.common.collect.ImmutableSet;
import com.google.gerrit.exceptions.StorageException;
import com.google.gerrit.reviewdb.client.Account; import com.google.gerrit.reviewdb.client.Account;
import com.google.gerrit.reviewdb.client.PatchSet; import com.google.gerrit.reviewdb.client.PatchSet;
import com.google.gwtorm.server.OrmException;
import java.util.Collection; import java.util.Collection;
import java.util.Optional; import java.util.Optional;
@@ -54,9 +54,9 @@ public interface AccountPatchReviewStore {
* @param path file path * @param path file path
* @return {@code true} if the reviewed flag was updated, {@code false} if the reviewed flag was * @return {@code true} if the reviewed flag was updated, {@code false} if the reviewed flag was
* already set * already set
* @throws 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. * 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 psId patch set ID
* @param accountId account ID of the user * @param accountId account ID of the user
* @param paths file paths * @param paths file paths
* @throws 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<String> paths) void markReviewed(PatchSet.Id psId, Account.Id accountId, Collection<String> paths)
throws OrmException; throws StorageException;
/** /**
* Clears the reviewed flag for the given file in the given patch set for the given user. * Clears the reviewed flag for the given file in the given patch set for the given user.
@@ -75,17 +75,17 @@ public interface AccountPatchReviewStore {
* @param psId patch set ID * @param psId patch set ID
* @param accountId account ID of the user * @param accountId account ID of the user
* @param path file path * @param path file path
* @throws 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. * Clears the reviewed flags for all files in the given patch set for all users.
* *
* @param psId patch set ID * @param psId patch set ID
* @throws 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, * 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 * @param accountId account ID of the user
* @return optionally, all files the have been reviewed by the given user that belong to the patch * @return optionally, all files the have been reviewed by the given user that belong to the patch
* set that is smaller or equals to the given patch set * set that is smaller or equals to the given patch set
* @throws OrmException thrown if accessing the reviewed flags failed * @throws StorageException thrown if accessing the reviewed flags failed
*/ */
Optional<PatchSetWithReviewedFiles> findReviewed(PatchSet.Id psId, Account.Id accountId) Optional<PatchSetWithReviewedFiles> findReviewed(PatchSet.Id psId, Account.Id accountId)
throws OrmException; throws StorageException;
} }

View File

@@ -20,6 +20,7 @@ import com.google.common.collect.ImmutableMap;
import com.google.common.collect.Iterables; import com.google.common.collect.Iterables;
import com.google.common.collect.Lists; import com.google.common.collect.Lists;
import com.google.gerrit.common.Nullable; import com.google.gerrit.common.Nullable;
import com.google.gerrit.exceptions.StorageException;
import com.google.gerrit.extensions.api.changes.ActionVisitor; import com.google.gerrit.extensions.api.changes.ActionVisitor;
import com.google.gerrit.extensions.common.ActionInfo; import com.google.gerrit.extensions.common.ActionInfo;
import com.google.gerrit.extensions.common.ChangeInfo; import com.google.gerrit.extensions.common.ChangeInfo;
@@ -32,7 +33,6 @@ import com.google.gerrit.extensions.webui.UiAction;
import com.google.gerrit.server.CurrentUser; import com.google.gerrit.server.CurrentUser;
import com.google.gerrit.server.extensions.webui.UiActions; import com.google.gerrit.server.extensions.webui.UiActions;
import com.google.gerrit.server.notedb.ChangeNotes; import com.google.gerrit.server.notedb.ChangeNotes;
import com.google.gwtorm.server.OrmException;
import com.google.inject.Inject; import com.google.inject.Inject;
import com.google.inject.Provider; import com.google.inject.Provider;
import com.google.inject.Singleton; import com.google.inject.Singleton;
@@ -70,7 +70,7 @@ public class ActionJson {
this.userProvider = userProvider; this.userProvider = userProvider;
} }
public Map<String, ActionInfo> format(RevisionResource rsrc) throws OrmException { public Map<String, ActionInfo> format(RevisionResource rsrc) throws StorageException {
ChangeInfo changeInfo = null; ChangeInfo changeInfo = null;
RevisionInfo revisionInfo = null; RevisionInfo revisionInfo = null;
List<ActionVisitor> visitors = visitors(); List<ActionVisitor> visitors = visitors();
@@ -97,7 +97,8 @@ public class ActionJson {
} }
public RevisionInfo addRevisionActions( public RevisionInfo addRevisionActions(
@Nullable ChangeInfo changeInfo, RevisionInfo to, RevisionResource rsrc) throws OrmException { @Nullable ChangeInfo changeInfo, RevisionInfo to, RevisionResource rsrc)
throws StorageException {
List<ActionVisitor> visitors = visitors(); List<ActionVisitor> visitors = visitors();
if (!visitors.isEmpty()) { if (!visitors.isEmpty()) {
if (changeInfo != null) { if (changeInfo != null) {

View File

@@ -27,6 +27,7 @@ import com.google.common.collect.ImmutableList;
import com.google.common.collect.ImmutableSet; import com.google.common.collect.ImmutableSet;
import com.google.common.collect.Lists; import com.google.common.collect.Lists;
import com.google.common.collect.Streams; import com.google.common.collect.Streams;
import com.google.gerrit.exceptions.StorageException;
import com.google.gerrit.extensions.client.ReviewerState; import com.google.gerrit.extensions.client.ReviewerState;
import com.google.gerrit.extensions.restapi.RestApiException; import com.google.gerrit.extensions.restapi.RestApiException;
import com.google.gerrit.mail.Address; import com.google.gerrit.mail.Address;
@@ -44,7 +45,6 @@ import com.google.gerrit.server.project.ProjectCache;
import com.google.gerrit.server.update.BatchUpdateOp; import com.google.gerrit.server.update.BatchUpdateOp;
import com.google.gerrit.server.update.ChangeContext; import com.google.gerrit.server.update.ChangeContext;
import com.google.gerrit.server.update.Context; import com.google.gerrit.server.update.Context;
import com.google.gwtorm.server.OrmException;
import com.google.inject.Inject; import com.google.inject.Inject;
import com.google.inject.assistedinject.Assisted; import com.google.inject.assistedinject.Assisted;
import java.io.IOException; import java.io.IOException;
@@ -158,7 +158,7 @@ public class AddReviewersOp implements BatchUpdateOp {
@Override @Override
public boolean updateChange(ChangeContext ctx) public boolean updateChange(ChangeContext ctx)
throws RestApiException, OrmException, IOException { throws RestApiException, StorageException, IOException {
change = ctx.getChange(); change = ctx.getChange();
if (!accountIds.isEmpty()) { if (!accountIds.isEmpty()) {
if (state == CC) { if (state == CC) {

View File

@@ -20,6 +20,7 @@ import com.google.common.collect.ImmutableList;
import com.google.common.collect.ImmutableSet; import com.google.common.collect.ImmutableSet;
import com.google.common.collect.Sets; import com.google.common.collect.Sets;
import com.google.common.primitives.Ints; 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.DeprecatedIdentifierException;
import com.google.gerrit.extensions.restapi.Url; import com.google.gerrit.extensions.restapi.Url;
import com.google.gerrit.index.IndexConfig; 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.project.NoSuchChangeException;
import com.google.gerrit.server.query.change.ChangeData; import com.google.gerrit.server.query.change.ChangeData;
import com.google.gerrit.server.query.change.InternalChangeQuery; import com.google.gerrit.server.query.change.InternalChangeQuery;
import com.google.gwtorm.server.OrmException;
import com.google.inject.Inject; import com.google.inject.Inject;
import com.google.inject.Module; import com.google.inject.Module;
import com.google.inject.Provider; import com.google.inject.Provider;
@@ -106,7 +106,7 @@ public class ChangeFinder {
this.allowedIdTypes = ImmutableSet.copyOf(configuredChangeIdTypes); this.allowedIdTypes = ImmutableSet.copyOf(configuredChangeIdTypes);
} }
public ChangeNotes findOne(String id) throws OrmException { public ChangeNotes findOne(String id) throws StorageException {
List<ChangeNotes> ctls = find(id); List<ChangeNotes> ctls = find(id);
if (ctls.size() != 1) { if (ctls.size() != 1) {
return null; return null;
@@ -119,14 +119,14 @@ public class ChangeFinder {
* *
* @param id change identifier. * @param id change identifier.
* @return possibly-empty list of notes for all matching changes; may or may not be visible. * @return possibly-empty list of notes for all matching changes; may or may not be visible.
* @throws OrmException if an error occurred querying the database. * @throws StorageException if an error occurred querying the database.
*/ */
public List<ChangeNotes> find(String id) throws OrmException { public List<ChangeNotes> find(String id) throws StorageException {
try { try {
return find(id, false); return find(id, false);
} catch (DeprecatedIdentifierException e) { } catch (DeprecatedIdentifierException e) {
// This can't happen because we don't enforce deprecation // 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 * @param enforceDeprecation boolean to see if we should throw {@link
* DeprecatedIdentifierException} in case the identifier is deprecated * DeprecatedIdentifierException} in case the identifier is deprecated
* @return possibly-empty list of notes for all matching changes; may or may not be visible. * @return possibly-empty list of notes for all matching changes; may or may not be visible.
* @throws OrmException if an error occurred querying the database * @throws StorageException if an error occurred querying the database
* @throws DeprecatedIdentifierException if the identifier is deprecated. * @throws DeprecatedIdentifierException if the identifier is deprecated.
*/ */
public List<ChangeNotes> find(String id, boolean enforceDeprecation) public List<ChangeNotes> find(String id, boolean enforceDeprecation)
throws OrmException, DeprecatedIdentifierException { throws StorageException, DeprecatedIdentifierException {
if (id.isEmpty()) { if (id.isEmpty()) {
return Collections.emptyList(); return Collections.emptyList();
} }
@@ -195,16 +195,16 @@ public class ChangeFinder {
} }
private List<ChangeNotes> fromProjectNumber(String project, int changeNumber) private List<ChangeNotes> fromProjectNumber(String project, int changeNumber)
throws OrmException { throws StorageException {
Change.Id cId = new Change.Id(changeNumber); Change.Id cId = new Change.Id(changeNumber);
try { try {
return ImmutableList.of( return ImmutableList.of(
changeNotesFactory.createChecked(Project.NameKey.parse(project), cId)); changeNotesFactory.createChecked(Project.NameKey.parse(project), cId));
} catch (NoSuchChangeException e) { } catch (NoSuchChangeException e) {
return Collections.emptyList(); return Collections.emptyList();
} catch (OrmException e) { } catch (StorageException e) {
// Distinguish between a RepositoryNotFoundException (project argument invalid) and // 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) { if (Throwables.getRootCause(e) instanceof RepositoryNotFoundException) {
return Collections.emptyList(); 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<ChangeNotes> notes = find(id); List<ChangeNotes> notes = find(id);
if (notes.size() != 1) { if (notes.size() != 1) {
throw new NoSuchChangeException(id); throw new NoSuchChangeException(id);
@@ -220,7 +220,7 @@ public class ChangeFinder {
return notes.get(0); return notes.get(0);
} }
public List<ChangeNotes> find(Change.Id id) throws OrmException { public List<ChangeNotes> find(Change.Id id) throws StorageException {
String project = changeIdProjectCache.getIfPresent(id); String project = changeIdProjectCache.getIfPresent(id);
if (project != null) { if (project != null) {
return fromProjectNumber(project, id.get()); return fromProjectNumber(project, id.get());
@@ -236,7 +236,7 @@ public class ChangeFinder {
return asChangeNotes(r); return asChangeNotes(r);
} }
private List<ChangeNotes> asChangeNotes(List<ChangeData> cds) throws OrmException { private List<ChangeNotes> asChangeNotes(List<ChangeData> cds) throws StorageException {
List<ChangeNotes> notes = new ArrayList<>(cds.size()); List<ChangeNotes> notes = new ArrayList<>(cds.size());
if (!indexConfig.separateChangeSubIndexes()) { if (!indexConfig.separateChangeSubIndexes()) {
for (ChangeData cd : cds) { for (ChangeData cd : cds) {

View File

@@ -30,6 +30,7 @@ import com.google.common.flogger.FluentLogger;
import com.google.gerrit.common.FooterConstants; import com.google.gerrit.common.FooterConstants;
import com.google.gerrit.common.data.LabelType; import com.google.gerrit.common.data.LabelType;
import com.google.gerrit.common.data.LabelTypes; import com.google.gerrit.common.data.LabelTypes;
import com.google.gerrit.exceptions.StorageException;
import com.google.gerrit.extensions.api.changes.NotifyHandling; import com.google.gerrit.extensions.api.changes.NotifyHandling;
import com.google.gerrit.extensions.client.ReviewerState; import com.google.gerrit.extensions.client.ReviewerState;
import com.google.gerrit.extensions.restapi.ResourceConflictException; import com.google.gerrit.extensions.restapi.ResourceConflictException;
@@ -68,7 +69,6 @@ import com.google.gerrit.server.update.Context;
import com.google.gerrit.server.update.InsertChangeOp; import com.google.gerrit.server.update.InsertChangeOp;
import com.google.gerrit.server.update.RepoContext; import com.google.gerrit.server.update.RepoContext;
import com.google.gerrit.server.util.RequestScopePropagator; import com.google.gerrit.server.util.RequestScopePropagator;
import com.google.gwtorm.server.OrmException;
import com.google.inject.Inject; import com.google.inject.Inject;
import com.google.inject.assistedinject.Assisted; import com.google.inject.assistedinject.Assisted;
import java.io.IOException; import java.io.IOException;
@@ -369,7 +369,7 @@ public class ChangeInserter implements InsertChangeOp {
@Override @Override
public boolean updateChange(ChangeContext ctx) public boolean updateChange(ChangeContext ctx)
throws RestApiException, OrmException, IOException, PermissionBackendException, throws RestApiException, StorageException, IOException, PermissionBackendException,
ConfigInvalidException { ConfigInvalidException {
change = ctx.getChange(); // Use defensive copy created by ChangeControl. change = ctx.getChange(); // Use defensive copy created by ChangeControl.
patchSetInfo = patchSetInfo =

View File

@@ -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.SubmitRecord.Status;
import com.google.gerrit.common.data.SubmitRequirement; import com.google.gerrit.common.data.SubmitRequirement;
import com.google.gerrit.common.data.SubmitTypeRecord; 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.api.changes.FixInput;
import com.google.gerrit.extensions.client.ListChangesOption; import com.google.gerrit.extensions.client.ListChangesOption;
import com.google.gerrit.extensions.client.ReviewerState; 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.project.SubmitRuleOptions;
import com.google.gerrit.server.query.change.ChangeData; import com.google.gerrit.server.query.change.ChangeData;
import com.google.gerrit.server.query.change.ChangeData.ChangedLines; import com.google.gerrit.server.query.change.ChangeData.ChangedLines;
import com.google.gwtorm.server.OrmException;
import com.google.inject.Inject; import com.google.inject.Inject;
import com.google.inject.Provider; import com.google.inject.Provider;
import com.google.inject.Singleton; import com.google.inject.Singleton;
@@ -268,23 +268,23 @@ public class ChangeJson {
return this; return this;
} }
public ChangeInfo format(ChangeResource rsrc) throws OrmException { public ChangeInfo format(ChangeResource rsrc) throws StorageException {
return format(changeDataFactory.create(rsrc.getNotes())); 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)); 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); 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); 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()); ChangeData cd = changeDataFactory.create(rsrc.getNotes());
return format(cd, Optional.of(rsrc.getPatchSet().getId()), true, ChangeInfo::new); return format(cd, Optional.of(rsrc.getPatchSet().getId()), true, ChangeInfo::new);
} }
@@ -309,7 +309,7 @@ public class ChangeJson {
} }
public List<ChangeInfo> format(Collection<ChangeData> in) public List<ChangeInfo> format(Collection<ChangeData> in)
throws OrmException, PermissionBackendException { throws StorageException, PermissionBackendException {
accountLoader = accountLoaderFactory.create(has(DETAILED_ACCOUNTS)); accountLoader = accountLoaderFactory.create(has(DETAILED_ACCOUNTS));
ensureLoaded(in); ensureLoaded(in);
List<ChangeInfo> out = new ArrayList<>(in.size()); List<ChangeInfo> out = new ArrayList<>(in.size());
@@ -321,11 +321,12 @@ public class ChangeJson {
} }
public <I extends ChangeInfo> I format( public <I extends ChangeInfo> I format(
Project.NameKey project, Change.Id id, Supplier<I> changeInfoSupplier) throws OrmException { Project.NameKey project, Change.Id id, Supplier<I> changeInfoSupplier)
throws StorageException {
ChangeNotes notes; ChangeNotes notes;
try { try {
notes = notesFactory.createChecked(project, id); notes = notesFactory.createChecked(project, id);
} catch (OrmException e) { } catch (StorageException e) {
if (!has(CHECK)) { if (!has(CHECK)) {
throw e; throw e;
} }
@@ -367,7 +368,7 @@ public class ChangeJson {
Optional<PatchSet.Id> limitToPsId, Optional<PatchSet.Id> limitToPsId,
boolean fillAccountLoader, boolean fillAccountLoader,
Supplier<I> changeInfoSupplier) Supplier<I> changeInfoSupplier)
throws OrmException { throws StorageException {
try { try {
if (fillAccountLoader) { if (fillAccountLoader) {
accountLoader = accountLoaderFactory.create(has(DETAILED_ACCOUNTS)); accountLoader = accountLoaderFactory.create(has(DETAILED_ACCOUNTS));
@@ -378,19 +379,19 @@ public class ChangeJson {
return toChangeInfo(cd, limitToPsId, changeInfoSupplier); return toChangeInfo(cd, limitToPsId, changeInfoSupplier);
} catch (PatchListNotAvailableException } catch (PatchListNotAvailableException
| GpgException | GpgException
| OrmException | StorageException
| IOException | IOException
| PermissionBackendException | PermissionBackendException
| RuntimeException e) { | RuntimeException e) {
if (!has(CHECK)) { if (!has(CHECK)) {
Throwables.throwIfInstanceOf(e, OrmException.class); Throwables.throwIfInstanceOf(e, StorageException.class);
throw new OrmException(e); throw new StorageException(e);
} }
return checkOnly(cd, changeInfoSupplier); return checkOnly(cd, changeInfoSupplier);
} }
} }
private void ensureLoaded(Iterable<ChangeData> all) throws OrmException { private void ensureLoaded(Iterable<ChangeData> all) throws StorageException {
if (lazyLoad) { if (lazyLoad) {
ChangeData.ensureChangeLoaded(all); ChangeData.ensureChangeLoaded(all);
if (has(ALL_REVISIONS)) { if (has(ALL_REVISIONS)) {
@@ -425,7 +426,7 @@ public class ChangeJson {
try { try {
ensureLoaded(Collections.singleton(cd)); ensureLoaded(Collections.singleton(cd));
changeInfos.add(format(cd, Optional.empty(), false, ChangeInfo::new)); changeInfos.add(format(cd, Optional.empty(), false, ChangeInfo::new));
} catch (OrmException | RuntimeException e) { } catch (StorageException | RuntimeException e) {
logger.atWarning().withCause(e).log( logger.atWarning().withCause(e).log(
"Omitting corrupt change %s from results", cd.getId()); "Omitting corrupt change %s from results", cd.getId());
} }
@@ -438,7 +439,7 @@ public class ChangeJson {
ChangeNotes notes; ChangeNotes notes;
try { try {
notes = cd.notes(); notes = cd.notes();
} catch (OrmException e) { } catch (StorageException e) {
String msg = "Error loading change"; String msg = "Error loading change";
logger.atWarning().withCause(e).log(msg + " %s", cd.getId()); logger.atWarning().withCause(e).log(msg + " %s", cd.getId());
I info = changeInfoSupplier.get(); I info = changeInfoSupplier.get();
@@ -477,8 +478,8 @@ public class ChangeJson {
private <I extends ChangeInfo> I toChangeInfo( private <I extends ChangeInfo> I toChangeInfo(
ChangeData cd, Optional<PatchSet.Id> limitToPsId, Supplier<I> changeInfoSupplier) ChangeData cd, Optional<PatchSet.Id> limitToPsId, Supplier<I> changeInfoSupplier)
throws PatchListNotAvailableException, GpgException, OrmException, PermissionBackendException, throws PatchListNotAvailableException, GpgException, StorageException,
IOException { PermissionBackendException, IOException {
try (Timer0.Context ignored = metrics.toChangeInfoLatency.start()) { try (Timer0.Context ignored = metrics.toChangeInfoLatency.start()) {
return toChangeInfoImpl(cd, limitToPsId, changeInfoSupplier); return toChangeInfoImpl(cd, limitToPsId, changeInfoSupplier);
} }
@@ -486,8 +487,8 @@ public class ChangeJson {
private <I extends ChangeInfo> I toChangeInfoImpl( private <I extends ChangeInfo> I toChangeInfoImpl(
ChangeData cd, Optional<PatchSet.Id> limitToPsId, Supplier<I> changeInfoSupplier) ChangeData cd, Optional<PatchSet.Id> limitToPsId, Supplier<I> changeInfoSupplier)
throws PatchListNotAvailableException, GpgException, OrmException, PermissionBackendException, throws PatchListNotAvailableException, GpgException, StorageException,
IOException { PermissionBackendException, IOException {
I out = changeInfoSupplier.get(); I out = changeInfoSupplier.get();
CurrentUser user = userProvider.get(); CurrentUser user = userProvider.get();
@@ -638,7 +639,7 @@ public class ChangeJson {
return reviewerMap; return reviewerMap;
} }
private Collection<ReviewerUpdateInfo> reviewerUpdates(ChangeData cd) throws OrmException { private Collection<ReviewerUpdateInfo> reviewerUpdates(ChangeData cd) throws StorageException {
List<ReviewerStatusUpdate> reviewerUpdates = cd.reviewerUpdates(); List<ReviewerStatusUpdate> reviewerUpdates = cd.reviewerUpdates();
List<ReviewerUpdateInfo> result = new ArrayList<>(reviewerUpdates.size()); List<ReviewerUpdateInfo> result = new ArrayList<>(reviewerUpdates.size());
for (ReviewerStatusUpdate c : reviewerUpdates) { for (ReviewerStatusUpdate c : reviewerUpdates) {
@@ -656,7 +657,7 @@ public class ChangeJson {
return SubmitRecord.allRecordsOK(cd.submitRecords(SUBMIT_RULE_OPTIONS_STRICT)); return SubmitRecord.allRecordsOK(cd.submitRecords(SUBMIT_RULE_OPTIONS_STRICT));
} }
private void setSubmitter(ChangeData cd, ChangeInfo out) throws OrmException { private void setSubmitter(ChangeData cd, ChangeInfo out) throws StorageException {
Optional<PatchSetApproval> s = cd.getSubmitApproval(); Optional<PatchSetApproval> s = cd.getSubmitApproval();
if (!s.isPresent()) { if (!s.isPresent()) {
return; return;
@@ -665,7 +666,7 @@ public class ChangeJson {
out.submitter = accountLoader.get(s.get().getAccountId()); out.submitter = accountLoader.get(s.get().getAccountId());
} }
private Collection<ChangeMessageInfo> messages(ChangeData cd) throws OrmException { private Collection<ChangeMessageInfo> messages(ChangeData cd) throws StorageException {
List<ChangeMessage> messages = cmUtil.byChange(cd.notes()); List<ChangeMessage> messages = cmUtil.byChange(cd.notes());
if (messages.isEmpty()) { if (messages.isEmpty()) {
return Collections.emptyList(); return Collections.emptyList();
@@ -679,7 +680,7 @@ public class ChangeJson {
} }
private Collection<AccountInfo> removableReviewers(ChangeData cd, ChangeInfo out) private Collection<AccountInfo> removableReviewers(ChangeData cd, ChangeInfo out)
throws PermissionBackendException, OrmException { throws PermissionBackendException, StorageException {
// Although this is called removableReviewers, this method also determines // Although this is called removableReviewers, this method also determines
// which CCs are removable. // which CCs are removable.
// //
@@ -768,7 +769,7 @@ public class ChangeJson {
} }
private Map<PatchSet.Id, PatchSet> loadPatchSets(ChangeData cd, Optional<PatchSet.Id> limitToPsId) private Map<PatchSet.Id, PatchSet> loadPatchSets(ChangeData cd, Optional<PatchSet.Id> limitToPsId)
throws OrmException { throws StorageException {
Collection<PatchSet> src; Collection<PatchSet> src;
if (has(ALL_REVISIONS) || has(MESSAGES)) { if (has(ALL_REVISIONS) || has(MESSAGES)) {
src = cd.patchSets(); src = cd.patchSets();
@@ -777,12 +778,12 @@ public class ChangeJson {
if (limitToPsId.isPresent()) { if (limitToPsId.isPresent()) {
ps = cd.patchSet(limitToPsId.get()); ps = cd.patchSet(limitToPsId.get());
if (ps == null) { if (ps == null) {
throw new OrmException("missing patch set " + limitToPsId.get()); throw new StorageException("missing patch set " + limitToPsId.get());
} }
} else { } else {
ps = cd.currentPatchSet(); ps = cd.currentPatchSet();
if (ps == null) { 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); src = Collections.singletonList(ps);
@@ -800,7 +801,7 @@ public class ChangeJson {
* lazyload}. * lazyload}.
*/ */
private PermissionBackend.ForChange permissionBackendForChange(CurrentUser user, ChangeData cd) private PermissionBackend.ForChange permissionBackendForChange(CurrentUser user, ChangeData cd)
throws OrmException { throws StorageException {
PermissionBackend.WithUser withUser = permissionBackend.user(user); PermissionBackend.WithUser withUser = permissionBackend.user(user);
return lazyLoad return lazyLoad
? withUser.change(cd) ? withUser.change(cd)

View File

@@ -23,6 +23,7 @@ import com.google.common.cache.Weigher;
import com.google.common.collect.FluentIterable; import com.google.common.collect.FluentIterable;
import com.google.common.flogger.FluentLogger; import com.google.common.flogger.FluentLogger;
import com.google.gerrit.common.Nullable; import com.google.gerrit.common.Nullable;
import com.google.gerrit.exceptions.StorageException;
import com.google.gerrit.extensions.client.ChangeKind; import com.google.gerrit.extensions.client.ChangeKind;
import com.google.gerrit.proto.Protos; import com.google.gerrit.proto.Protos;
import com.google.gerrit.reviewdb.client.Change; 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.InMemoryInserter;
import com.google.gerrit.server.git.MergeUtil; import com.google.gerrit.server.git.MergeUtil;
import com.google.gerrit.server.query.change.ChangeData; import com.google.gerrit.server.query.change.ChangeData;
import com.google.gwtorm.server.OrmException;
import com.google.inject.Inject; import com.google.inject.Inject;
import com.google.inject.Module; import com.google.inject.Module;
import com.google.inject.name.Named; import com.google.inject.name.Named;
@@ -392,7 +392,7 @@ public class ChangeKindCacheImpl implements ChangeKindCache {
ObjectId.fromString(priorPs.getRevision().get()), ObjectId.fromString(priorPs.getRevision().get()),
ObjectId.fromString(patch.getRevision().get())); ObjectId.fromString(patch.getRevision().get()));
} }
} catch (OrmException e) { } catch (StorageException e) {
// Do nothing; assume we have a complex change // Do nothing; assume we have a complex change
logger.atWarning().withCause(e).log( logger.atWarning().withCause(e).log(
"Unable to get change kind for patchSet %s of change %s", "Unable to get change kind for patchSet %s of change %s",

View File

@@ -21,6 +21,7 @@ import com.google.common.collect.ImmutableList;
import com.google.common.flogger.FluentLogger; import com.google.common.flogger.FluentLogger;
import com.google.common.hash.Hasher; import com.google.common.hash.Hasher;
import com.google.common.hash.Hashing; 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;
import com.google.gerrit.extensions.restapi.RestResource.HasETag; import com.google.gerrit.extensions.restapi.RestResource.HasETag;
import com.google.gerrit.extensions.restapi.RestView; 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.permissions.PermissionBackend;
import com.google.gerrit.server.project.ProjectCache; import com.google.gerrit.server.project.ProjectCache;
import com.google.gerrit.server.project.ProjectState; import com.google.gerrit.server.project.ProjectState;
import com.google.gwtorm.server.OrmException;
import com.google.inject.Inject; import com.google.inject.Inject;
import com.google.inject.TypeLiteral; import com.google.inject.TypeLiteral;
import com.google.inject.assistedinject.Assisted; 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 // 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. // be sure that we have all accounts that posted messages on the change.
accounts.addAll(approvalUtil.getReviewers(notes).all()); accounts.addAll(approvalUtil.getReviewers(notes).all());
} catch (OrmException e) { } catch (StorageException e) {
// This ETag will be invalidated if it loads next time. // This ETag will be invalidated if it loads next time.
} }
@@ -175,7 +175,7 @@ public class ChangeResource implements RestResource, HasETag {
ObjectId noteId; ObjectId noteId;
try { try {
noteId = notes.loadRevision(); noteId = notes.loadRevision();
} catch (OrmException e) { } catch (StorageException e) {
noteId = null; // This ETag will be invalidated if it loads next time. noteId = null; // This ETag will be invalidated if it loads next time.
} }
hashObjectId(h, noteId, buf); hashObjectId(h, noteId, buf);

View File

@@ -30,6 +30,7 @@ import com.google.common.collect.SetMultimap;
import com.google.common.flogger.FluentLogger; import com.google.common.flogger.FluentLogger;
import com.google.gerrit.common.FooterConstants; import com.google.gerrit.common.FooterConstants;
import com.google.gerrit.common.Nullable; import com.google.gerrit.common.Nullable;
import com.google.gerrit.exceptions.StorageException;
import com.google.gerrit.extensions.api.changes.FixInput; import com.google.gerrit.extensions.api.changes.FixInput;
import com.google.gerrit.extensions.common.ProblemInfo; import com.google.gerrit.extensions.common.ProblemInfo;
import com.google.gerrit.extensions.common.ProblemInfo.Status; 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.RetryHelper;
import com.google.gerrit.server.update.UpdateException; import com.google.gerrit.server.update.UpdateException;
import com.google.gerrit.server.util.time.TimeUtil; import com.google.gerrit.server.util.time.TimeUtil;
import com.google.gwtorm.server.OrmException;
import com.google.inject.Inject; import com.google.inject.Inject;
import com.google.inject.Provider; import com.google.inject.Provider;
import java.io.IOException; import java.io.IOException;
@@ -232,7 +232,7 @@ public class ConsistencyChecker {
problem( problem(
String.format("Current patch set %d not found", change().currentPatchSetId().get())); 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); error("Failed to look up current patch set", e);
} }
} }
@@ -256,7 +256,7 @@ public class ConsistencyChecker {
try { try {
// Iterate in descending order. // Iterate in descending order.
all = PS_ID_ORDER.sortedCopy(psUtil.byChange(notes)); all = PS_ID_ORDER.sortedCopy(psUtil.byChange(notes));
} catch (OrmException e) { } catch (StorageException e) {
return error("Failed to look up patch sets", e); return error("Failed to look up patch sets", e);
} }
patchSetsBySha = MultimapBuilder.hashKeys(all.size()).treeSetValues(PS_ID_ORDER).build(); patchSetsBySha = MultimapBuilder.hashKeys(all.size()).treeSetValues(PS_ID_ORDER).build();
@@ -425,7 +425,7 @@ public class ConsistencyChecker {
if (!c.getDest().equals(change().getDest())) { if (!c.getDest().equals(change().getDest())) {
continue; continue;
} }
} catch (OrmException e) { } catch (StorageException e) {
warn(e); warn(e);
// Include this patch set; should cause an error below, which is good. // Include this patch set; should cause an error below, which is good.
} }
@@ -556,7 +556,7 @@ public class ConsistencyChecker {
notes = notesFactory.createChecked(inserter.getChange()); notes = notesFactory.createChecked(inserter.getChange());
insertPatchSetProblem.status = Status.FIXED; insertPatchSetProblem.status = Status.FIXED;
insertPatchSetProblem.outcome = "Inserted as patch set " + psId.get(); insertPatchSetProblem.outcome = "Inserted as patch set " + psId.get();
} catch (OrmException | IOException | UpdateException | RestApiException e) { } catch (StorageException | IOException | UpdateException | RestApiException e) {
warn(e); warn(e);
for (ProblemInfo pi : currProblems) { for (ProblemInfo pi : currProblems) {
pi.status = Status.FIX_FAILED; pi.status = Status.FIX_FAILED;
@@ -574,7 +574,7 @@ public class ConsistencyChecker {
} }
@Override @Override
public boolean updateChange(ChangeContext ctx) throws OrmException { public boolean updateChange(ChangeContext ctx) throws StorageException {
ctx.getChange().setStatus(Change.Status.MERGED); ctx.getChange().setStatus(Change.Status.MERGED);
ctx.getUpdate(ctx.getChange().currentPatchSetId()).fixStatus(Change.Status.MERGED); ctx.getUpdate(ctx.getChange().currentPatchSetId()).fixStatus(Change.Status.MERGED);
p.status = Status.FIXED; p.status = Status.FIXED;
@@ -673,9 +673,9 @@ public class ConsistencyChecker {
@Override @Override
public boolean updateChange(ChangeContext ctx) public boolean updateChange(ChangeContext ctx)
throws OrmException, PatchSetInfoNotAvailableException { throws StorageException, PatchSetInfoNotAvailableException {
// Delete dangling key references. // 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. // For NoteDb setting the state to deleted is sufficient to filter everything out.
ctx.getUpdate(psId).setPatchSetState(PatchSetState.DELETED); ctx.getUpdate(psId).setPatchSetState(PatchSetState.DELETED);
@@ -706,7 +706,8 @@ public class ConsistencyChecker {
@Override @Override
public boolean updateChange(ChangeContext ctx) public boolean updateChange(ChangeContext ctx)
throws OrmException, PatchSetInfoNotAvailableException, NoPatchSetsWouldRemainException { throws StorageException, PatchSetInfoNotAvailableException,
NoPatchSetsWouldRemainException {
if (!toDelete.contains(ctx.getChange().currentPatchSetId())) { if (!toDelete.contains(ctx.getChange().currentPatchSetId())) {
return false; return false;
} }

View File

@@ -14,6 +14,7 @@
package com.google.gerrit.server.change; 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.MethodNotAllowedException;
import com.google.gerrit.extensions.restapi.ResourceConflictException; import com.google.gerrit.extensions.restapi.ResourceConflictException;
import com.google.gerrit.extensions.restapi.RestApiException; import com.google.gerrit.extensions.restapi.RestApiException;
@@ -27,7 +28,6 @@ import com.google.gerrit.server.project.NoSuchChangeException;
import com.google.gerrit.server.update.BatchUpdateOp; import com.google.gerrit.server.update.BatchUpdateOp;
import com.google.gerrit.server.update.ChangeContext; import com.google.gerrit.server.update.ChangeContext;
import com.google.gerrit.server.update.RepoContext; import com.google.gerrit.server.update.RepoContext;
import com.google.gwtorm.server.OrmException;
import com.google.inject.Inject; import com.google.inject.Inject;
import com.google.inject.assistedinject.Assisted; import com.google.inject.assistedinject.Assisted;
import java.io.IOException; 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. // fail gracefully if the second delete fails, but fortunately that's not what happens.
@Override @Override
public boolean updateChange(ChangeContext ctx) public boolean updateChange(ChangeContext ctx)
throws RestApiException, OrmException, IOException { throws RestApiException, StorageException, IOException {
Collection<PatchSet> patchSets = psUtil.byChange(ctx.getNotes()); Collection<PatchSet> patchSets = psUtil.byChange(ctx.getNotes());
ensureDeletable(ctx, id, patchSets); ensureDeletable(ctx, id, patchSets);
@@ -107,9 +107,9 @@ public class DeleteChangeOp implements BatchUpdateOp {
} }
private void cleanUpReferences(ChangeContext ctx, Change.Id id, Collection<PatchSet> patchSets) private void cleanUpReferences(ChangeContext ctx, Change.Id id, Collection<PatchSet> patchSets)
throws OrmException, NoSuchChangeException { throws StorageException, NoSuchChangeException {
for (PatchSet ps : patchSets) { 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 // Non-atomic operation on Accounts table; not much we can do to make it

View File

@@ -15,6 +15,7 @@
package com.google.gerrit.server.change; package com.google.gerrit.server.change;
import com.google.common.flogger.FluentLogger; import com.google.common.flogger.FluentLogger;
import com.google.gerrit.exceptions.StorageException;
import com.google.gerrit.mail.Address; import com.google.gerrit.mail.Address;
import com.google.gerrit.reviewdb.client.Change; import com.google.gerrit.reviewdb.client.Change;
import com.google.gerrit.reviewdb.client.ChangeMessage; import com.google.gerrit.reviewdb.client.ChangeMessage;
@@ -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.BatchUpdateOp;
import com.google.gerrit.server.update.ChangeContext; import com.google.gerrit.server.update.ChangeContext;
import com.google.gerrit.server.update.Context; import com.google.gerrit.server.update.Context;
import com.google.gwtorm.server.OrmException;
import com.google.inject.Inject; import com.google.inject.Inject;
import com.google.inject.assistedinject.Assisted; import com.google.inject.assistedinject.Assisted;
import java.util.Collections; import java.util.Collections;
@@ -50,7 +50,7 @@ public class DeleteReviewerByEmailOp implements BatchUpdateOp {
} }
@Override @Override
public boolean updateChange(ChangeContext ctx) throws OrmException { public boolean updateChange(ChangeContext ctx) throws StorageException {
change = ctx.getChange(); change = ctx.getChange();
PatchSet.Id psId = ctx.getChange().currentPatchSetId(); PatchSet.Id psId = ctx.getChange().currentPatchSetId();
String msg = "Removed reviewer " + reviewer; String msg = "Removed reviewer " + reviewer;

View File

@@ -19,6 +19,7 @@ import com.google.common.flogger.FluentLogger;
import com.google.gerrit.common.data.LabelType; import com.google.gerrit.common.data.LabelType;
import com.google.gerrit.common.data.LabelTypes; import com.google.gerrit.common.data.LabelTypes;
import com.google.gerrit.exceptions.EmailException; import com.google.gerrit.exceptions.EmailException;
import com.google.gerrit.exceptions.StorageException;
import com.google.gerrit.extensions.api.changes.DeleteReviewerInput; import com.google.gerrit.extensions.api.changes.DeleteReviewerInput;
import com.google.gerrit.extensions.api.changes.NotifyHandling; import com.google.gerrit.extensions.api.changes.NotifyHandling;
import com.google.gerrit.extensions.restapi.AuthException; import com.google.gerrit.extensions.restapi.AuthException;
@@ -43,7 +44,6 @@ import com.google.gerrit.server.project.RemoveReviewerControl;
import com.google.gerrit.server.update.BatchUpdateOp; import com.google.gerrit.server.update.BatchUpdateOp;
import com.google.gerrit.server.update.ChangeContext; import com.google.gerrit.server.update.ChangeContext;
import com.google.gerrit.server.update.Context; import com.google.gerrit.server.update.Context;
import com.google.gwtorm.server.OrmException;
import com.google.inject.Inject; import com.google.inject.Inject;
import com.google.inject.Provider; import com.google.inject.Provider;
import com.google.inject.assistedinject.Assisted; import com.google.inject.assistedinject.Assisted;
@@ -108,7 +108,7 @@ public class DeleteReviewerOp implements BatchUpdateOp {
@Override @Override
public boolean updateChange(ChangeContext ctx) public boolean updateChange(ChangeContext ctx)
throws AuthException, ResourceNotFoundException, OrmException, PermissionBackendException, throws AuthException, ResourceNotFoundException, StorageException, PermissionBackendException,
IOException { IOException {
Account.Id reviewerId = reviewer.getAccount().getId(); Account.Id reviewerId = reviewer.getAccount().getId();
// Check of removing this reviewer (even if there is no vote processed by the loop below) is OK // Check of removing this reviewer (even if there is no vote processed by the loop below) is OK
@@ -195,7 +195,7 @@ public class DeleteReviewerOp implements BatchUpdateOp {
} }
private Iterable<PatchSetApproval> approvals(ChangeContext ctx, Account.Id accountId) private Iterable<PatchSetApproval> approvals(ChangeContext ctx, Account.Id accountId)
throws OrmException { throws StorageException {
Iterable<PatchSetApproval> approvals; Iterable<PatchSetApproval> approvals;
approvals = approvalsUtil.byChange(ctx.getNotes()).values(); approvals = approvalsUtil.byChange(ctx.getNotes()).values();
return Iterables.filter(approvals, psa -> accountId.equals(psa.getAccountId())); return Iterables.filter(approvals, psa -> accountId.equals(psa.getAccountId()));

View File

@@ -36,6 +36,7 @@ import com.google.gerrit.common.data.LabelType;
import com.google.gerrit.common.data.LabelTypes; import com.google.gerrit.common.data.LabelTypes;
import com.google.gerrit.common.data.LabelValue; import com.google.gerrit.common.data.LabelValue;
import com.google.gerrit.common.data.SubmitRecord; import com.google.gerrit.common.data.SubmitRecord;
import com.google.gerrit.exceptions.StorageException;
import com.google.gerrit.extensions.client.ListChangesOption; import com.google.gerrit.extensions.client.ListChangesOption;
import com.google.gerrit.extensions.common.ApprovalInfo; import com.google.gerrit.extensions.common.ApprovalInfo;
import com.google.gerrit.extensions.common.LabelInfo; import com.google.gerrit.extensions.common.LabelInfo;
@@ -51,7 +52,6 @@ import com.google.gerrit.server.permissions.LabelPermission;
import com.google.gerrit.server.permissions.PermissionBackend; import com.google.gerrit.server.permissions.PermissionBackend;
import com.google.gerrit.server.permissions.PermissionBackendException; import com.google.gerrit.server.permissions.PermissionBackendException;
import com.google.gerrit.server.query.change.ChangeData; import com.google.gerrit.server.query.change.ChangeData;
import com.google.gwtorm.server.OrmException;
import com.google.inject.Inject; import com.google.inject.Inject;
import com.google.inject.assistedinject.Assisted; import com.google.inject.assistedinject.Assisted;
import java.sql.Timestamp; import java.sql.Timestamp;
@@ -100,7 +100,7 @@ public class LabelsJson {
*/ */
Map<String, LabelInfo> labelsFor( Map<String, LabelInfo> labelsFor(
AccountLoader accountLoader, ChangeData cd, boolean standard, boolean detailed) AccountLoader accountLoader, ChangeData cd, boolean standard, boolean detailed)
throws OrmException, PermissionBackendException { throws StorageException, PermissionBackendException {
if (!standard && !detailed) { if (!standard && !detailed) {
return null; return null;
} }
@@ -115,7 +115,7 @@ public class LabelsJson {
/** Returns all labels that the provided user has permission to vote on. */ /** Returns all labels that the provided user has permission to vote on. */
Map<String, Collection<String>> permittedLabels(Account.Id filterApprovalsBy, ChangeData cd) Map<String, Collection<String>> permittedLabels(Account.Id filterApprovalsBy, ChangeData cd)
throws OrmException, PermissionBackendException { throws StorageException, PermissionBackendException {
boolean isMerged = cd.change().isMerged(); boolean isMerged = cd.change().isMerged();
LabelTypes labelTypes = cd.getLabelTypes(); LabelTypes labelTypes = cd.getLabelTypes();
Map<String, LabelType> toCheck = new HashMap<>(); Map<String, LabelType> toCheck = new HashMap<>();
@@ -194,7 +194,7 @@ public class LabelsJson {
LabelTypes labelTypes, LabelTypes labelTypes,
boolean standard, boolean standard,
boolean detailed) boolean detailed)
throws OrmException, PermissionBackendException { throws StorageException, PermissionBackendException {
Map<String, LabelWithStatus> labels = initLabels(accountLoader, cd, labelTypes, standard); Map<String, LabelWithStatus> labels = initLabels(accountLoader, cd, labelTypes, standard);
if (detailed) { if (detailed) {
setAllApprovals(accountLoader, cd, labels); setAllApprovals(accountLoader, cd, labels);
@@ -253,7 +253,7 @@ public class LabelsJson {
} }
private Map<String, Short> currentLabels(Account.Id accountId, ChangeData cd) private Map<String, Short> currentLabels(Account.Id accountId, ChangeData cd)
throws OrmException { throws StorageException {
Map<String, Short> result = new HashMap<>(); Map<String, Short> result = new HashMap<>();
for (PatchSetApproval psa : for (PatchSetApproval psa :
approvalsUtil.byPatchSetUser( approvalsUtil.byPatchSetUser(
@@ -273,7 +273,7 @@ public class LabelsJson {
LabelTypes labelTypes, LabelTypes labelTypes,
boolean standard, boolean standard,
boolean detailed) boolean detailed)
throws OrmException, PermissionBackendException { throws StorageException, PermissionBackendException {
Set<Account.Id> allUsers = new HashSet<>(); Set<Account.Id> allUsers = new HashSet<>();
if (detailed) { if (detailed) {
// Users expect to see all reviewers on closed changes, even if they // Users expect to see all reviewers on closed changes, even if they
@@ -431,7 +431,7 @@ public class LabelsJson {
private void setAllApprovals( private void setAllApprovals(
AccountLoader accountLoader, ChangeData cd, Map<String, LabelWithStatus> labels) AccountLoader accountLoader, ChangeData cd, Map<String, LabelWithStatus> labels)
throws OrmException, PermissionBackendException { throws StorageException, PermissionBackendException {
checkState( checkState(
!cd.change().isMerged(), !cd.change().isMerged(),
"should not call setAllApprovals on %s change", "should not call setAllApprovals on %s change",
@@ -500,7 +500,7 @@ public class LabelsJson {
* lazyload}. * lazyload}.
*/ */
private PermissionBackend.ForChange permissionBackendForChange(Account.Id user, ChangeData cd) private PermissionBackend.ForChange permissionBackendForChange(Account.Id user, ChangeData cd)
throws OrmException { throws StorageException {
PermissionBackend.WithUser withUser = permissionBackend.absentUser(user); PermissionBackend.WithUser withUser = permissionBackend.absentUser(user);
return lazyLoad return lazyLoad
? withUser.change(cd) ? withUser.change(cd)

View File

@@ -21,6 +21,7 @@ import com.google.auto.value.AutoValue;
import com.google.common.collect.ImmutableList; import com.google.common.collect.ImmutableList;
import com.google.common.collect.ImmutableSetMultimap; import com.google.common.collect.ImmutableSetMultimap;
import com.google.gerrit.common.Nullable; import com.google.gerrit.common.Nullable;
import com.google.gerrit.exceptions.StorageException;
import com.google.gerrit.extensions.api.changes.NotifyHandling; import com.google.gerrit.extensions.api.changes.NotifyHandling;
import com.google.gerrit.extensions.api.changes.NotifyInfo; import com.google.gerrit.extensions.api.changes.NotifyInfo;
import com.google.gerrit.extensions.api.changes.RecipientType; import com.google.gerrit.extensions.api.changes.RecipientType;
@@ -28,7 +29,6 @@ import com.google.gerrit.extensions.restapi.BadRequestException;
import com.google.gerrit.extensions.restapi.UnprocessableEntityException; import com.google.gerrit.extensions.restapi.UnprocessableEntityException;
import com.google.gerrit.reviewdb.client.Account; import com.google.gerrit.reviewdb.client.Account;
import com.google.gerrit.server.account.AccountResolver; import com.google.gerrit.server.account.AccountResolver;
import com.google.gwtorm.server.OrmException;
import com.google.inject.Inject; import com.google.inject.Inject;
import com.google.inject.Singleton; import com.google.inject.Singleton;
import java.io.IOException; import java.io.IOException;
@@ -81,7 +81,7 @@ public class NotifyResolver {
public Result resolve( public Result resolve(
NotifyHandling handling, @Nullable Map<RecipientType, NotifyInfo> notifyDetails) NotifyHandling handling, @Nullable Map<RecipientType, NotifyInfo> notifyDetails)
throws BadRequestException, OrmException, IOException, ConfigInvalidException { throws BadRequestException, StorageException, IOException, ConfigInvalidException {
requireNonNull(handling); requireNonNull(handling);
ImmutableSetMultimap.Builder<RecipientType, Account.Id> b = ImmutableSetMultimap.builder(); ImmutableSetMultimap.Builder<RecipientType, Account.Id> b = ImmutableSetMultimap.builder();
if (notifyDetails != null) { if (notifyDetails != null) {
@@ -93,7 +93,7 @@ public class NotifyResolver {
} }
private ImmutableList<Account.Id> find(@Nullable List<String> inputs) private ImmutableList<Account.Id> find(@Nullable List<String> inputs)
throws OrmException, BadRequestException, IOException, ConfigInvalidException { throws StorageException, BadRequestException, IOException, ConfigInvalidException {
if (inputs == null || inputs.isEmpty()) { if (inputs == null || inputs.isEmpty()) {
return ImmutableList.of(); return ImmutableList.of();
} }

View File

@@ -20,6 +20,7 @@ import static com.google.gerrit.server.notedb.ReviewerStateInternal.REVIEWER;
import static java.util.Objects.requireNonNull; import static java.util.Objects.requireNonNull;
import com.google.common.flogger.FluentLogger; import com.google.common.flogger.FluentLogger;
import com.google.gerrit.exceptions.StorageException;
import com.google.gerrit.extensions.api.changes.NotifyHandling; import com.google.gerrit.extensions.api.changes.NotifyHandling;
import com.google.gerrit.extensions.restapi.AuthException; import com.google.gerrit.extensions.restapi.AuthException;
import com.google.gerrit.extensions.restapi.ResourceConflictException; import com.google.gerrit.extensions.restapi.ResourceConflictException;
@@ -49,7 +50,6 @@ import com.google.gerrit.server.update.BatchUpdateOp;
import com.google.gerrit.server.update.ChangeContext; import com.google.gerrit.server.update.ChangeContext;
import com.google.gerrit.server.update.Context; import com.google.gerrit.server.update.Context;
import com.google.gerrit.server.update.RepoContext; import com.google.gerrit.server.update.RepoContext;
import com.google.gwtorm.server.OrmException;
import com.google.inject.Inject; import com.google.inject.Inject;
import com.google.inject.assistedinject.Assisted; import com.google.inject.assistedinject.Assisted;
import java.io.IOException; import java.io.IOException;
@@ -187,7 +187,7 @@ public class PatchSetInserter implements BatchUpdateOp {
@Override @Override
public void updateRepo(RepoContext ctx) public void updateRepo(RepoContext ctx)
throws AuthException, ResourceConflictException, IOException, OrmException, throws AuthException, ResourceConflictException, IOException, StorageException,
PermissionBackendException { PermissionBackendException {
validate(ctx); validate(ctx);
ctx.addRefUpdate(ObjectId.zeroId(), commitId, getPatchSetId().toRefName()); ctx.addRefUpdate(ObjectId.zeroId(), commitId, getPatchSetId().toRefName());
@@ -195,7 +195,7 @@ public class PatchSetInserter implements BatchUpdateOp {
@Override @Override
public boolean updateChange(ChangeContext ctx) public boolean updateChange(ChangeContext ctx)
throws ResourceConflictException, OrmException, IOException { throws ResourceConflictException, StorageException, IOException {
change = ctx.getChange(); change = ctx.getChange();
ChangeUpdate update = ctx.getUpdate(psId); ChangeUpdate update = ctx.getUpdate(psId);
update.setSubjectForCommit("Create patch set " + psId.get()); update.setSubjectForCommit("Create patch set " + psId.get());
@@ -272,7 +272,7 @@ public class PatchSetInserter implements BatchUpdateOp {
private void validate(RepoContext ctx) private void validate(RepoContext ctx)
throws AuthException, ResourceConflictException, IOException, PermissionBackendException, throws AuthException, ResourceConflictException, IOException, PermissionBackendException,
OrmException { StorageException {
// Not allowed to create a new patch set if the current patch set is locked. // Not allowed to create a new patch set if the current patch set is locked.
psUtil.checkPatchSetNotLocked(origNotes); psUtil.checkPatchSetNotLocked(origNotes);

View File

@@ -14,12 +14,12 @@
package com.google.gerrit.server.change; package com.google.gerrit.server.change;
import com.google.gerrit.exceptions.StorageException;
import com.google.gerrit.extensions.restapi.BadRequestException; import com.google.gerrit.extensions.restapi.BadRequestException;
import com.google.gerrit.extensions.restapi.ResourceConflictException; import com.google.gerrit.extensions.restapi.ResourceConflictException;
import com.google.gerrit.reviewdb.client.PatchSet; import com.google.gerrit.reviewdb.client.PatchSet;
import com.google.gerrit.server.git.PureRevertCache; import com.google.gerrit.server.git.PureRevertCache;
import com.google.gerrit.server.notedb.ChangeNotes; import com.google.gerrit.server.notedb.ChangeNotes;
import com.google.gwtorm.server.OrmException;
import com.google.inject.Inject; import com.google.inject.Inject;
import com.google.inject.Singleton; import com.google.inject.Singleton;
import java.io.IOException; import java.io.IOException;
@@ -38,7 +38,7 @@ public class PureRevert {
} }
public boolean get(ChangeNotes notes, Optional<String> claimedOriginal) public boolean get(ChangeNotes notes, Optional<String> claimedOriginal)
throws OrmException, IOException, BadRequestException, ResourceConflictException { throws StorageException, IOException, BadRequestException, ResourceConflictException {
PatchSet currentPatchSet = notes.getCurrentPatchSet(); PatchSet currentPatchSet = notes.getCurrentPatchSet();
if (currentPatchSet == null) { if (currentPatchSet == null) {
throw new ResourceConflictException("current revision is missing"); throw new ResourceConflictException("current revision is missing");

View File

@@ -16,6 +16,7 @@ package com.google.gerrit.server.change;
import static com.google.common.base.Preconditions.checkState; import static com.google.common.base.Preconditions.checkState;
import com.google.gerrit.exceptions.StorageException;
import com.google.gerrit.extensions.restapi.MergeConflictException; import com.google.gerrit.extensions.restapi.MergeConflictException;
import com.google.gerrit.extensions.restapi.ResourceConflictException; import com.google.gerrit.extensions.restapi.ResourceConflictException;
import com.google.gerrit.extensions.restapi.RestApiException; import com.google.gerrit.extensions.restapi.RestApiException;
@@ -37,7 +38,6 @@ import com.google.gerrit.server.update.BatchUpdateOp;
import com.google.gerrit.server.update.ChangeContext; import com.google.gerrit.server.update.ChangeContext;
import com.google.gerrit.server.update.Context; import com.google.gerrit.server.update.Context;
import com.google.gerrit.server.update.RepoContext; import com.google.gerrit.server.update.RepoContext;
import com.google.gwtorm.server.OrmException;
import com.google.inject.Inject; import com.google.inject.Inject;
import com.google.inject.assistedinject.Assisted; import com.google.inject.assistedinject.Assisted;
import java.io.IOException; import java.io.IOException;
@@ -149,7 +149,7 @@ public class RebaseChangeOp implements BatchUpdateOp {
@Override @Override
public void updateRepo(RepoContext ctx) public void updateRepo(RepoContext ctx)
throws MergeConflictException, InvalidChangeOperationException, RestApiException, IOException, throws MergeConflictException, InvalidChangeOperationException, RestApiException, IOException,
OrmException, NoSuchChangeException, PermissionBackendException { StorageException, NoSuchChangeException, PermissionBackendException {
// Ok that originalPatchSet was not read in a transaction, since we just // Ok that originalPatchSet was not read in a transaction, since we just
// need its revision. // need its revision.
RevId oldRev = originalPatchSet.getRevision(); RevId oldRev = originalPatchSet.getRevision();
@@ -214,14 +214,14 @@ public class RebaseChangeOp implements BatchUpdateOp {
@Override @Override
public boolean updateChange(ChangeContext ctx) public boolean updateChange(ChangeContext ctx)
throws ResourceConflictException, OrmException, IOException { throws ResourceConflictException, StorageException, IOException {
boolean ret = patchSetInserter.updateChange(ctx); boolean ret = patchSetInserter.updateChange(ctx);
rebasedPatchSet = patchSetInserter.getPatchSet(); rebasedPatchSet = patchSetInserter.getPatchSet();
return ret; return ret;
} }
@Override @Override
public void postUpdate(Context ctx) throws OrmException { public void postUpdate(Context ctx) throws StorageException {
patchSetInserter.postUpdate(ctx); patchSetInserter.postUpdate(ctx);
} }

Some files were not shown because too many files have changed in this diff Show More