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:
@@ -455,7 +455,7 @@ its own custom event class derived from
|
||||
----
|
||||
import com.google.gerrit.common.EventDispatcher;
|
||||
import com.google.gerrit.extensions.registration.DynamicItem;
|
||||
import com.google.gwtorm.server.OrmException;
|
||||
import com.google.exceptions.StorageException;
|
||||
import com.google.inject.Inject;
|
||||
|
||||
class MyPlugin {
|
||||
@@ -469,7 +469,7 @@ class MyPlugin {
|
||||
private void postEvent(MyPluginEvent event) {
|
||||
try {
|
||||
eventDispatcher.get().postEvent(event);
|
||||
} catch (OrmException e) {
|
||||
} catch (StorageException e) {
|
||||
// error handling
|
||||
}
|
||||
}
|
||||
|
@@ -53,6 +53,7 @@ import com.google.gerrit.common.data.Permission;
|
||||
import com.google.gerrit.common.data.PermissionRange;
|
||||
import com.google.gerrit.common.data.PermissionRule;
|
||||
import com.google.gerrit.common.data.PermissionRule.Action;
|
||||
import com.google.gerrit.exceptions.StorageException;
|
||||
import com.google.gerrit.extensions.api.GerritApi;
|
||||
import com.google.gerrit.extensions.api.changes.ReviewInput;
|
||||
import com.google.gerrit.extensions.api.changes.RevisionApi;
|
||||
@@ -132,7 +133,6 @@ import com.google.gerrit.testing.FakeEmailSender;
|
||||
import com.google.gerrit.testing.FakeEmailSender.Message;
|
||||
import com.google.gerrit.testing.SshMode;
|
||||
import com.google.gson.Gson;
|
||||
import com.google.gwtorm.server.OrmException;
|
||||
import com.google.inject.Inject;
|
||||
import com.google.inject.Module;
|
||||
import com.google.inject.Provider;
|
||||
@@ -1087,7 +1087,7 @@ public abstract class AbstractDaemonTest {
|
||||
.inOrder();
|
||||
}
|
||||
|
||||
protected PatchSet getPatchSet(PatchSet.Id psId) throws OrmException {
|
||||
protected PatchSet getPatchSet(PatchSet.Id psId) throws StorageException {
|
||||
return changeDataFactory.create(project, psId.getParentKey()).patchSet(psId);
|
||||
}
|
||||
|
||||
@@ -1416,7 +1416,7 @@ public abstract class AbstractDaemonTest {
|
||||
}
|
||||
|
||||
protected void watch(PushOneCommit.Result r, ProjectWatchInfoConfiguration config)
|
||||
throws OrmException, RestApiException {
|
||||
throws StorageException, RestApiException {
|
||||
watch(r.getChange().project().get(), config);
|
||||
}
|
||||
|
||||
|
@@ -21,6 +21,7 @@ import com.google.common.collect.ImmutableSet;
|
||||
import com.google.common.collect.Sets;
|
||||
import com.google.gerrit.common.Nullable;
|
||||
import com.google.gerrit.exceptions.NoSuchGroupException;
|
||||
import com.google.gerrit.exceptions.StorageException;
|
||||
import com.google.gerrit.reviewdb.client.Account;
|
||||
import com.google.gerrit.reviewdb.client.AccountGroup;
|
||||
import com.google.gerrit.server.ServerInitiated;
|
||||
@@ -31,7 +32,6 @@ import com.google.gerrit.server.group.InternalGroup;
|
||||
import com.google.gerrit.server.group.db.GroupsUpdate;
|
||||
import com.google.gerrit.server.group.db.InternalGroupUpdate;
|
||||
import com.google.gerrit.server.notedb.Sequences;
|
||||
import com.google.gwtorm.server.OrmException;
|
||||
import com.google.inject.Inject;
|
||||
import com.google.inject.Provider;
|
||||
import com.google.inject.Singleton;
|
||||
@@ -157,7 +157,7 @@ public class AccountCreator {
|
||||
}
|
||||
|
||||
private void addGroupMember(AccountGroup.UUID groupUuid, Account.Id accountId)
|
||||
throws OrmException, IOException, NoSuchGroupException, ConfigInvalidException {
|
||||
throws StorageException, IOException, NoSuchGroupException, ConfigInvalidException {
|
||||
InternalGroupUpdate groupUpdate =
|
||||
InternalGroupUpdate.builder()
|
||||
.setMemberModification(memberIds -> Sets.union(memberIds, ImmutableSet.of(accountId)))
|
||||
|
@@ -34,7 +34,6 @@ java_library(
|
||||
"//java/com/google/gerrit/server/restapi",
|
||||
"//java/com/google/gerrit/sshd",
|
||||
"//java/com/google/gerrit/testing:gerrit-test-util",
|
||||
"//java/com/google/gwtorm",
|
||||
"//lib:args4j",
|
||||
"//lib:gson",
|
||||
"//lib:guava-retrying",
|
||||
@@ -117,7 +116,6 @@ java_library2(
|
||||
"//java/com/google/gerrit/server/schema",
|
||||
"//java/com/google/gerrit/server/util/time",
|
||||
"//java/com/google/gerrit/sshd",
|
||||
"//java/com/google/gwtorm",
|
||||
"//lib:args4j",
|
||||
"//lib:gson",
|
||||
"//lib:guava-retrying",
|
||||
|
@@ -17,6 +17,8 @@ package com.google.gerrit.acceptance;
|
||||
import static com.google.inject.Scopes.SINGLETON;
|
||||
|
||||
import com.google.gerrit.common.Nullable;
|
||||
import com.google.gerrit.exceptions.StorageException;
|
||||
import com.google.gerrit.exceptions.StorageRuntimeException;
|
||||
import com.google.gerrit.extensions.events.LifecycleListener;
|
||||
import com.google.gerrit.lifecycle.LifecycleModule;
|
||||
import com.google.gerrit.metrics.DisabledMetricMaker;
|
||||
@@ -30,8 +32,6 @@ import com.google.gerrit.server.git.GitRepositoryManager;
|
||||
import com.google.gerrit.server.schema.SchemaCreator;
|
||||
import com.google.gerrit.server.schema.SchemaModule;
|
||||
import com.google.gerrit.testing.InMemoryRepositoryManager;
|
||||
import com.google.gwtorm.server.OrmException;
|
||||
import com.google.gwtorm.server.OrmRuntimeException;
|
||||
import com.google.inject.Inject;
|
||||
import com.google.inject.ProvisionException;
|
||||
import java.io.IOException;
|
||||
@@ -91,8 +91,8 @@ class InMemoryTestingDatabaseModule extends LifecycleModule {
|
||||
public void start() {
|
||||
try {
|
||||
schemaCreator.ensureCreated();
|
||||
} catch (OrmException | IOException | ConfigInvalidException e) {
|
||||
throw new OrmRuntimeException(e);
|
||||
} catch (StorageException | IOException | ConfigInvalidException e) {
|
||||
throw new StorageRuntimeException(e);
|
||||
}
|
||||
}
|
||||
|
||||
|
@@ -24,6 +24,7 @@ import com.google.common.collect.ImmutableMap;
|
||||
import com.google.common.collect.Iterables;
|
||||
import com.google.common.collect.Sets;
|
||||
import com.google.gerrit.common.Nullable;
|
||||
import com.google.gerrit.exceptions.StorageException;
|
||||
import com.google.gerrit.reviewdb.client.Account;
|
||||
import com.google.gerrit.reviewdb.client.Change;
|
||||
import com.google.gerrit.reviewdb.client.PatchSet;
|
||||
@@ -32,7 +33,6 @@ import com.google.gerrit.server.notedb.ChangeNotes;
|
||||
import com.google.gerrit.server.notedb.ReviewerStateInternal;
|
||||
import com.google.gerrit.server.query.change.ChangeData;
|
||||
import com.google.gerrit.server.query.change.InternalChangeQuery;
|
||||
import com.google.gwtorm.server.OrmException;
|
||||
import com.google.inject.Provider;
|
||||
import com.google.inject.assistedinject.Assisted;
|
||||
import com.google.inject.assistedinject.AssistedInject;
|
||||
@@ -334,15 +334,15 @@ public class PushOneCommit {
|
||||
this.resSubj = subject;
|
||||
}
|
||||
|
||||
public ChangeData getChange() throws OrmException {
|
||||
public ChangeData getChange() throws StorageException {
|
||||
return Iterables.getOnlyElement(queryProvider.get().byKeyPrefix(changeId));
|
||||
}
|
||||
|
||||
public PatchSet getPatchSet() throws OrmException {
|
||||
public PatchSet getPatchSet() throws StorageException {
|
||||
return getChange().currentPatchSet();
|
||||
}
|
||||
|
||||
public PatchSet.Id getPatchSetId() throws OrmException {
|
||||
public PatchSet.Id getPatchSetId() throws StorageException {
|
||||
return getChange().change().currentPatchSetId();
|
||||
}
|
||||
|
||||
@@ -360,7 +360,7 @@ public class PushOneCommit {
|
||||
|
||||
public void assertChange(
|
||||
Change.Status expectedStatus, String expectedTopic, TestAccount... expectedReviewers)
|
||||
throws OrmException {
|
||||
throws StorageException {
|
||||
assertChange(
|
||||
expectedStatus, expectedTopic, Arrays.asList(expectedReviewers), ImmutableList.of());
|
||||
}
|
||||
@@ -370,7 +370,7 @@ public class PushOneCommit {
|
||||
String expectedTopic,
|
||||
List<TestAccount> expectedReviewers,
|
||||
List<TestAccount> expectedCcs)
|
||||
throws OrmException {
|
||||
throws StorageException {
|
||||
Change c = getChange().change();
|
||||
assertThat(c.getSubject()).isEqualTo(resSubj);
|
||||
assertThat(c.getStatus()).isEqualTo(expectedStatus);
|
||||
@@ -381,7 +381,7 @@ public class PushOneCommit {
|
||||
|
||||
private void assertReviewers(
|
||||
Change c, ReviewerStateInternal state, List<TestAccount> expectedReviewers)
|
||||
throws OrmException {
|
||||
throws StorageException {
|
||||
Iterable<Account.Id> actualIds =
|
||||
approvalsUtil.getReviewers(notesFactory.createChecked(c)).byState(state);
|
||||
assertThat(actualIds)
|
||||
|
@@ -16,6 +16,7 @@ package com.google.gerrit.acceptance.testsuite.account;
|
||||
|
||||
import static com.google.common.base.Preconditions.checkState;
|
||||
|
||||
import com.google.gerrit.exceptions.StorageException;
|
||||
import com.google.gerrit.reviewdb.client.Account;
|
||||
import com.google.gerrit.server.ServerInitiated;
|
||||
import com.google.gerrit.server.account.AccountState;
|
||||
@@ -24,7 +25,6 @@ import com.google.gerrit.server.account.AccountsUpdate;
|
||||
import com.google.gerrit.server.account.InternalAccountUpdate;
|
||||
import com.google.gerrit.server.account.externalids.ExternalId;
|
||||
import com.google.gerrit.server.notedb.Sequences;
|
||||
import com.google.gwtorm.server.OrmException;
|
||||
import com.google.inject.Inject;
|
||||
import java.io.IOException;
|
||||
import java.util.Optional;
|
||||
@@ -68,7 +68,7 @@ public class AccountOperationsImpl implements AccountOperations {
|
||||
}
|
||||
|
||||
private AccountState createAccount(AccountsUpdate.AccountUpdater accountUpdater)
|
||||
throws OrmException, IOException, ConfigInvalidException {
|
||||
throws StorageException, IOException, ConfigInvalidException {
|
||||
Account.Id accountId = new Account.Id(seq.nextAccountId());
|
||||
return accountsUpdate.insert("Create Test Account", accountId, accountUpdater);
|
||||
}
|
||||
@@ -146,7 +146,7 @@ public class AccountOperationsImpl implements AccountOperations {
|
||||
}
|
||||
|
||||
private void updateAccount(TestAccountUpdate accountUpdate)
|
||||
throws OrmException, IOException, ConfigInvalidException {
|
||||
throws StorageException, IOException, ConfigInvalidException {
|
||||
AccountsUpdate.AccountUpdater accountUpdater =
|
||||
(account, updateBuilder) -> fillBuilder(updateBuilder, accountUpdate, accountId);
|
||||
Optional<AccountState> updatedAccount = updateAccount(accountUpdater);
|
||||
@@ -154,7 +154,7 @@ public class AccountOperationsImpl implements AccountOperations {
|
||||
}
|
||||
|
||||
private Optional<AccountState> updateAccount(AccountsUpdate.AccountUpdater accountUpdater)
|
||||
throws OrmException, IOException, ConfigInvalidException {
|
||||
throws StorageException, IOException, ConfigInvalidException {
|
||||
return accountsUpdate.update("Update Test Account", accountId, accountUpdater);
|
||||
}
|
||||
|
||||
|
@@ -16,7 +16,9 @@ package com.google.gerrit.acceptance.testsuite.group;
|
||||
|
||||
import static com.google.common.base.Preconditions.checkState;
|
||||
|
||||
import com.google.gerrit.exceptions.DuplicateKeyException;
|
||||
import com.google.gerrit.exceptions.NoSuchGroupException;
|
||||
import com.google.gerrit.exceptions.StorageException;
|
||||
import com.google.gerrit.reviewdb.client.AccountGroup;
|
||||
import com.google.gerrit.server.GerritPersonIdent;
|
||||
import com.google.gerrit.server.ServerInitiated;
|
||||
@@ -27,8 +29,6 @@ import com.google.gerrit.server.group.db.GroupsUpdate;
|
||||
import com.google.gerrit.server.group.db.InternalGroupCreation;
|
||||
import com.google.gerrit.server.group.db.InternalGroupUpdate;
|
||||
import com.google.gerrit.server.notedb.Sequences;
|
||||
import com.google.gwtorm.server.OrmDuplicateKeyException;
|
||||
import com.google.gwtorm.server.OrmException;
|
||||
import com.google.inject.Inject;
|
||||
import java.io.IOException;
|
||||
import java.util.Optional;
|
||||
@@ -70,7 +70,7 @@ public class GroupOperationsImpl implements GroupOperations {
|
||||
}
|
||||
|
||||
private AccountGroup.UUID createNewGroup(TestGroupCreation groupCreation)
|
||||
throws ConfigInvalidException, IOException, OrmException {
|
||||
throws ConfigInvalidException, IOException, StorageException {
|
||||
InternalGroupCreation internalGroupCreation = toInternalGroupCreation(groupCreation);
|
||||
InternalGroupUpdate internalGroupUpdate = toInternalGroupUpdate(groupCreation);
|
||||
InternalGroup internalGroup =
|
||||
@@ -79,7 +79,7 @@ public class GroupOperationsImpl implements GroupOperations {
|
||||
}
|
||||
|
||||
private InternalGroupCreation toInternalGroupCreation(TestGroupCreation groupCreation)
|
||||
throws OrmException {
|
||||
throws StorageException {
|
||||
AccountGroup.Id groupId = new AccountGroup.Id(seq.nextGroupId());
|
||||
String groupName = groupCreation.name().orElse("group-with-id-" + groupId.get());
|
||||
AccountGroup.UUID groupUuid = GroupUUID.make(groupName, serverIdent);
|
||||
@@ -148,7 +148,7 @@ public class GroupOperationsImpl implements GroupOperations {
|
||||
}
|
||||
|
||||
private void updateGroup(TestGroupUpdate groupUpdate)
|
||||
throws OrmDuplicateKeyException, NoSuchGroupException, ConfigInvalidException, IOException {
|
||||
throws DuplicateKeyException, NoSuchGroupException, ConfigInvalidException, IOException {
|
||||
InternalGroupUpdate internalGroupUpdate = toInternalGroupUpdate(groupUpdate);
|
||||
groupsUpdate.updateGroup(groupUuid, internalGroupUpdate);
|
||||
}
|
||||
|
@@ -32,6 +32,7 @@ import com.google.gerrit.elasticsearch.ElasticMapping.MappingProperties;
|
||||
import com.google.gerrit.elasticsearch.builders.QueryBuilder;
|
||||
import com.google.gerrit.elasticsearch.builders.SearchSourceBuilder;
|
||||
import com.google.gerrit.elasticsearch.bulk.DeleteRequest;
|
||||
import com.google.gerrit.exceptions.StorageException;
|
||||
import com.google.gerrit.index.FieldDef;
|
||||
import com.google.gerrit.index.FieldType;
|
||||
import com.google.gerrit.index.Index;
|
||||
@@ -53,7 +54,6 @@ import com.google.gson.JsonArray;
|
||||
import com.google.gson.JsonElement;
|
||||
import com.google.gson.JsonObject;
|
||||
import com.google.gson.JsonParser;
|
||||
import com.google.gwtorm.server.OrmException;
|
||||
import com.google.protobuf.MessageLite;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
@@ -377,16 +377,16 @@ abstract class AbstractElasticIndex<K, V> implements Index<K, V> {
|
||||
}
|
||||
|
||||
@Override
|
||||
public ResultSet<V> read() throws OrmException {
|
||||
public ResultSet<V> read() throws StorageException {
|
||||
return readImpl((doc) -> AbstractElasticIndex.this.fromDocument(doc, opts.fields()));
|
||||
}
|
||||
|
||||
@Override
|
||||
public ResultSet<FieldBundle> readRaw() throws OrmException {
|
||||
public ResultSet<FieldBundle> readRaw() throws StorageException {
|
||||
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 {
|
||||
String uri = getURI(index, SEARCH);
|
||||
Response response =
|
||||
@@ -412,7 +412,7 @@ abstract class AbstractElasticIndex<K, V> implements Index<K, V> {
|
||||
}
|
||||
return new ListResultSet<>(ImmutableList.of());
|
||||
} catch (IOException e) {
|
||||
throw new OrmException(e);
|
||||
throw new StorageException(e);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@@ -4,6 +4,7 @@ java_library(
|
||||
visibility = ["//visibility:public"],
|
||||
deps = [
|
||||
"//java/com/google/gerrit/common:annotations",
|
||||
"//java/com/google/gerrit/exceptions",
|
||||
"//java/com/google/gerrit/extensions:api",
|
||||
"//java/com/google/gerrit/index",
|
||||
"//java/com/google/gerrit/index:query_exception",
|
||||
@@ -12,7 +13,6 @@ java_library(
|
||||
"//java/com/google/gerrit/proto",
|
||||
"//java/com/google/gerrit/reviewdb:server",
|
||||
"//java/com/google/gerrit/server",
|
||||
"//java/com/google/gwtorm",
|
||||
"//lib:gson",
|
||||
"//lib:guava",
|
||||
"//lib:protobuf",
|
||||
|
@@ -33,6 +33,7 @@ import com.google.gerrit.elasticsearch.bulk.BulkRequest;
|
||||
import com.google.gerrit.elasticsearch.bulk.DeleteRequest;
|
||||
import com.google.gerrit.elasticsearch.bulk.IndexRequest;
|
||||
import com.google.gerrit.elasticsearch.bulk.UpdateRequest;
|
||||
import com.google.gerrit.exceptions.StorageException;
|
||||
import com.google.gerrit.index.QueryOptions;
|
||||
import com.google.gerrit.index.Schema;
|
||||
import com.google.gerrit.index.query.DataSource;
|
||||
@@ -57,7 +58,6 @@ import com.google.gerrit.server.query.change.ChangeData;
|
||||
import com.google.gson.JsonArray;
|
||||
import com.google.gson.JsonElement;
|
||||
import com.google.gson.JsonObject;
|
||||
import com.google.gwtorm.server.OrmException;
|
||||
import com.google.inject.Inject;
|
||||
import com.google.inject.assistedinject.Assisted;
|
||||
import java.io.IOException;
|
||||
@@ -119,7 +119,7 @@ class ElasticChangeIndex extends AbstractElasticIndex<Change.Id, ChangeData>
|
||||
insertIndex = CLOSED_CHANGES;
|
||||
deleteIndex = OPEN_CHANGES;
|
||||
}
|
||||
} catch (OrmException e) {
|
||||
} catch (StorageException e) {
|
||||
throw new IOException(e);
|
||||
}
|
||||
|
||||
|
@@ -12,17 +12,17 @@
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
package com.google.gwtorm.server;
|
||||
package com.google.gerrit.exceptions;
|
||||
|
||||
/** Indicates one or more entities were concurrently inserted with the same key. */
|
||||
public class OrmDuplicateKeyException extends OrmException {
|
||||
public class DuplicateKeyException extends StorageException {
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
public OrmDuplicateKeyException(String msg) {
|
||||
public DuplicateKeyException(String msg) {
|
||||
super(msg);
|
||||
}
|
||||
|
||||
public OrmDuplicateKeyException(String msg, Throwable why) {
|
||||
public DuplicateKeyException(String msg, Throwable why) {
|
||||
super(msg, why);
|
||||
}
|
||||
}
|
@@ -12,21 +12,33 @@
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
package com.google.gwtorm.server;
|
||||
package com.google.gerrit.exceptions;
|
||||
|
||||
/** Any data store read or write error. */
|
||||
public class OrmRuntimeException extends RuntimeException {
|
||||
/**
|
||||
* Any read/write error in a storage layer.
|
||||
*
|
||||
* <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;
|
||||
|
||||
public OrmRuntimeException(String message) {
|
||||
public StorageException(String message) {
|
||||
super(message);
|
||||
}
|
||||
|
||||
public OrmRuntimeException(String message, Throwable why) {
|
||||
public StorageException(String message, Throwable why) {
|
||||
super(message, why);
|
||||
}
|
||||
|
||||
public OrmRuntimeException(Throwable why) {
|
||||
public StorageException(Throwable why) {
|
||||
super(why);
|
||||
}
|
||||
}
|
@@ -12,21 +12,21 @@
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
package com.google.gwtorm.server;
|
||||
package com.google.gerrit.exceptions;
|
||||
|
||||
/** Any data store read or write error. */
|
||||
public class OrmException extends Exception {
|
||||
public class StorageRuntimeException extends RuntimeException {
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
public OrmException(String message) {
|
||||
public StorageRuntimeException(String message) {
|
||||
super(message);
|
||||
}
|
||||
|
||||
public OrmException(String message, Throwable why) {
|
||||
public StorageRuntimeException(String message, Throwable why) {
|
||||
super(message, why);
|
||||
}
|
||||
|
||||
public OrmException(Throwable why) {
|
||||
public StorageRuntimeException(Throwable why) {
|
||||
super(why);
|
||||
}
|
||||
}
|
@@ -8,7 +8,6 @@ java_library(
|
||||
"//java/com/google/gerrit/extensions:api",
|
||||
"//java/com/google/gerrit/reviewdb:server",
|
||||
"//java/com/google/gerrit/server",
|
||||
"//java/com/google/gwtorm",
|
||||
"//lib:guava",
|
||||
"//lib/bouncycastle:bcpg-neverlink",
|
||||
"//lib/bouncycastle:bcprov-neverlink",
|
||||
|
@@ -22,6 +22,7 @@ import com.google.common.collect.ImmutableMap;
|
||||
import com.google.common.collect.Maps;
|
||||
import com.google.common.flogger.FluentLogger;
|
||||
import com.google.common.io.BaseEncoding;
|
||||
import com.google.gerrit.exceptions.StorageException;
|
||||
import com.google.gerrit.extensions.registration.DynamicItem;
|
||||
import com.google.gerrit.server.IdentifiedUser;
|
||||
import com.google.gerrit.server.account.AccountState;
|
||||
@@ -29,7 +30,6 @@ import com.google.gerrit.server.account.externalids.ExternalId;
|
||||
import com.google.gerrit.server.config.GerritServerConfig;
|
||||
import com.google.gerrit.server.config.UrlFormatter;
|
||||
import com.google.gerrit.server.query.account.InternalAccountQuery;
|
||||
import com.google.gwtorm.server.OrmException;
|
||||
import com.google.inject.Inject;
|
||||
import com.google.inject.Provider;
|
||||
import com.google.inject.Singleton;
|
||||
@@ -135,7 +135,7 @@ public class GerritPublicKeyChecker extends PublicKeyChecker {
|
||||
return checkIdsForExpectedUser(key);
|
||||
}
|
||||
return checkIdsForArbitraryUser(key);
|
||||
} catch (PGPException | OrmException e) {
|
||||
} catch (PGPException | StorageException e) {
|
||||
String msg = "Error checking user IDs for key";
|
||||
logger.atWarning().withCause(e).log("%s %s", msg, keyIdToString(key.getKeyID()));
|
||||
return CheckResult.bad(msg);
|
||||
@@ -156,7 +156,8 @@ public class GerritPublicKeyChecker extends PublicKeyChecker {
|
||||
return CheckResult.bad(missingUserIds(allowedUserIds));
|
||||
}
|
||||
|
||||
private CheckResult checkIdsForArbitraryUser(PGPPublicKey key) throws PGPException, OrmException {
|
||||
private CheckResult checkIdsForArbitraryUser(PGPPublicKey key)
|
||||
throws PGPException, StorageException {
|
||||
List<AccountState> accountStates = accountQueryProvider.get().byExternalId(toExtIdKey(key));
|
||||
if (accountStates.isEmpty()) {
|
||||
return CheckResult.bad("Key is not associated with any users");
|
||||
|
@@ -14,6 +14,7 @@
|
||||
|
||||
package com.google.gerrit.gpg.api;
|
||||
|
||||
import com.google.gerrit.exceptions.StorageException;
|
||||
import com.google.gerrit.extensions.api.accounts.GpgKeyApi;
|
||||
import com.google.gerrit.extensions.api.accounts.GpgKeysInput;
|
||||
import com.google.gerrit.extensions.common.GpgKeyInfo;
|
||||
@@ -28,7 +29,6 @@ import com.google.gerrit.server.GpgException;
|
||||
import com.google.gerrit.server.IdentifiedUser;
|
||||
import com.google.gerrit.server.account.AccountResource;
|
||||
import com.google.gerrit.server.account.GpgApiAdapter;
|
||||
import com.google.gwtorm.server.OrmException;
|
||||
import com.google.inject.Inject;
|
||||
import com.google.inject.Provider;
|
||||
import java.io.IOException;
|
||||
@@ -67,7 +67,7 @@ public class GpgApiAdapterImpl implements GpgApiAdapter {
|
||||
throws RestApiException, GpgException {
|
||||
try {
|
||||
return gpgKeys.get().list().apply(account);
|
||||
} catch (OrmException | PGPException | IOException e) {
|
||||
} catch (StorageException | PGPException | IOException e) {
|
||||
throw new GpgException(e);
|
||||
}
|
||||
}
|
||||
@@ -81,7 +81,7 @@ public class GpgApiAdapterImpl implements GpgApiAdapter {
|
||||
in.delete = delete;
|
||||
try {
|
||||
return postGpgKeys.get().apply(account, in);
|
||||
} catch (PGPException | OrmException | IOException | ConfigInvalidException e) {
|
||||
} catch (PGPException | StorageException | IOException | ConfigInvalidException e) {
|
||||
throw new GpgException(e);
|
||||
}
|
||||
}
|
||||
@@ -91,7 +91,7 @@ public class GpgApiAdapterImpl implements GpgApiAdapter {
|
||||
throws RestApiException, GpgException {
|
||||
try {
|
||||
return gpgKeyApiFactory.create(gpgKeys.get().parse(account, idStr));
|
||||
} catch (PGPException | OrmException | IOException e) {
|
||||
} catch (PGPException | StorageException | IOException e) {
|
||||
throw new GpgException(e);
|
||||
}
|
||||
}
|
||||
|
@@ -14,6 +14,7 @@
|
||||
|
||||
package com.google.gerrit.gpg.api;
|
||||
|
||||
import com.google.gerrit.exceptions.StorageException;
|
||||
import com.google.gerrit.extensions.api.accounts.GpgKeyApi;
|
||||
import com.google.gerrit.extensions.common.GpgKeyInfo;
|
||||
import com.google.gerrit.extensions.common.Input;
|
||||
@@ -21,7 +22,6 @@ import com.google.gerrit.extensions.restapi.RestApiException;
|
||||
import com.google.gerrit.gpg.server.DeleteGpgKey;
|
||||
import com.google.gerrit.gpg.server.GpgKey;
|
||||
import com.google.gerrit.gpg.server.GpgKeys;
|
||||
import com.google.gwtorm.server.OrmException;
|
||||
import com.google.inject.Inject;
|
||||
import com.google.inject.assistedinject.Assisted;
|
||||
import java.io.IOException;
|
||||
@@ -57,7 +57,7 @@ public class GpgKeyApiImpl implements GpgKeyApi {
|
||||
public void delete() throws RestApiException {
|
||||
try {
|
||||
delete.apply(rsrc, new Input());
|
||||
} catch (PGPException | OrmException | IOException | ConfigInvalidException e) {
|
||||
} catch (PGPException | StorageException | IOException | ConfigInvalidException e) {
|
||||
throw new RestApiException("Cannot delete GPG key", e);
|
||||
}
|
||||
}
|
||||
|
@@ -18,6 +18,7 @@ import static com.google.gerrit.gpg.PublicKeyStore.keyIdToString;
|
||||
import static com.google.gerrit.server.account.externalids.ExternalId.SCHEME_GPGKEY;
|
||||
|
||||
import com.google.common.io.BaseEncoding;
|
||||
import com.google.gerrit.exceptions.StorageException;
|
||||
import com.google.gerrit.extensions.common.Input;
|
||||
import com.google.gerrit.extensions.restapi.ResourceConflictException;
|
||||
import com.google.gerrit.extensions.restapi.ResourceNotFoundException;
|
||||
@@ -30,7 +31,6 @@ import com.google.gerrit.server.UserInitiated;
|
||||
import com.google.gerrit.server.account.AccountsUpdate;
|
||||
import com.google.gerrit.server.account.externalids.ExternalId;
|
||||
import com.google.gerrit.server.account.externalids.ExternalIds;
|
||||
import com.google.gwtorm.server.OrmException;
|
||||
import com.google.inject.Inject;
|
||||
import com.google.inject.Provider;
|
||||
import java.io.IOException;
|
||||
@@ -63,7 +63,7 @@ public class DeleteGpgKey implements RestModifyView<GpgKey, Input> {
|
||||
|
||||
@Override
|
||||
public Response<?> apply(GpgKey rsrc, Input input)
|
||||
throws RestApiException, PGPException, OrmException, IOException, ConfigInvalidException {
|
||||
throws RestApiException, PGPException, StorageException, IOException, ConfigInvalidException {
|
||||
PGPPublicKey key = rsrc.getKeyRing().getPublicKey();
|
||||
String fingerprint = BaseEncoding.base16().encode(key.getFingerprint());
|
||||
Optional<ExternalId> extId = externalIds.get(ExternalId.Key.create(SCHEME_GPGKEY, fingerprint));
|
||||
|
@@ -21,6 +21,7 @@ import com.google.common.base.CharMatcher;
|
||||
import com.google.common.collect.ImmutableList;
|
||||
import com.google.common.flogger.FluentLogger;
|
||||
import com.google.common.io.BaseEncoding;
|
||||
import com.google.gerrit.exceptions.StorageException;
|
||||
import com.google.gerrit.extensions.common.GpgKeyInfo;
|
||||
import com.google.gerrit.extensions.registration.DynamicMap;
|
||||
import com.google.gerrit.extensions.restapi.AuthException;
|
||||
@@ -39,7 +40,6 @@ import com.google.gerrit.server.CurrentUser;
|
||||
import com.google.gerrit.server.account.AccountResource;
|
||||
import com.google.gerrit.server.account.externalids.ExternalId;
|
||||
import com.google.gerrit.server.account.externalids.ExternalIds;
|
||||
import com.google.gwtorm.server.OrmException;
|
||||
import com.google.inject.Inject;
|
||||
import com.google.inject.Provider;
|
||||
import com.google.inject.Singleton;
|
||||
@@ -86,7 +86,7 @@ public class GpgKeys implements ChildCollection<AccountResource, GpgKey> {
|
||||
|
||||
@Override
|
||||
public GpgKey parse(AccountResource parent, IdString id)
|
||||
throws ResourceNotFoundException, PGPException, OrmException, IOException {
|
||||
throws ResourceNotFoundException, PGPException, StorageException, IOException {
|
||||
checkVisible(self, parent);
|
||||
|
||||
ExternalId gpgKeyExtId = findGpgKey(id.get(), getGpgExtIds(parent));
|
||||
@@ -142,7 +142,7 @@ public class GpgKeys implements ChildCollection<AccountResource, GpgKey> {
|
||||
public class ListGpgKeys implements RestReadView<AccountResource> {
|
||||
@Override
|
||||
public Map<String, GpgKeyInfo> apply(AccountResource rsrc)
|
||||
throws OrmException, PGPException, IOException, ResourceNotFoundException {
|
||||
throws StorageException, PGPException, IOException, ResourceNotFoundException {
|
||||
checkVisible(self, rsrc);
|
||||
Map<String, GpgKeyInfo> keys = new HashMap<>();
|
||||
try (PublicKeyStore store = storeProvider.get()) {
|
||||
|
@@ -27,6 +27,7 @@ import com.google.common.collect.Maps;
|
||||
import com.google.common.flogger.FluentLogger;
|
||||
import com.google.common.io.BaseEncoding;
|
||||
import com.google.gerrit.exceptions.EmailException;
|
||||
import com.google.gerrit.exceptions.StorageException;
|
||||
import com.google.gerrit.extensions.api.accounts.GpgKeysInput;
|
||||
import com.google.gerrit.extensions.common.GpgKeyInfo;
|
||||
import com.google.gerrit.extensions.restapi.BadRequestException;
|
||||
@@ -50,7 +51,6 @@ import com.google.gerrit.server.account.externalids.ExternalId;
|
||||
import com.google.gerrit.server.account.externalids.ExternalIds;
|
||||
import com.google.gerrit.server.mail.send.AddKeySender;
|
||||
import com.google.gerrit.server.query.account.InternalAccountQuery;
|
||||
import com.google.gwtorm.server.OrmException;
|
||||
import com.google.inject.Inject;
|
||||
import com.google.inject.Provider;
|
||||
import com.google.inject.Singleton;
|
||||
@@ -108,7 +108,7 @@ public class PostGpgKeys implements RestModifyView<AccountResource, GpgKeysInput
|
||||
@Override
|
||||
public Map<String, GpgKeyInfo> apply(AccountResource rsrc, GpgKeysInput input)
|
||||
throws ResourceNotFoundException, BadRequestException, ResourceConflictException,
|
||||
PGPException, OrmException, IOException, ConfigInvalidException {
|
||||
PGPException, StorageException, IOException, ConfigInvalidException {
|
||||
GpgKeys.checkVisible(self, rsrc);
|
||||
|
||||
Collection<ExternalId> existingExtIds =
|
||||
@@ -249,7 +249,7 @@ public class PostGpgKeys implements RestModifyView<AccountResource, GpgKeysInput
|
||||
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);
|
||||
|
||||
if (accountStates.isEmpty()) {
|
||||
|
@@ -10,6 +10,7 @@ java_library(
|
||||
deps = [
|
||||
"//java/com/google/gerrit/common:annotations",
|
||||
"//java/com/google/gerrit/common:server",
|
||||
"//java/com/google/gerrit/exceptions",
|
||||
"//java/com/google/gerrit/extensions:api",
|
||||
"//java/com/google/gerrit/git",
|
||||
"//java/com/google/gerrit/json",
|
||||
@@ -26,7 +27,6 @@ java_library(
|
||||
"//java/com/google/gerrit/server/util/time",
|
||||
"//java/com/google/gerrit/util/cli",
|
||||
"//java/com/google/gerrit/util/http",
|
||||
"//java/com/google/gwtorm",
|
||||
"//java/org/eclipse/jgit:server",
|
||||
"//lib:args4j",
|
||||
"//lib:gson",
|
||||
|
@@ -15,13 +15,13 @@
|
||||
package com.google.gerrit.httpd;
|
||||
|
||||
import com.google.gerrit.common.PageLinks;
|
||||
import com.google.gerrit.exceptions.StorageException;
|
||||
import com.google.gerrit.extensions.restapi.ResourceConflictException;
|
||||
import com.google.gerrit.extensions.restapi.ResourceNotFoundException;
|
||||
import com.google.gerrit.reviewdb.client.Change;
|
||||
import com.google.gerrit.server.change.ChangeResource;
|
||||
import com.google.gerrit.server.permissions.PermissionBackendException;
|
||||
import com.google.gerrit.server.restapi.change.ChangesCollection;
|
||||
import com.google.gwtorm.server.OrmException;
|
||||
import com.google.inject.Inject;
|
||||
import com.google.inject.Singleton;
|
||||
import java.io.IOException;
|
||||
@@ -61,7 +61,7 @@ public class NumericChangeIdRedirectServlet extends HttpServlet {
|
||||
} catch (ResourceConflictException | ResourceNotFoundException e) {
|
||||
rsp.sendError(HttpServletResponse.SC_NOT_FOUND);
|
||||
return;
|
||||
} catch (OrmException | PermissionBackendException e) {
|
||||
} catch (StorageException | PermissionBackendException e) {
|
||||
throw new IOException("Unable to lookup change " + id.id, e);
|
||||
}
|
||||
String path =
|
||||
|
@@ -19,6 +19,7 @@ import static javax.servlet.http.HttpServletResponse.SC_FORBIDDEN;
|
||||
import static javax.servlet.http.HttpServletResponse.SC_INTERNAL_SERVER_ERROR;
|
||||
|
||||
import com.google.common.flogger.FluentLogger;
|
||||
import com.google.gerrit.exceptions.StorageException;
|
||||
import com.google.gerrit.extensions.registration.DynamicItem;
|
||||
import com.google.gerrit.extensions.restapi.AuthException;
|
||||
import com.google.gerrit.extensions.restapi.UnprocessableEntityException;
|
||||
@@ -29,7 +30,6 @@ import com.google.gerrit.server.config.AuthConfig;
|
||||
import com.google.gerrit.server.permissions.GlobalPermission;
|
||||
import com.google.gerrit.server.permissions.PermissionBackend;
|
||||
import com.google.gerrit.server.permissions.PermissionBackendException;
|
||||
import com.google.gwtorm.server.OrmException;
|
||||
import com.google.inject.Inject;
|
||||
import com.google.inject.Singleton;
|
||||
import com.google.inject.servlet.ServletModule;
|
||||
@@ -110,7 +110,7 @@ class RunAsFilter implements Filter {
|
||||
} catch (UnprocessableEntityException e) {
|
||||
replyError(req, res, SC_FORBIDDEN, "no account matches " + RUN_AS, null);
|
||||
return;
|
||||
} catch (OrmException | IOException | ConfigInvalidException e) {
|
||||
} catch (StorageException | IOException | ConfigInvalidException e) {
|
||||
logger.atWarning().withCause(e).log("cannot resolve account for %s", RUN_AS);
|
||||
replyError(req, res, SC_INTERNAL_SERVER_ERROR, "cannot resolve " + RUN_AS, e);
|
||||
return;
|
||||
|
@@ -18,6 +18,7 @@ import static com.google.gerrit.server.account.externalids.ExternalId.SCHEME_USE
|
||||
import static com.google.gerrit.server.account.externalids.ExternalId.SCHEME_UUID;
|
||||
|
||||
import com.google.gerrit.common.PageLinks;
|
||||
import com.google.gerrit.exceptions.StorageException;
|
||||
import com.google.gerrit.extensions.registration.DynamicItem;
|
||||
import com.google.gerrit.httpd.HtmlDomUtil;
|
||||
import com.google.gerrit.httpd.LoginUrlToken;
|
||||
@@ -34,7 +35,6 @@ import com.google.gerrit.server.account.AuthResult;
|
||||
import com.google.gerrit.server.account.externalids.ExternalId;
|
||||
import com.google.gerrit.server.query.account.InternalAccountQuery;
|
||||
import com.google.gerrit.util.http.CacheHeaders;
|
||||
import com.google.gwtorm.server.OrmException;
|
||||
import com.google.inject.Inject;
|
||||
import com.google.inject.Provider;
|
||||
import com.google.inject.Singleton;
|
||||
@@ -200,7 +200,7 @@ class BecomeAnyAccountLoginServlet extends HttpServlet {
|
||||
return null;
|
||||
}
|
||||
return auth(accountStates.get(0).getAccount().getId());
|
||||
} catch (OrmException e) {
|
||||
} catch (StorageException e) {
|
||||
getServletContext().log("cannot query account index", e);
|
||||
return null;
|
||||
}
|
||||
@@ -211,7 +211,7 @@ class BecomeAnyAccountLoginServlet extends HttpServlet {
|
||||
Optional<AccountState> match =
|
||||
queryProvider.get().byPreferredEmail(email).stream().findFirst();
|
||||
return auth(match);
|
||||
} catch (OrmException e) {
|
||||
} catch (StorageException e) {
|
||||
getServletContext().log("cannot query database", e);
|
||||
return Optional.empty();
|
||||
}
|
||||
|
@@ -19,6 +19,7 @@ import static java.nio.charset.StandardCharsets.UTF_8;
|
||||
|
||||
import com.google.common.flogger.FluentLogger;
|
||||
import com.google.gerrit.common.PageLinks;
|
||||
import com.google.gerrit.exceptions.StorageException;
|
||||
import com.google.gerrit.extensions.registration.DynamicItem;
|
||||
import com.google.gerrit.httpd.CanonicalWebUrl;
|
||||
import com.google.gerrit.httpd.HtmlDomUtil;
|
||||
@@ -31,7 +32,6 @@ import com.google.gerrit.server.account.AuthResult;
|
||||
import com.google.gerrit.server.account.externalids.ExternalId;
|
||||
import com.google.gerrit.server.config.AuthConfig;
|
||||
import com.google.gerrit.util.http.CacheHeaders;
|
||||
import com.google.gwtorm.server.OrmException;
|
||||
import com.google.inject.Inject;
|
||||
import com.google.inject.Singleton;
|
||||
import java.io.IOException;
|
||||
@@ -128,7 +128,7 @@ class HttpLoginServlet extends HttpServlet {
|
||||
logger.atFine().log(
|
||||
"Associating external identity \"%s\" to user \"%s\"", remoteExternalId, user);
|
||||
updateRemoteExternalId(arsp, remoteExternalId);
|
||||
} catch (AccountException | OrmException | ConfigInvalidException e) {
|
||||
} catch (AccountException | StorageException | ConfigInvalidException e) {
|
||||
logger.atSevere().withCause(e).log(
|
||||
"Unable to associate external identity \"%s\" to user \"%s\"", remoteExternalId, user);
|
||||
rsp.sendError(HttpServletResponse.SC_FORBIDDEN);
|
||||
@@ -152,7 +152,7 @@ class HttpLoginServlet extends HttpServlet {
|
||||
}
|
||||
|
||||
private void updateRemoteExternalId(AuthResult arsp, String remoteAuthToken)
|
||||
throws AccountException, OrmException, IOException, ConfigInvalidException {
|
||||
throws AccountException, StorageException, IOException, ConfigInvalidException {
|
||||
accountManager.updateLink(
|
||||
arsp.getAccountId(),
|
||||
new AuthRequest(ExternalId.Key.create(SCHEME_EXTERNAL, remoteAuthToken)));
|
||||
|
@@ -6,12 +6,12 @@ java_library(
|
||||
visibility = ["//visibility:public"],
|
||||
deps = [
|
||||
"//java/com/google/gerrit/common:annotations",
|
||||
"//java/com/google/gerrit/exceptions",
|
||||
"//java/com/google/gerrit/extensions:api",
|
||||
"//java/com/google/gerrit/httpd",
|
||||
"//java/com/google/gerrit/reviewdb:server",
|
||||
"//java/com/google/gerrit/server",
|
||||
"//java/com/google/gerrit/server/audit",
|
||||
"//java/com/google/gwtorm",
|
||||
"//lib:gson",
|
||||
"//lib:guava",
|
||||
"//lib:servlet-api-3_1",
|
||||
|
@@ -19,6 +19,7 @@ import static javax.servlet.http.HttpServletResponse.SC_UNAUTHORIZED;
|
||||
import com.google.common.base.CharMatcher;
|
||||
import com.google.common.base.Strings;
|
||||
import com.google.common.flogger.FluentLogger;
|
||||
import com.google.gerrit.exceptions.StorageException;
|
||||
import com.google.gerrit.extensions.auth.oauth.OAuthServiceProvider;
|
||||
import com.google.gerrit.extensions.auth.oauth.OAuthToken;
|
||||
import com.google.gerrit.extensions.auth.oauth.OAuthUserInfo;
|
||||
@@ -35,7 +36,6 @@ import com.google.gerrit.server.account.AuthRequest;
|
||||
import com.google.gerrit.server.account.AuthResult;
|
||||
import com.google.gerrit.server.account.externalids.ExternalId;
|
||||
import com.google.gerrit.server.auth.oauth.OAuthTokenCache;
|
||||
import com.google.gwtorm.server.OrmException;
|
||||
import com.google.inject.Inject;
|
||||
import com.google.inject.Provider;
|
||||
import com.google.inject.servlet.SessionScoped;
|
||||
@@ -188,7 +188,7 @@ class OAuthSession {
|
||||
logger.atInfo().log("OAuth2: linking claimed identity to %s", claimedId.get().toString());
|
||||
try {
|
||||
accountManager.link(claimedId.get(), req);
|
||||
} catch (OrmException | ConfigInvalidException e) {
|
||||
} catch (StorageException | ConfigInvalidException e) {
|
||||
logger.atSevere().log(
|
||||
"Cannot link: %s to user identity:\n Claimed ID: %s is %s",
|
||||
user.getExternalId(), claimedId.get(), claimedIdentifier);
|
||||
@@ -203,7 +203,7 @@ class OAuthSession {
|
||||
throws AccountException, IOException {
|
||||
try {
|
||||
accountManager.link(identifiedUser.get().getAccountId(), areq);
|
||||
} catch (OrmException | ConfigInvalidException e) {
|
||||
} catch (StorageException | ConfigInvalidException e) {
|
||||
logger.atSevere().log(
|
||||
"Cannot link: %s to user identity: %s",
|
||||
user.getExternalId(), identifiedUser.get().getAccountId());
|
||||
|
@@ -8,6 +8,7 @@ java_library(
|
||||
# We want all these deps to be provided_deps
|
||||
"//java/com/google/gerrit/common:annotations",
|
||||
"//java/com/google/gerrit/common:server",
|
||||
"//java/com/google/gerrit/exceptions",
|
||||
"//java/com/google/gerrit/extensions:api",
|
||||
"//java/com/google/gerrit/httpd",
|
||||
"//java/com/google/gerrit/reviewdb:server",
|
||||
|
@@ -18,6 +18,7 @@ import static javax.servlet.http.HttpServletResponse.SC_UNAUTHORIZED;
|
||||
|
||||
import com.google.common.base.Strings;
|
||||
import com.google.common.flogger.FluentLogger;
|
||||
import com.google.gerrit.exceptions.StorageException;
|
||||
import com.google.gerrit.extensions.auth.oauth.OAuthServiceProvider;
|
||||
import com.google.gerrit.extensions.auth.oauth.OAuthToken;
|
||||
import com.google.gerrit.extensions.auth.oauth.OAuthUserInfo;
|
||||
@@ -33,7 +34,6 @@ import com.google.gerrit.server.account.AccountException;
|
||||
import com.google.gerrit.server.account.AccountManager;
|
||||
import com.google.gerrit.server.account.AuthResult;
|
||||
import com.google.gerrit.server.account.externalids.ExternalId;
|
||||
import com.google.gwtorm.server.OrmException;
|
||||
import com.google.inject.Inject;
|
||||
import com.google.inject.Provider;
|
||||
import com.google.inject.servlet.SessionScoped;
|
||||
@@ -164,7 +164,7 @@ class OAuthSessionOverOpenID {
|
||||
logger.atFine().log("Claimed account already exists: link to it.");
|
||||
try {
|
||||
accountManager.link(claimedId.get(), areq);
|
||||
} catch (OrmException | ConfigInvalidException e) {
|
||||
} catch (StorageException | ConfigInvalidException e) {
|
||||
logger.atSevere().log(
|
||||
"Cannot link: %s to user identity:\n Claimed ID: %s is %s",
|
||||
user.getExternalId(), claimedId.get(), claimedIdentifier);
|
||||
@@ -178,7 +178,7 @@ class OAuthSessionOverOpenID {
|
||||
try {
|
||||
logger.atFine().log("Linking \"%s\" to \"%s\"", user.getExternalId(), accountId);
|
||||
accountManager.link(accountId, areq);
|
||||
} catch (OrmException | ConfigInvalidException e) {
|
||||
} catch (StorageException | ConfigInvalidException e) {
|
||||
logger.atSevere().log(
|
||||
"Cannot link: %s to user identity: %s", user.getExternalId(), accountId);
|
||||
rsp.sendError(HttpServletResponse.SC_FORBIDDEN);
|
||||
|
@@ -25,7 +25,6 @@ java_library(
|
||||
"//java/com/google/gerrit/server/restapi",
|
||||
"//java/com/google/gerrit/server/schema",
|
||||
"//java/com/google/gerrit/sshd",
|
||||
"//java/com/google/gwtorm",
|
||||
"//lib:guava",
|
||||
"//lib:servlet-api-3_1",
|
||||
"//lib/flogger:api",
|
||||
|
@@ -14,6 +14,7 @@
|
||||
|
||||
package com.google.gerrit.httpd.raw;
|
||||
|
||||
import com.google.gerrit.exceptions.StorageException;
|
||||
import com.google.gerrit.extensions.restapi.AuthException;
|
||||
import com.google.gerrit.extensions.restapi.ResourceConflictException;
|
||||
import com.google.gerrit.extensions.restapi.Url;
|
||||
@@ -29,7 +30,6 @@ import com.google.gerrit.server.permissions.PermissionBackend;
|
||||
import com.google.gerrit.server.permissions.PermissionBackendException;
|
||||
import com.google.gerrit.server.project.NoSuchChangeException;
|
||||
import com.google.gerrit.server.project.ProjectCache;
|
||||
import com.google.gwtorm.server.OrmException;
|
||||
import com.google.inject.Inject;
|
||||
import com.google.inject.Singleton;
|
||||
import java.io.IOException;
|
||||
@@ -145,7 +145,7 @@ public class CatServlet extends HttpServlet {
|
||||
} catch (ResourceConflictException | NoSuchChangeException | AuthException e) {
|
||||
rsp.sendError(HttpServletResponse.SC_NOT_FOUND);
|
||||
return;
|
||||
} catch (OrmException | PermissionBackendException | IOException e) {
|
||||
} catch (StorageException | PermissionBackendException | IOException e) {
|
||||
getServletContext().log("Cannot query database", e);
|
||||
rsp.sendError(HttpServletResponse.SC_INTERNAL_SERVER_ERROR);
|
||||
return;
|
||||
|
@@ -20,12 +20,12 @@ java_library(
|
||||
":query_exception",
|
||||
"//antlr3:query_parser",
|
||||
"//java/com/google/gerrit/common:annotations",
|
||||
"//java/com/google/gerrit/exceptions",
|
||||
"//java/com/google/gerrit/extensions:api",
|
||||
"//java/com/google/gerrit/json",
|
||||
"//java/com/google/gerrit/metrics",
|
||||
"//java/com/google/gerrit/reviewdb:server",
|
||||
"//java/com/google/gerrit/server/logging",
|
||||
"//java/com/google/gwtorm",
|
||||
"//lib:guava",
|
||||
"//lib/antlr:java-runtime",
|
||||
"//lib/auto:auto-value",
|
||||
|
@@ -19,7 +19,7 @@ import static java.util.Objects.requireNonNull;
|
||||
|
||||
import com.google.common.base.CharMatcher;
|
||||
import com.google.gerrit.common.Nullable;
|
||||
import com.google.gwtorm.server.OrmException;
|
||||
import com.google.gerrit.exceptions.StorageException;
|
||||
import java.io.IOException;
|
||||
import java.sql.Timestamp;
|
||||
|
||||
@@ -62,7 +62,7 @@ public final class FieldDef<I, T> {
|
||||
@FunctionalInterface
|
||||
public interface Getter<I, T> {
|
||||
@Nullable
|
||||
T get(I input) throws OrmException, IOException;
|
||||
T get(I input) throws StorageException, IOException;
|
||||
}
|
||||
|
||||
public static class Builder<T> {
|
||||
@@ -133,14 +133,14 @@ public final class FieldDef<I, T> {
|
||||
*
|
||||
* @param input input object.
|
||||
* @return the field value(s) to index.
|
||||
* @throws OrmException
|
||||
* @throws StorageException
|
||||
*/
|
||||
@Nullable
|
||||
public T get(I input) throws OrmException {
|
||||
public T get(I input) throws StorageException {
|
||||
try {
|
||||
return getter.get(input);
|
||||
} catch (IOException e) {
|
||||
throw new OrmException(e);
|
||||
throw new StorageException(e);
|
||||
}
|
||||
}
|
||||
|
||||
|
@@ -15,12 +15,12 @@
|
||||
package com.google.gerrit.index;
|
||||
|
||||
import com.google.common.collect.ImmutableList;
|
||||
import com.google.gerrit.exceptions.StorageException;
|
||||
import com.google.gerrit.index.query.DataSource;
|
||||
import com.google.gerrit.index.query.FieldBundle;
|
||||
import com.google.gerrit.index.query.IndexPredicate;
|
||||
import com.google.gerrit.index.query.Predicate;
|
||||
import com.google.gerrit.index.query.QueryParseException;
|
||||
import com.google.gwtorm.server.OrmException;
|
||||
import java.io.IOException;
|
||||
import java.util.Optional;
|
||||
|
||||
@@ -100,7 +100,7 @@ public interface Index<K, V> {
|
||||
results = getSource(keyPredicate(key), opts).read().toList();
|
||||
} catch (QueryParseException e) {
|
||||
throw new IOException("Unexpected QueryParseException during get()", e);
|
||||
} catch (OrmException e) {
|
||||
} catch (StorageException e) {
|
||||
throw new IOException(e);
|
||||
}
|
||||
if (results.size() > 1) {
|
||||
@@ -125,7 +125,7 @@ public interface Index<K, V> {
|
||||
results = getSource(keyPredicate(key), opts).readRaw().toList();
|
||||
} catch (QueryParseException e) {
|
||||
throw new IOException("Unexpected QueryParseException during get()", e);
|
||||
} catch (OrmException e) {
|
||||
} catch (StorageException e) {
|
||||
throw new IOException(e);
|
||||
}
|
||||
if (results.size() > 1) {
|
||||
|
@@ -22,7 +22,7 @@ import com.google.common.collect.FluentIterable;
|
||||
import com.google.common.collect.ImmutableList;
|
||||
import com.google.common.collect.ImmutableMap;
|
||||
import com.google.common.flogger.FluentLogger;
|
||||
import com.google.gwtorm.server.OrmException;
|
||||
import com.google.gerrit.exceptions.StorageException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.Collections;
|
||||
@@ -179,7 +179,7 @@ public class Schema<T> {
|
||||
Object v;
|
||||
try {
|
||||
v = f.get(obj);
|
||||
} catch (OrmException e) {
|
||||
} catch (StorageException e) {
|
||||
logger.atSevere().withCause(e).log(
|
||||
"error getting field %s of %s", f.getName(), obj);
|
||||
return null;
|
||||
|
@@ -16,7 +16,7 @@ package com.google.gerrit.index.query;
|
||||
|
||||
import static com.google.common.base.Preconditions.checkState;
|
||||
|
||||
import com.google.gwtorm.server.OrmException;
|
||||
import com.google.gerrit.exceptions.StorageException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.Collection;
|
||||
@@ -82,7 +82,7 @@ public class AndPredicate<T> extends Predicate<T> implements Matchable<T> {
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean match(T object) throws OrmException {
|
||||
public boolean match(T object) throws StorageException {
|
||||
for (Predicate<T> c : children) {
|
||||
checkState(
|
||||
c.isMatchable(),
|
||||
|
@@ -21,8 +21,8 @@ import com.google.common.base.Throwables;
|
||||
import com.google.common.collect.FluentIterable;
|
||||
import com.google.common.collect.ImmutableList;
|
||||
import com.google.common.collect.Iterables;
|
||||
import com.google.gwtorm.server.OrmException;
|
||||
import com.google.gwtorm.server.OrmRuntimeException;
|
||||
import com.google.gerrit.exceptions.StorageException;
|
||||
import com.google.gerrit.exceptions.StorageRuntimeException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
import java.util.Comparator;
|
||||
@@ -76,26 +76,26 @@ public class AndSource<T> extends AndPredicate<T>
|
||||
}
|
||||
|
||||
@Override
|
||||
public ResultSet<T> read() throws OrmException {
|
||||
public ResultSet<T> read() throws StorageException {
|
||||
try {
|
||||
return readImpl();
|
||||
} catch (OrmRuntimeException err) {
|
||||
} catch (StorageRuntimeException err) {
|
||||
if (err.getCause() != null) {
|
||||
Throwables.throwIfInstanceOf(err.getCause(), OrmException.class);
|
||||
Throwables.throwIfInstanceOf(err.getCause(), StorageException.class);
|
||||
}
|
||||
throw new OrmException(err);
|
||||
throw new StorageException(err);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public ResultSet<FieldBundle> readRaw() throws OrmException {
|
||||
public ResultSet<FieldBundle> readRaw() throws StorageException {
|
||||
// TOOD(hiesel): Implement
|
||||
throw new UnsupportedOperationException("not implemented");
|
||||
}
|
||||
|
||||
private ResultSet<T> readImpl() throws OrmException {
|
||||
private ResultSet<T> readImpl() throws StorageException {
|
||||
if (source == null) {
|
||||
throw new OrmException("No DataSource: " + this);
|
||||
throw new StorageException("No DataSource: " + this);
|
||||
}
|
||||
List<T> r = new ArrayList<>();
|
||||
T last = null;
|
||||
@@ -147,7 +147,7 @@ public class AndSource<T> extends AndPredicate<T>
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean match(T object) throws OrmException {
|
||||
public boolean match(T object) throws StorageException {
|
||||
if (isVisibleToPredicate != null && !isVisibleToPredicate.match(object)) {
|
||||
return false;
|
||||
}
|
||||
@@ -164,7 +164,7 @@ public class AndSource<T> extends AndPredicate<T>
|
||||
.transformAndConcat(this::transformBuffer);
|
||||
}
|
||||
|
||||
protected List<T> transformBuffer(List<T> buffer) throws OrmRuntimeException {
|
||||
protected List<T> transformBuffer(List<T> buffer) throws StorageRuntimeException {
|
||||
return buffer;
|
||||
}
|
||||
|
||||
|
@@ -14,15 +14,15 @@
|
||||
|
||||
package com.google.gerrit.index.query;
|
||||
|
||||
import com.google.gwtorm.server.OrmException;
|
||||
import com.google.gerrit.exceptions.StorageException;
|
||||
|
||||
public interface DataSource<T> {
|
||||
/** @return an estimate of the number of results from {@link #read()}. */
|
||||
int getCardinality();
|
||||
|
||||
/** @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. */
|
||||
ResultSet<FieldBundle> readRaw() throws OrmException;
|
||||
ResultSet<FieldBundle> readRaw() throws StorageException;
|
||||
}
|
||||
|
@@ -16,9 +16,9 @@ package com.google.gerrit.index.query;
|
||||
|
||||
import com.google.common.base.MoreObjects;
|
||||
import com.google.common.collect.ImmutableList;
|
||||
import com.google.gerrit.exceptions.StorageException;
|
||||
import com.google.gerrit.index.Index;
|
||||
import com.google.gerrit.index.QueryOptions;
|
||||
import com.google.gwtorm.server.OrmException;
|
||||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
|
||||
@@ -77,17 +77,17 @@ public class IndexedQuery<I, T> extends Predicate<T> implements DataSource<T>, P
|
||||
}
|
||||
|
||||
@Override
|
||||
public ResultSet<T> read() throws OrmException {
|
||||
public ResultSet<T> read() throws StorageException {
|
||||
return source.read();
|
||||
}
|
||||
|
||||
@Override
|
||||
public ResultSet<FieldBundle> readRaw() throws OrmException {
|
||||
public ResultSet<FieldBundle> readRaw() throws StorageException {
|
||||
return source.readRaw();
|
||||
}
|
||||
|
||||
@Override
|
||||
public ResultSet<T> restart(int start) throws OrmException {
|
||||
public ResultSet<T> restart(int start) throws StorageException {
|
||||
opts = opts.withStart(start);
|
||||
try {
|
||||
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
|
||||
// changed about pred was its start, and any other QPEs that might happen
|
||||
// should have already thrown from the constructor.
|
||||
throw new OrmException(e);
|
||||
throw new StorageException(e);
|
||||
}
|
||||
// Don't convert start to a limit, since the caller of this method (see
|
||||
// AndSource) has calculated the actual number to skip.
|
||||
|
@@ -14,9 +14,9 @@
|
||||
|
||||
package com.google.gerrit.index.query;
|
||||
|
||||
import com.google.gerrit.exceptions.StorageException;
|
||||
import com.google.gerrit.index.FieldDef;
|
||||
import com.google.gerrit.index.query.RangeUtil.Range;
|
||||
import com.google.gwtorm.server.OrmException;
|
||||
|
||||
public abstract class IntegerRangePredicate<T> extends IndexPredicate<T> {
|
||||
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);
|
||||
if (valueInt == null) {
|
||||
return false;
|
||||
|
@@ -20,12 +20,12 @@ import static java.util.stream.Collectors.toSet;
|
||||
import com.google.common.collect.ImmutableList;
|
||||
import com.google.common.collect.ImmutableSet;
|
||||
import com.google.common.collect.Lists;
|
||||
import com.google.gerrit.exceptions.StorageException;
|
||||
import com.google.gerrit.index.FieldDef;
|
||||
import com.google.gerrit.index.Index;
|
||||
import com.google.gerrit.index.IndexCollection;
|
||||
import com.google.gerrit.index.IndexConfig;
|
||||
import com.google.gerrit.index.Schema;
|
||||
import com.google.gwtorm.server.OrmException;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
import java.util.function.Supplier;
|
||||
@@ -88,15 +88,15 @@ public class InternalQuery<T, Q extends InternalQuery<T, Q>> {
|
||||
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();
|
||||
}
|
||||
|
||||
final QueryResult<T> queryResults(Predicate<T> p) throws OrmException {
|
||||
final QueryResult<T> queryResults(Predicate<T> p) throws StorageException {
|
||||
try {
|
||||
return queryProcessor.query(p);
|
||||
} catch (QueryParseException e) {
|
||||
throw new OrmException(e);
|
||||
throw new StorageException(e);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -110,11 +110,11 @@ public class InternalQuery<T, Q extends InternalQuery<T, Q>> {
|
||||
* @return results of the queries, one list of results per input query, in the same order as the
|
||||
* 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 {
|
||||
return Lists.transform(queryProcessor.query(queries), QueryResult::entities);
|
||||
} catch (QueryParseException e) {
|
||||
throw new OrmException(e);
|
||||
throw new StorageException(e);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -144,11 +144,11 @@ public class InternalQuery<T, Q extends InternalQuery<T, Q>> {
|
||||
* @param predicate predicate to search for.
|
||||
* @param <T> result type.
|
||||
* @return exhaustive list of results, subject to the race condition described above.
|
||||
* @throws OrmException if an error occurred.
|
||||
* @throws StorageException if an error occurred.
|
||||
*/
|
||||
protected static <T> ImmutableList<T> queryExhaustively(
|
||||
Supplier<? extends InternalQuery<T, ?>> querySupplier, Predicate<T> predicate)
|
||||
throws OrmException {
|
||||
throws StorageException {
|
||||
ImmutableList.Builder<T> b = null;
|
||||
int start = 0;
|
||||
while (true) {
|
||||
|
@@ -14,15 +14,15 @@
|
||||
|
||||
package com.google.gerrit.index.query;
|
||||
|
||||
import com.google.gwtorm.server.OrmException;
|
||||
import com.google.gerrit.exceptions.StorageException;
|
||||
|
||||
public interface Matchable<T> {
|
||||
/**
|
||||
* Does this predicate match this object?
|
||||
*
|
||||
* @throws OrmException
|
||||
* @throws StorageException
|
||||
*/
|
||||
boolean match(T object) throws OrmException;
|
||||
boolean match(T object) throws StorageException;
|
||||
|
||||
/** @return a cost estimate to run this predicate, higher figures cost more. */
|
||||
int getCost();
|
||||
|
@@ -16,7 +16,7 @@ package com.google.gerrit.index.query;
|
||||
|
||||
import static com.google.common.base.Preconditions.checkState;
|
||||
|
||||
import com.google.gwtorm.server.OrmException;
|
||||
import com.google.gerrit.exceptions.StorageException;
|
||||
import java.util.Collection;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
@@ -64,7 +64,7 @@ public class NotPredicate<T> extends Predicate<T> implements Matchable<T> {
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean match(T object) throws OrmException {
|
||||
public boolean match(T object) throws StorageException {
|
||||
checkState(
|
||||
that.isMatchable(),
|
||||
"match invoked, but child predicate %s doesn't implement %s",
|
||||
|
@@ -16,7 +16,7 @@ package com.google.gerrit.index.query;
|
||||
|
||||
import static com.google.common.base.Preconditions.checkState;
|
||||
|
||||
import com.google.gwtorm.server.OrmException;
|
||||
import com.google.gerrit.exceptions.StorageException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.Collection;
|
||||
@@ -82,7 +82,7 @@ public class OrPredicate<T> extends Predicate<T> implements Matchable<T> {
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean match(T object) throws OrmException {
|
||||
public boolean match(T object) throws StorageException {
|
||||
for (Predicate<T> c : children) {
|
||||
checkState(
|
||||
c.isMatchable(),
|
||||
|
@@ -14,11 +14,11 @@
|
||||
|
||||
package com.google.gerrit.index.query;
|
||||
|
||||
import com.google.gerrit.exceptions.StorageException;
|
||||
import com.google.gerrit.index.QueryOptions;
|
||||
import com.google.gwtorm.server.OrmException;
|
||||
|
||||
public interface Paginated<T> {
|
||||
QueryOptions getOptions();
|
||||
|
||||
ResultSet<T> restart(int start) throws OrmException;
|
||||
ResultSet<T> restart(int start) throws StorageException;
|
||||
}
|
||||
|
@@ -26,6 +26,8 @@ import com.google.common.collect.ImmutableSet;
|
||||
import com.google.common.collect.Ordering;
|
||||
import com.google.common.flogger.FluentLogger;
|
||||
import com.google.gerrit.common.Nullable;
|
||||
import com.google.gerrit.exceptions.StorageException;
|
||||
import com.google.gerrit.exceptions.StorageRuntimeException;
|
||||
import com.google.gerrit.index.Index;
|
||||
import com.google.gerrit.index.IndexCollection;
|
||||
import com.google.gerrit.index.IndexConfig;
|
||||
@@ -37,8 +39,6 @@ import com.google.gerrit.metrics.Field;
|
||||
import com.google.gerrit.metrics.MetricMaker;
|
||||
import com.google.gerrit.metrics.Timer1;
|
||||
import com.google.gerrit.server.logging.CallerFinder;
|
||||
import com.google.gwtorm.server.OrmException;
|
||||
import com.google.gwtorm.server.OrmRuntimeException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Optional;
|
||||
@@ -173,7 +173,7 @@ public abstract class QueryProcessor<T> {
|
||||
* @param query 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);
|
||||
}
|
||||
|
||||
@@ -189,12 +189,12 @@ public abstract class QueryProcessor<T> {
|
||||
* input.
|
||||
*/
|
||||
public List<QueryResult<T>> query(List<Predicate<T>> queries)
|
||||
throws OrmException, QueryParseException {
|
||||
throws StorageException, QueryParseException {
|
||||
try {
|
||||
return query(null, queries);
|
||||
} catch (OrmRuntimeException e) {
|
||||
throw new OrmException(e.getMessage(), e);
|
||||
} catch (OrmException e) {
|
||||
} catch (StorageRuntimeException e) {
|
||||
throw new StorageException(e.getMessage(), e);
|
||||
} catch (StorageException e) {
|
||||
if (e.getCause() != null) {
|
||||
Throwables.throwIfInstanceOf(e.getCause(), QueryParseException.class);
|
||||
}
|
||||
@@ -204,7 +204,7 @@ public abstract class QueryProcessor<T> {
|
||||
|
||||
private List<QueryResult<T>> query(
|
||||
@Nullable List<String> queryStrings, List<Predicate<T>> queries)
|
||||
throws OrmException, QueryParseException {
|
||||
throws StorageException, QueryParseException {
|
||||
long startNanos = System.nanoTime();
|
||||
checkState(!used.getAndSet(true), "%s has already been used", getClass().getSimpleName());
|
||||
int cnt = queries.size();
|
||||
@@ -287,7 +287,7 @@ public abstract class QueryProcessor<T> {
|
||||
// Only measure successful queries that actually touched the index.
|
||||
metrics.executionTime.record(
|
||||
schemaDef.getName(), System.nanoTime() - startNanos, TimeUnit.NANOSECONDS);
|
||||
} catch (OrmException | OrmRuntimeException e) {
|
||||
} catch (StorageException | StorageRuntimeException e) {
|
||||
Optional<QueryParseException> qpe = findQueryParseException(e);
|
||||
if (qpe.isPresent()) {
|
||||
throw new QueryParseException(qpe.get().getMessage(), e);
|
||||
|
@@ -31,6 +31,7 @@ import com.google.common.util.concurrent.ListeningExecutorService;
|
||||
import com.google.common.util.concurrent.MoreExecutors;
|
||||
import com.google.common.util.concurrent.ThreadFactoryBuilder;
|
||||
import com.google.gerrit.common.Nullable;
|
||||
import com.google.gerrit.exceptions.StorageException;
|
||||
import com.google.gerrit.index.FieldDef;
|
||||
import com.google.gerrit.index.FieldType;
|
||||
import com.google.gerrit.index.Index;
|
||||
@@ -45,7 +46,6 @@ import com.google.gerrit.server.config.SitePaths;
|
||||
import com.google.gerrit.server.index.IndexUtils;
|
||||
import com.google.gerrit.server.logging.LoggingContextAwareExecutorService;
|
||||
import com.google.gerrit.server.logging.LoggingContextAwareScheduledExecutorService;
|
||||
import com.google.gwtorm.server.OrmException;
|
||||
import java.io.IOException;
|
||||
import java.sql.Timestamp;
|
||||
import java.util.Map;
|
||||
@@ -486,16 +486,16 @@ public abstract class AbstractLuceneIndex<K, V> implements Index<K, V> {
|
||||
}
|
||||
|
||||
@Override
|
||||
public ResultSet<V> read() throws OrmException {
|
||||
public ResultSet<V> read() throws StorageException {
|
||||
return readImpl(AbstractLuceneIndex.this::fromDocument);
|
||||
}
|
||||
|
||||
@Override
|
||||
public ResultSet<FieldBundle> readRaw() throws OrmException {
|
||||
public ResultSet<FieldBundle> readRaw() throws StorageException {
|
||||
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;
|
||||
try {
|
||||
searcher = acquire();
|
||||
@@ -512,7 +512,7 @@ public abstract class AbstractLuceneIndex<K, V> implements Index<K, V> {
|
||||
}
|
||||
return new ListResultSet<>(b.build());
|
||||
} catch (IOException e) {
|
||||
throw new OrmException(e);
|
||||
throw new StorageException(e);
|
||||
} finally {
|
||||
if (searcher != null) {
|
||||
try {
|
||||
|
@@ -9,7 +9,6 @@ java_library(
|
||||
"//java/com/google/gerrit/index:query_exception",
|
||||
"//java/com/google/gerrit/reviewdb:server",
|
||||
"//java/com/google/gerrit/server",
|
||||
"//java/com/google/gwtorm",
|
||||
"//lib:guava",
|
||||
"//lib/lucene:lucene-core-and-backward-codecs",
|
||||
],
|
||||
@@ -26,6 +25,7 @@ java_library(
|
||||
":query_builder",
|
||||
"//java/com/google/gerrit/common:annotations",
|
||||
"//java/com/google/gerrit/common:server",
|
||||
"//java/com/google/gerrit/exceptions",
|
||||
"//java/com/google/gerrit/extensions:api",
|
||||
"//java/com/google/gerrit/index",
|
||||
"//java/com/google/gerrit/index:query_exception",
|
||||
@@ -35,7 +35,6 @@ java_library(
|
||||
"//java/com/google/gerrit/reviewdb:server",
|
||||
"//java/com/google/gerrit/server",
|
||||
"//java/com/google/gerrit/server/logging",
|
||||
"//java/com/google/gwtorm",
|
||||
"//lib:guava",
|
||||
"//lib:protobuf",
|
||||
"//lib/flogger:api",
|
||||
|
@@ -36,6 +36,8 @@ import com.google.common.collect.Sets;
|
||||
import com.google.common.flogger.FluentLogger;
|
||||
import com.google.common.util.concurrent.Futures;
|
||||
import com.google.common.util.concurrent.ListeningExecutorService;
|
||||
import com.google.gerrit.exceptions.StorageException;
|
||||
import com.google.gerrit.exceptions.StorageRuntimeException;
|
||||
import com.google.gerrit.index.QueryOptions;
|
||||
import com.google.gerrit.index.Schema;
|
||||
import com.google.gerrit.index.query.FieldBundle;
|
||||
@@ -62,8 +64,6 @@ import com.google.gerrit.server.index.change.ChangeIndexRewriter;
|
||||
import com.google.gerrit.server.project.SubmitRuleOptions;
|
||||
import com.google.gerrit.server.query.change.ChangeData;
|
||||
import com.google.gerrit.server.query.change.ChangeDataSource;
|
||||
import com.google.gwtorm.server.OrmException;
|
||||
import com.google.gwtorm.server.OrmRuntimeException;
|
||||
import com.google.inject.Inject;
|
||||
import com.google.inject.assistedinject.Assisted;
|
||||
import com.google.protobuf.MessageLite;
|
||||
@@ -212,7 +212,7 @@ public class LuceneChangeIndex implements ChangeIndex {
|
||||
} else {
|
||||
Futures.allAsList(openIndex.delete(id), closedIndex.replace(id, doc)).get();
|
||||
}
|
||||
} catch (OrmException | ExecutionException | InterruptedException e) {
|
||||
} catch (StorageException | ExecutionException | InterruptedException e) {
|
||||
throw new IOException(e);
|
||||
}
|
||||
}
|
||||
@@ -303,10 +303,10 @@ public class LuceneChangeIndex implements ChangeIndex {
|
||||
}
|
||||
|
||||
@Override
|
||||
public ResultSet<ChangeData> read() throws OrmException {
|
||||
public ResultSet<ChangeData> read() throws StorageException {
|
||||
if (Thread.interrupted()) {
|
||||
Thread.currentThread().interrupt();
|
||||
throw new OrmException("interrupted");
|
||||
throw new StorageException("interrupted");
|
||||
}
|
||||
|
||||
final Set<String> fields = IndexUtils.changeFields(opts);
|
||||
@@ -327,12 +327,12 @@ public class LuceneChangeIndex implements ChangeIndex {
|
||||
}
|
||||
|
||||
@Override
|
||||
public ResultSet<FieldBundle> readRaw() throws OrmException {
|
||||
public ResultSet<FieldBundle> readRaw() throws StorageException {
|
||||
List<Document> documents;
|
||||
try {
|
||||
documents = doRead(IndexUtils.changeFields(opts));
|
||||
} catch (IOException e) {
|
||||
throw new OrmException(e);
|
||||
throw new StorageException(e);
|
||||
}
|
||||
ImmutableList<FieldBundle> fieldBundles =
|
||||
documents.stream().map(rawDocumentMapper).collect(toImmutableList());
|
||||
@@ -415,10 +415,10 @@ public class LuceneChangeIndex implements ChangeIndex {
|
||||
return result.build();
|
||||
} catch (InterruptedException e) {
|
||||
close();
|
||||
throw new OrmRuntimeException(e);
|
||||
throw new StorageRuntimeException(e);
|
||||
} catch (ExecutionException e) {
|
||||
Throwables.throwIfUnchecked(e.getCause());
|
||||
throw new OrmRuntimeException(e.getCause());
|
||||
throw new StorageRuntimeException(e.getCause());
|
||||
}
|
||||
}
|
||||
|
||||
|
@@ -18,6 +18,7 @@ java_library(
|
||||
"//java/com/google/gerrit/common:annotations",
|
||||
"//java/com/google/gerrit/common:server",
|
||||
"//java/com/google/gerrit/elasticsearch",
|
||||
"//java/com/google/gerrit/exceptions",
|
||||
"//java/com/google/gerrit/extensions:api",
|
||||
"//java/com/google/gerrit/gpg",
|
||||
"//java/com/google/gerrit/httpd",
|
||||
@@ -47,7 +48,6 @@ java_library(
|
||||
"//java/com/google/gerrit/server/util/time",
|
||||
"//java/com/google/gerrit/sshd",
|
||||
"//java/com/google/gerrit/util/http",
|
||||
"//java/com/google/gwtorm",
|
||||
"//lib:args4j",
|
||||
"//lib:guava",
|
||||
"//lib:protobuf",
|
||||
|
@@ -16,6 +16,7 @@ package com.google.gerrit.pgm;
|
||||
|
||||
import static com.google.gerrit.server.account.externalids.ExternalId.SCHEME_GERRIT;
|
||||
|
||||
import com.google.gerrit.exceptions.DuplicateKeyException;
|
||||
import com.google.gerrit.extensions.config.FactoryModule;
|
||||
import com.google.gerrit.lifecycle.LifecycleManager;
|
||||
import com.google.gerrit.pgm.util.SiteProgram;
|
||||
@@ -29,7 +30,6 @@ import com.google.gerrit.server.git.GitRepositoryManager;
|
||||
import com.google.gerrit.server.git.meta.MetaDataUpdate;
|
||||
import com.google.gerrit.server.index.account.AccountSchemaDefinitions;
|
||||
import com.google.gerrit.server.schema.NoteDbSchemaVersionCheck;
|
||||
import com.google.gwtorm.server.OrmDuplicateKeyException;
|
||||
import com.google.inject.Inject;
|
||||
import com.google.inject.Injector;
|
||||
import com.google.inject.Provider;
|
||||
@@ -96,7 +96,7 @@ public class LocalUsernamesToLowerCase extends SiteProgram {
|
||||
}
|
||||
|
||||
private void convertLocalUserToLowerCase(ExternalIdNotes extIdNotes, ExternalId extId)
|
||||
throws OrmDuplicateKeyException, IOException {
|
||||
throws DuplicateKeyException, IOException {
|
||||
if (extId.isScheme(SCHEME_GERRIT)) {
|
||||
String localUser = extId.key().id();
|
||||
String localUserLowerCase = localUser.toLowerCase(Locale.US);
|
||||
|
@@ -21,7 +21,6 @@ java_library(
|
||||
"//java/com/google/gerrit/server/ioutil",
|
||||
"//java/com/google/gerrit/server/schema",
|
||||
"//java/com/google/gerrit/server/util/time",
|
||||
"//java/com/google/gwtorm",
|
||||
"//lib:guava",
|
||||
"//lib:h2",
|
||||
"//lib/commons:validator",
|
||||
|
@@ -22,6 +22,7 @@ import com.google.common.base.Strings;
|
||||
import com.google.common.flogger.FluentLogger;
|
||||
import com.google.gerrit.common.Die;
|
||||
import com.google.gerrit.common.IoUtil;
|
||||
import com.google.gerrit.exceptions.StorageException;
|
||||
import com.google.gerrit.metrics.DisabledMetricMaker;
|
||||
import com.google.gerrit.metrics.MetricMaker;
|
||||
import com.google.gerrit.pgm.init.api.ConsoleUI;
|
||||
@@ -44,7 +45,6 @@ import com.google.gerrit.server.schema.UpdateUI;
|
||||
import com.google.gerrit.server.securestore.SecureStore;
|
||||
import com.google.gerrit.server.securestore.SecureStoreClassName;
|
||||
import com.google.gerrit.server.securestore.SecureStoreProvider;
|
||||
import com.google.gwtorm.server.OrmException;
|
||||
import com.google.inject.AbstractModule;
|
||||
import com.google.inject.CreationException;
|
||||
import com.google.inject.Guice;
|
||||
@@ -350,7 +350,7 @@ public class BaseInit extends SiteProgram {
|
||||
this.repositoryManager = repositoryManager;
|
||||
}
|
||||
|
||||
void upgradeSchema() throws OrmException {
|
||||
void upgradeSchema() throws StorageException {
|
||||
noteDbSchemaUpdater.update(new UpdateUIImpl(ui));
|
||||
}
|
||||
|
||||
|
@@ -14,6 +14,7 @@
|
||||
|
||||
package com.google.gerrit.pgm.init;
|
||||
|
||||
import com.google.gerrit.exceptions.StorageException;
|
||||
import com.google.gerrit.pgm.init.api.AllUsersNameOnInitProvider;
|
||||
import com.google.gerrit.pgm.init.api.InitFlags;
|
||||
import com.google.gerrit.server.GerritPersonIdentProvider;
|
||||
@@ -23,7 +24,6 @@ import com.google.gerrit.server.config.AllUsersName;
|
||||
import com.google.gerrit.server.config.SitePaths;
|
||||
import com.google.gerrit.server.extensions.events.GitReferenceUpdated;
|
||||
import com.google.gerrit.server.git.meta.MetaDataUpdate;
|
||||
import com.google.gwtorm.server.OrmException;
|
||||
import com.google.inject.Inject;
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
@@ -49,7 +49,7 @@ public class ExternalIdsOnInit {
|
||||
}
|
||||
|
||||
public synchronized void insert(String commitMessage, Collection<ExternalId> extIds)
|
||||
throws OrmException, IOException, ConfigInvalidException {
|
||||
throws StorageException, IOException, ConfigInvalidException {
|
||||
File path = getPath();
|
||||
if (path != null) {
|
||||
try (Repository allUsersRepo = new FileRepository(path)) {
|
||||
|
@@ -5,9 +5,9 @@ java_library(
|
||||
deps = [
|
||||
"//java/com/google/gerrit/common:annotations",
|
||||
"//java/com/google/gerrit/common:server",
|
||||
"//java/com/google/gerrit/exceptions",
|
||||
"//java/com/google/gerrit/reviewdb:server",
|
||||
"//java/com/google/gerrit/server",
|
||||
"//java/com/google/gwtorm",
|
||||
"//lib:guava",
|
||||
"//lib/flogger:api",
|
||||
"//lib/guice",
|
||||
|
@@ -14,12 +14,12 @@
|
||||
|
||||
package com.google.gerrit.pgm.init.api;
|
||||
|
||||
import com.google.gerrit.exceptions.StorageException;
|
||||
import com.google.gerrit.reviewdb.client.Project;
|
||||
import com.google.gerrit.server.extensions.events.GitReferenceUpdated;
|
||||
import com.google.gerrit.server.git.GitRepositoryManager;
|
||||
import com.google.gerrit.server.notedb.RepoSequence;
|
||||
import com.google.gerrit.server.notedb.Sequences;
|
||||
import com.google.gwtorm.server.OrmException;
|
||||
import com.google.inject.Inject;
|
||||
import com.google.inject.Singleton;
|
||||
|
||||
@@ -34,7 +34,7 @@ public class SequencesOnInit {
|
||||
this.allUsersName = allUsersName;
|
||||
}
|
||||
|
||||
public int nextAccountId() throws OrmException {
|
||||
public int nextAccountId() throws StorageException {
|
||||
RepoSequence accountSeq =
|
||||
new RepoSequence(
|
||||
repoManager,
|
||||
|
@@ -17,7 +17,6 @@ java_library(
|
||||
"//java/com/google/gerrit/server/restapi",
|
||||
"//java/com/google/gerrit/server/schema",
|
||||
"//java/com/google/gerrit/util/cli",
|
||||
"//java/com/google/gwtorm",
|
||||
"//lib:args4j",
|
||||
"//lib:guava",
|
||||
"//lib/flogger:api",
|
||||
|
@@ -22,6 +22,7 @@ import com.google.common.collect.ListMultimap;
|
||||
import com.google.common.collect.Table;
|
||||
import com.google.gerrit.common.Nullable;
|
||||
import com.google.gerrit.common.data.LabelType;
|
||||
import com.google.gerrit.exceptions.StorageException;
|
||||
import com.google.gerrit.extensions.client.ChangeKind;
|
||||
import com.google.gerrit.reviewdb.client.Account;
|
||||
import com.google.gerrit.reviewdb.client.PatchSet;
|
||||
@@ -32,7 +33,6 @@ import com.google.gerrit.server.notedb.ChangeNotes;
|
||||
import com.google.gerrit.server.project.ProjectCache;
|
||||
import com.google.gerrit.server.project.ProjectState;
|
||||
import com.google.gerrit.server.query.change.ChangeData;
|
||||
import com.google.gwtorm.server.OrmException;
|
||||
import com.google.inject.Inject;
|
||||
import com.google.inject.Singleton;
|
||||
import java.io.IOException;
|
||||
@@ -74,7 +74,7 @@ public class ApprovalCopier {
|
||||
|
||||
Iterable<PatchSetApproval> getForPatchSet(
|
||||
ChangeNotes notes, PatchSet.Id psId, @Nullable RevWalk rw, @Nullable Config repoConfig)
|
||||
throws OrmException {
|
||||
throws StorageException {
|
||||
return getForPatchSet(notes, psId, rw, repoConfig, Collections.emptyList());
|
||||
}
|
||||
|
||||
@@ -84,7 +84,7 @@ public class ApprovalCopier {
|
||||
@Nullable RevWalk rw,
|
||||
@Nullable Config repoConfig,
|
||||
Iterable<PatchSetApproval> dontCopy)
|
||||
throws OrmException {
|
||||
throws StorageException {
|
||||
PatchSet ps = psUtil.get(notes, psId);
|
||||
if (ps == null) {
|
||||
return Collections.emptyList();
|
||||
@@ -98,7 +98,7 @@ public class ApprovalCopier {
|
||||
@Nullable RevWalk rw,
|
||||
@Nullable Config repoConfig,
|
||||
Iterable<PatchSetApproval> dontCopy)
|
||||
throws OrmException {
|
||||
throws StorageException {
|
||||
requireNonNull(ps, "ps should not be null");
|
||||
ChangeData cd = changeDataFactory.create(notes);
|
||||
try {
|
||||
@@ -153,11 +153,11 @@ public class ApprovalCopier {
|
||||
}
|
||||
return labelNormalizer.normalize(notes, byUser.values()).getNormalized();
|
||||
} catch (IOException e) {
|
||||
throw new OrmException(e);
|
||||
throw new StorageException(e);
|
||||
}
|
||||
}
|
||||
|
||||
private static TreeMap<Integer, PatchSet> getPatchSets(ChangeData cd) throws OrmException {
|
||||
private static TreeMap<Integer, PatchSet> getPatchSets(ChangeData cd) throws StorageException {
|
||||
Collection<PatchSet> patchSets = cd.patchSets();
|
||||
TreeMap<Integer, PatchSet> result = new TreeMap<>();
|
||||
for (PatchSet ps : patchSets) {
|
||||
|
@@ -29,6 +29,7 @@ import com.google.common.primitives.Shorts;
|
||||
import com.google.gerrit.common.Nullable;
|
||||
import com.google.gerrit.common.data.LabelType;
|
||||
import com.google.gerrit.common.data.LabelTypes;
|
||||
import com.google.gerrit.exceptions.StorageException;
|
||||
import com.google.gerrit.extensions.restapi.AuthException;
|
||||
import com.google.gerrit.extensions.restapi.BadRequestException;
|
||||
import com.google.gerrit.extensions.restapi.RestApiException;
|
||||
@@ -47,7 +48,6 @@ import com.google.gerrit.server.permissions.PermissionBackend;
|
||||
import com.google.gerrit.server.permissions.PermissionBackendException;
|
||||
import com.google.gerrit.server.project.ProjectCache;
|
||||
import com.google.gerrit.server.util.LabelVote;
|
||||
import com.google.gwtorm.server.OrmException;
|
||||
import com.google.inject.Inject;
|
||||
import com.google.inject.Singleton;
|
||||
import java.io.IOException;
|
||||
@@ -112,9 +112,9 @@ public class ApprovalsUtil {
|
||||
*
|
||||
* @param notes change notes.
|
||||
* @return reviewers for the change.
|
||||
* @throws OrmException if reviewers for the change could not be read.
|
||||
* @throws StorageException if reviewers for the change could not be read.
|
||||
*/
|
||||
public ReviewerSet getReviewers(ChangeNotes notes) throws OrmException {
|
||||
public ReviewerSet getReviewers(ChangeNotes notes) throws StorageException {
|
||||
return notes.load().getReviewers();
|
||||
}
|
||||
|
||||
@@ -123,10 +123,10 @@ public class ApprovalsUtil {
|
||||
*
|
||||
* @param allApprovals all approvals to consider; must all belong to the same change.
|
||||
* @return reviewers for the change.
|
||||
* @throws OrmException if reviewers for the change could not be read.
|
||||
* @throws StorageException if reviewers for the change could not be read.
|
||||
*/
|
||||
public ReviewerSet getReviewers(ChangeNotes notes, Iterable<PatchSetApproval> allApprovals)
|
||||
throws OrmException {
|
||||
throws StorageException {
|
||||
return notes.load().getReviewers();
|
||||
}
|
||||
|
||||
@@ -135,9 +135,9 @@ public class ApprovalsUtil {
|
||||
*
|
||||
* @param notes change notes.
|
||||
* @return reviewer updates for the change.
|
||||
* @throws OrmException if reviewer updates for the change could not be read.
|
||||
* @throws StorageException if reviewer updates for the change could not be read.
|
||||
*/
|
||||
public List<ReviewerStatusUpdate> getReviewerUpdates(ChangeNotes notes) throws OrmException {
|
||||
public List<ReviewerStatusUpdate> getReviewerUpdates(ChangeNotes notes) throws StorageException {
|
||||
return notes.load().getReviewerUpdates();
|
||||
}
|
||||
|
||||
@@ -166,7 +166,7 @@ public class ApprovalsUtil {
|
||||
LabelTypes labelTypes,
|
||||
Change change,
|
||||
Iterable<Account.Id> wantReviewers)
|
||||
throws OrmException {
|
||||
throws StorageException {
|
||||
PatchSet.Id psId = change.currentPatchSetId();
|
||||
Collection<Account.Id> existingReviewers;
|
||||
existingReviewers = notes.load().getReviewers().byState(REVIEWER);
|
||||
@@ -245,10 +245,11 @@ public class ApprovalsUtil {
|
||||
* @param update change update.
|
||||
* @param wantCCs accounts to CC.
|
||||
* @return whether a change was made.
|
||||
* @throws OrmException
|
||||
* @throws StorageException
|
||||
*/
|
||||
public Collection<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());
|
||||
}
|
||||
|
||||
@@ -272,7 +273,7 @@ public class ApprovalsUtil {
|
||||
* @param user user adding approvals.
|
||||
* @param approvals approvals to add.
|
||||
* @throws RestApiException
|
||||
* @throws OrmException
|
||||
* @throws StorageException
|
||||
*/
|
||||
public Iterable<PatchSetApproval> addApprovalsForNewPatchSet(
|
||||
ChangeUpdate update,
|
||||
@@ -280,7 +281,7 @@ public class ApprovalsUtil {
|
||||
PatchSet ps,
|
||||
CurrentUser user,
|
||||
Map<String, Short> approvals)
|
||||
throws RestApiException, OrmException, PermissionBackendException {
|
||||
throws RestApiException, StorageException, PermissionBackendException {
|
||||
Account.Id accountId = user.getAccountId();
|
||||
checkArgument(
|
||||
accountId.equals(ps.getUploader()),
|
||||
@@ -331,13 +332,13 @@ public class ApprovalsUtil {
|
||||
}
|
||||
|
||||
public ListMultimap<PatchSet.Id, PatchSetApproval> byChange(ChangeNotes notes)
|
||||
throws OrmException {
|
||||
throws StorageException {
|
||||
return notes.load().getApprovals();
|
||||
}
|
||||
|
||||
public Iterable<PatchSetApproval> byPatchSet(
|
||||
ChangeNotes notes, PatchSet.Id psId, @Nullable RevWalk rw, @Nullable Config repoConfig)
|
||||
throws OrmException {
|
||||
throws StorageException {
|
||||
return copier.getForPatchSet(notes, psId, rw, repoConfig);
|
||||
}
|
||||
|
||||
@@ -347,7 +348,7 @@ public class ApprovalsUtil {
|
||||
Account.Id accountId,
|
||||
@Nullable RevWalk rw,
|
||||
@Nullable Config repoConfig)
|
||||
throws OrmException {
|
||||
throws StorageException {
|
||||
return filterApprovals(byPatchSet(notes, psId, rw, repoConfig), accountId);
|
||||
}
|
||||
|
||||
@@ -358,7 +359,7 @@ public class ApprovalsUtil {
|
||||
try {
|
||||
// Submit approval is never copied, so bypass expensive byPatchSet call.
|
||||
return getSubmitter(c, byChange(notes).get(c));
|
||||
} catch (OrmException e) {
|
||||
} catch (StorageException e) {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
@@ -18,6 +18,7 @@ import static com.google.common.base.Preconditions.checkState;
|
||||
import static java.util.Objects.requireNonNull;
|
||||
|
||||
import com.google.gerrit.common.Nullable;
|
||||
import com.google.gerrit.exceptions.StorageException;
|
||||
import com.google.gerrit.extensions.common.ChangeMessageInfo;
|
||||
import com.google.gerrit.reviewdb.client.Account;
|
||||
import com.google.gerrit.reviewdb.client.ChangeMessage;
|
||||
@@ -26,7 +27,6 @@ import com.google.gerrit.server.account.AccountLoader;
|
||||
import com.google.gerrit.server.notedb.ChangeNotes;
|
||||
import com.google.gerrit.server.notedb.ChangeUpdate;
|
||||
import com.google.gerrit.server.update.ChangeContext;
|
||||
import com.google.gwtorm.server.OrmException;
|
||||
import com.google.inject.Singleton;
|
||||
import java.sql.Timestamp;
|
||||
import java.util.List;
|
||||
@@ -87,7 +87,7 @@ public class ChangeMessagesUtil {
|
||||
return workInProgress ? TAG_UPLOADED_WIP_PATCH_SET : TAG_UPLOADED_PATCH_SET;
|
||||
}
|
||||
|
||||
public List<ChangeMessage> byChange(ChangeNotes notes) throws OrmException {
|
||||
public List<ChangeMessage> byChange(ChangeNotes notes) throws StorageException {
|
||||
return notes.load().getChangeMessages();
|
||||
}
|
||||
|
||||
|
@@ -23,6 +23,7 @@ import com.google.common.collect.FluentIterable;
|
||||
import com.google.common.collect.Lists;
|
||||
import com.google.common.collect.Ordering;
|
||||
import com.google.gerrit.common.Nullable;
|
||||
import com.google.gerrit.exceptions.StorageException;
|
||||
import com.google.gerrit.extensions.client.Side;
|
||||
import com.google.gerrit.extensions.common.CommentInfo;
|
||||
import com.google.gerrit.extensions.restapi.UnprocessableEntityException;
|
||||
@@ -42,7 +43,6 @@ import com.google.gerrit.server.notedb.ChangeUpdate;
|
||||
import com.google.gerrit.server.patch.PatchListCache;
|
||||
import com.google.gerrit.server.patch.PatchListNotAvailableException;
|
||||
import com.google.gerrit.server.update.ChangeContext;
|
||||
import com.google.gwtorm.server.OrmException;
|
||||
import com.google.inject.Inject;
|
||||
import com.google.inject.Singleton;
|
||||
import java.io.IOException;
|
||||
@@ -124,7 +124,7 @@ public class CommentsUtil {
|
||||
String message,
|
||||
@Nullable Boolean unresolved,
|
||||
@Nullable String parentUuid)
|
||||
throws OrmException, UnprocessableEntityException {
|
||||
throws StorageException, UnprocessableEntityException {
|
||||
if (unresolved == null) {
|
||||
if (parentUuid == null) {
|
||||
// Default to false if comment is not descended from another.
|
||||
@@ -175,28 +175,29 @@ public class CommentsUtil {
|
||||
return c;
|
||||
}
|
||||
|
||||
public Optional<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();
|
||||
}
|
||||
|
||||
public Optional<Comment> getDraft(ChangeNotes notes, IdentifiedUser user, Comment.Key key)
|
||||
throws OrmException {
|
||||
throws StorageException {
|
||||
return draftByChangeAuthor(notes, user.getAccountId()).stream()
|
||||
.filter(c -> key.equals(c.key))
|
||||
.findFirst();
|
||||
}
|
||||
|
||||
public List<Comment> publishedByChange(ChangeNotes notes) throws OrmException {
|
||||
public List<Comment> publishedByChange(ChangeNotes notes) throws StorageException {
|
||||
notes.load();
|
||||
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();
|
||||
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<>();
|
||||
for (Ref ref : getDraftRefs(notes.getChangeId())) {
|
||||
Account.Id account = Account.Id.fromRefSuffix(ref.getName());
|
||||
@@ -207,7 +208,7 @@ public class CommentsUtil {
|
||||
return sort(comments);
|
||||
}
|
||||
|
||||
public List<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<>();
|
||||
comments.addAll(publishedByPatchSet(notes, psId));
|
||||
|
||||
@@ -220,18 +221,19 @@ public class CommentsUtil {
|
||||
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);
|
||||
}
|
||||
|
||||
public List<Comment> publishedByPatchSet(ChangeNotes notes, PatchSet.Id psId)
|
||||
throws OrmException {
|
||||
throws StorageException {
|
||||
return removeCommentsOnAncestorOfCommitMessage(
|
||||
commentsOnPatchSet(notes.load().getComments().values(), psId));
|
||||
}
|
||||
|
||||
public List<RobotComment> robotCommentsByPatchSet(ChangeNotes notes, PatchSet.Id psId)
|
||||
throws OrmException {
|
||||
throws StorageException {
|
||||
return commentsOnPatchSet(notes.load().getRobotComments().values(), psId);
|
||||
}
|
||||
|
||||
@@ -249,17 +251,17 @@ public class CommentsUtil {
|
||||
}
|
||||
|
||||
public List<Comment> draftByPatchSetAuthor(PatchSet.Id psId, Account.Id author, ChangeNotes notes)
|
||||
throws OrmException {
|
||||
throws StorageException {
|
||||
return commentsOnPatchSet(notes.load().getDraftComments(author).values(), psId);
|
||||
}
|
||||
|
||||
public List<Comment> draftByChangeFileAuthor(ChangeNotes notes, String file, Account.Id author)
|
||||
throws OrmException {
|
||||
throws StorageException {
|
||||
return commentsOnFile(notes.load().getDraftComments(author).values(), file);
|
||||
}
|
||||
|
||||
public List<Comment> draftByChangeAuthor(ChangeNotes notes, Account.Id author)
|
||||
throws OrmException {
|
||||
throws StorageException {
|
||||
List<Comment> comments = new ArrayList<>();
|
||||
comments.addAll(notes.getDraftComments(author).values());
|
||||
return sort(comments);
|
||||
@@ -343,11 +345,11 @@ public class CommentsUtil {
|
||||
* @param changeId change ID.
|
||||
* @return raw refs from All-Users repo.
|
||||
*/
|
||||
public Collection<Ref> getDraftRefs(Change.Id changeId) throws OrmException {
|
||||
public Collection<Ref> getDraftRefs(Change.Id changeId) throws StorageException {
|
||||
try (Repository repo = repoManager.openRepository(allUsers)) {
|
||||
return getDraftRefs(repo, changeId);
|
||||
} catch (IOException e) {
|
||||
throw new OrmException(e);
|
||||
throw new StorageException(e);
|
||||
}
|
||||
}
|
||||
|
||||
|
@@ -22,6 +22,7 @@ import com.google.common.collect.ImmutableMap;
|
||||
import com.google.common.collect.Maps;
|
||||
import com.google.gerrit.common.data.LabelFunction;
|
||||
import com.google.gerrit.common.data.LabelType;
|
||||
import com.google.gerrit.exceptions.StorageException;
|
||||
import com.google.gerrit.extensions.restapi.ResourceConflictException;
|
||||
import com.google.gerrit.reviewdb.client.Change;
|
||||
import com.google.gerrit.reviewdb.client.PatchSet;
|
||||
@@ -33,7 +34,6 @@ import com.google.gerrit.server.notedb.ChangeNotes;
|
||||
import com.google.gerrit.server.notedb.ChangeUpdate;
|
||||
import com.google.gerrit.server.project.ProjectCache;
|
||||
import com.google.gerrit.server.project.ProjectState;
|
||||
import com.google.gwtorm.server.OrmException;
|
||||
import com.google.inject.Inject;
|
||||
import com.google.inject.Provider;
|
||||
import com.google.inject.Singleton;
|
||||
@@ -63,24 +63,25 @@ public class PatchSetUtil {
|
||||
this.repoManager = repoManager;
|
||||
}
|
||||
|
||||
public PatchSet current(ChangeNotes notes) throws OrmException {
|
||||
public PatchSet current(ChangeNotes notes) throws StorageException {
|
||||
return get(notes, notes.getChange().currentPatchSetId());
|
||||
}
|
||||
|
||||
public PatchSet get(ChangeNotes notes, PatchSet.Id psId) throws OrmException {
|
||||
public PatchSet get(ChangeNotes notes, PatchSet.Id psId) throws StorageException {
|
||||
return notes.load().getPatchSets().get(psId);
|
||||
}
|
||||
|
||||
public ImmutableCollection<PatchSet> byChange(ChangeNotes notes) throws OrmException {
|
||||
public ImmutableCollection<PatchSet> byChange(ChangeNotes notes) throws StorageException {
|
||||
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();
|
||||
}
|
||||
|
||||
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));
|
||||
}
|
||||
|
||||
@@ -135,7 +136,7 @@ public class PatchSetUtil {
|
||||
|
||||
/** Check if the current patch set of the change is locked. */
|
||||
public void checkPatchSetNotLocked(ChangeNotes notes)
|
||||
throws OrmException, IOException, ResourceConflictException {
|
||||
throws StorageException, IOException, ResourceConflictException {
|
||||
if (isPatchSetLocked(notes)) {
|
||||
throw new ResourceConflictException(
|
||||
String.format("The current patch set of change %s is locked", notes.getChangeId()));
|
||||
@@ -143,7 +144,7 @@ public class PatchSetUtil {
|
||||
}
|
||||
|
||||
/** Is the current patch set locked against state changes? */
|
||||
public boolean isPatchSetLocked(ChangeNotes notes) throws OrmException, IOException {
|
||||
public boolean isPatchSetLocked(ChangeNotes notes) throws StorageException, IOException {
|
||||
Change change = notes.getChange();
|
||||
if (change.isMerged()) {
|
||||
return false;
|
||||
|
@@ -19,13 +19,13 @@ import static com.google.gerrit.reviewdb.client.PatchLineComment.Status.PUBLISHE
|
||||
import static java.util.stream.Collectors.toSet;
|
||||
|
||||
import com.google.gerrit.common.Nullable;
|
||||
import com.google.gerrit.exceptions.StorageException;
|
||||
import com.google.gerrit.reviewdb.client.Comment;
|
||||
import com.google.gerrit.reviewdb.client.PatchSet;
|
||||
import com.google.gerrit.server.notedb.ChangeNotes;
|
||||
import com.google.gerrit.server.patch.PatchListCache;
|
||||
import com.google.gerrit.server.patch.PatchListNotAvailableException;
|
||||
import com.google.gerrit.server.update.ChangeContext;
|
||||
import com.google.gwtorm.server.OrmException;
|
||||
import com.google.inject.Inject;
|
||||
import com.google.inject.Singleton;
|
||||
import java.util.Collection;
|
||||
@@ -47,7 +47,7 @@ public class PublishCommentUtil {
|
||||
|
||||
public void publish(
|
||||
ChangeContext ctx, PatchSet.Id psId, Collection<Comment> drafts, @Nullable String tag)
|
||||
throws OrmException {
|
||||
throws StorageException {
|
||||
ChangeNotes notes = ctx.getNotes();
|
||||
checkArgument(notes != null);
|
||||
if (drafts.isEmpty()) {
|
||||
@@ -59,7 +59,7 @@ public class PublishCommentUtil {
|
||||
for (Comment d : drafts) {
|
||||
PatchSet ps = patchSets.get(psId(notes, d));
|
||||
if (ps == null) {
|
||||
throw new OrmException("patch set " + ps + " not found");
|
||||
throw new StorageException("patch set " + ps + " not found");
|
||||
}
|
||||
d.writtenOn = ctx.getWhen();
|
||||
d.tag = tag;
|
||||
@@ -69,7 +69,7 @@ public class PublishCommentUtil {
|
||||
try {
|
||||
CommentsUtil.setCommentRevId(d, patchListCache, notes.getChange(), ps);
|
||||
} catch (PatchListNotAvailableException e) {
|
||||
throw new OrmException(e);
|
||||
throw new StorageException(e);
|
||||
}
|
||||
}
|
||||
commentsUtil.putComments(ctx.getUpdate(psId), PUBLISHED, drafts);
|
||||
|
@@ -31,6 +31,7 @@ import com.google.common.collect.Sets;
|
||||
import com.google.common.flogger.FluentLogger;
|
||||
import com.google.common.primitives.Ints;
|
||||
import com.google.gerrit.common.Nullable;
|
||||
import com.google.gerrit.exceptions.StorageException;
|
||||
import com.google.gerrit.reviewdb.client.Account;
|
||||
import com.google.gerrit.reviewdb.client.Change;
|
||||
import com.google.gerrit.reviewdb.client.Project;
|
||||
@@ -46,7 +47,6 @@ import com.google.gerrit.server.logging.TraceContext.TraceTimer;
|
||||
import com.google.gerrit.server.project.NoSuchChangeException;
|
||||
import com.google.gerrit.server.query.change.ChangeData;
|
||||
import com.google.gerrit.server.query.change.InternalChangeQuery;
|
||||
import com.google.gwtorm.server.OrmException;
|
||||
import com.google.inject.Inject;
|
||||
import com.google.inject.Provider;
|
||||
import com.google.inject.Singleton;
|
||||
@@ -187,11 +187,11 @@ public class StarredChangesUtil {
|
||||
}
|
||||
|
||||
public ImmutableSortedSet<String> getLabels(Account.Id accountId, Change.Id changeId)
|
||||
throws OrmException {
|
||||
throws StorageException {
|
||||
try (Repository repo = repoManager.openRepository(allUsers)) {
|
||||
return readLabels(repo, RefNames.refsStarredChanges(changeId, accountId)).labels();
|
||||
} catch (IOException e) {
|
||||
throw new OrmException(
|
||||
throw new StorageException(
|
||||
String.format(
|
||||
"Reading stars from change %d for account %d failed",
|
||||
changeId.get(), accountId.get()),
|
||||
@@ -205,7 +205,7 @@ public class StarredChangesUtil {
|
||||
Change.Id changeId,
|
||||
Set<String> labelsToAdd,
|
||||
Set<String> labelsToRemove)
|
||||
throws OrmException, IllegalLabelException {
|
||||
throws StorageException, IllegalLabelException {
|
||||
try (Repository repo = repoManager.openRepository(allUsers)) {
|
||||
String refName = RefNames.refsStarredChanges(changeId, accountId);
|
||||
StarRef old = readLabels(repo, refName);
|
||||
@@ -228,13 +228,13 @@ public class StarredChangesUtil {
|
||||
indexer.index(project, changeId);
|
||||
return ImmutableSortedSet.copyOf(labels);
|
||||
} catch (IOException e) {
|
||||
throw new OrmException(
|
||||
throw new StorageException(
|
||||
String.format("Star change %d for account %d failed", changeId.get(), accountId.get()),
|
||||
e);
|
||||
}
|
||||
}
|
||||
|
||||
public void unstarAll(Project.NameKey project, Change.Id changeId) throws OrmException {
|
||||
public void unstarAll(Project.NameKey project, Change.Id changeId) throws StorageException {
|
||||
try (Repository repo = repoManager.openRepository(allUsers);
|
||||
RevWalk rw = new RevWalk(repo)) {
|
||||
BatchRefUpdate batchUpdate = repo.getRefDatabase().newBatchUpdate();
|
||||
@@ -257,11 +257,11 @@ public class StarredChangesUtil {
|
||||
}
|
||||
indexer.index(project, changeId);
|
||||
} catch (IOException e) {
|
||||
throw new OrmException(String.format("Unstar change %d failed", changeId.get()), e);
|
||||
throw new StorageException(String.format("Unstar change %d failed", changeId.get()), e);
|
||||
}
|
||||
}
|
||||
|
||||
public ImmutableMap<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)) {
|
||||
ImmutableMap.Builder<Account.Id, StarRef> builder = ImmutableMap.builder();
|
||||
for (String refPart : getRefNames(repo, RefNames.refsStarredChangesPrefix(changeId))) {
|
||||
@@ -274,13 +274,13 @@ public class StarredChangesUtil {
|
||||
}
|
||||
return builder.build();
|
||||
} catch (IOException e) {
|
||||
throw new OrmException(
|
||||
throw new StorageException(
|
||||
String.format("Get accounts that starred change %d failed", changeId.get()), e);
|
||||
}
|
||||
}
|
||||
|
||||
public ImmutableListMultimap<Account.Id, String> byChangeFromIndex(Change.Id changeId)
|
||||
throws OrmException {
|
||||
throws StorageException {
|
||||
List<ChangeData> changeData =
|
||||
queryProvider
|
||||
.get()
|
||||
@@ -311,7 +311,7 @@ public class StarredChangesUtil {
|
||||
}
|
||||
}
|
||||
|
||||
public void ignore(ChangeResource rsrc) throws OrmException, IllegalLabelException {
|
||||
public void ignore(ChangeResource rsrc) throws StorageException, IllegalLabelException {
|
||||
star(
|
||||
rsrc.getUser().asIdentifiedUser().getAccountId(),
|
||||
rsrc.getProject(),
|
||||
@@ -320,7 +320,7 @@ public class StarredChangesUtil {
|
||||
ImmutableSet.of());
|
||||
}
|
||||
|
||||
public void unignore(ChangeResource rsrc) throws OrmException, IllegalLabelException {
|
||||
public void unignore(ChangeResource rsrc) throws StorageException, IllegalLabelException {
|
||||
star(
|
||||
rsrc.getUser().asIdentifiedUser().getAccountId(),
|
||||
rsrc.getProject(),
|
||||
@@ -329,11 +329,11 @@ public class StarredChangesUtil {
|
||||
ImmutableSet.of(IGNORE_LABEL));
|
||||
}
|
||||
|
||||
public boolean isIgnoredBy(Change.Id changeId, Account.Id accountId) throws OrmException {
|
||||
public boolean isIgnoredBy(Change.Id changeId, Account.Id accountId) throws StorageException {
|
||||
return getLabels(accountId, changeId).contains(IGNORE_LABEL);
|
||||
}
|
||||
|
||||
public boolean isIgnored(ChangeResource rsrc) throws OrmException {
|
||||
public boolean isIgnored(ChangeResource rsrc) throws StorageException {
|
||||
return isIgnoredBy(rsrc.getChange().getId(), rsrc.getUser().asIdentifiedUser().getAccountId());
|
||||
}
|
||||
|
||||
@@ -353,7 +353,7 @@ public class StarredChangesUtil {
|
||||
return UNREVIEWED_LABEL + "/" + ps;
|
||||
}
|
||||
|
||||
public void markAsReviewed(ChangeResource rsrc) throws OrmException, IllegalLabelException {
|
||||
public void markAsReviewed(ChangeResource rsrc) throws StorageException, IllegalLabelException {
|
||||
star(
|
||||
rsrc.getUser().asIdentifiedUser().getAccountId(),
|
||||
rsrc.getProject(),
|
||||
@@ -362,7 +362,7 @@ public class StarredChangesUtil {
|
||||
ImmutableSet.of(getUnreviewedLabel(rsrc.getChange())));
|
||||
}
|
||||
|
||||
public void markAsUnreviewed(ChangeResource rsrc) throws OrmException, IllegalLabelException {
|
||||
public void markAsUnreviewed(ChangeResource rsrc) throws StorageException, IllegalLabelException {
|
||||
star(
|
||||
rsrc.getUser().asIdentifiedUser().getAccountId(),
|
||||
rsrc.getProject(),
|
||||
@@ -444,7 +444,7 @@ public class StarredChangesUtil {
|
||||
|
||||
private void updateLabels(
|
||||
Repository repo, String refName, ObjectId oldObjectId, Collection<String> labels)
|
||||
throws IOException, OrmException, InvalidLabelsException {
|
||||
throws IOException, StorageException, InvalidLabelsException {
|
||||
try (TraceTimer traceTimer =
|
||||
TraceContext.newTimer("Update star labels in %s (labels=%s)", refName, labels);
|
||||
RevWalk rw = new RevWalk(repo)) {
|
||||
@@ -471,14 +471,14 @@ public class StarredChangesUtil {
|
||||
case REJECTED_MISSING_OBJECT:
|
||||
case REJECTED_OTHER_REASON:
|
||||
default:
|
||||
throw new OrmException(
|
||||
throw new StorageException(
|
||||
String.format("Update star labels on ref %s failed: %s", refName, result.name()));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void deleteRef(Repository repo, String refName, ObjectId oldObjectId)
|
||||
throws IOException, OrmException {
|
||||
throws IOException, StorageException {
|
||||
if (ObjectId.zeroId().equals(oldObjectId)) {
|
||||
// ref doesn't exist
|
||||
return;
|
||||
@@ -507,7 +507,7 @@ public class StarredChangesUtil {
|
||||
case REJECTED_MISSING_OBJECT:
|
||||
case REJECTED_OTHER_REASON:
|
||||
default:
|
||||
throw new OrmException(
|
||||
throw new StorageException(
|
||||
String.format("Delete star ref %s failed: %s", refName, result.name()));
|
||||
}
|
||||
}
|
||||
|
@@ -21,6 +21,7 @@ import com.google.common.base.Strings;
|
||||
import com.google.common.collect.ImmutableList;
|
||||
import com.google.common.collect.ImmutableMap;
|
||||
import com.google.common.collect.ImmutableSet;
|
||||
import com.google.gerrit.exceptions.DuplicateKeyException;
|
||||
import com.google.gerrit.extensions.client.DiffPreferencesInfo;
|
||||
import com.google.gerrit.extensions.client.EditPreferencesInfo;
|
||||
import com.google.gerrit.extensions.client.GeneralPreferencesInfo;
|
||||
@@ -34,7 +35,6 @@ import com.google.gerrit.server.git.ValidationError;
|
||||
import com.google.gerrit.server.git.meta.MetaDataUpdate;
|
||||
import com.google.gerrit.server.git.meta.VersionedMetaData;
|
||||
import com.google.gerrit.server.util.time.TimeUtil;
|
||||
import com.google.gwtorm.server.OrmDuplicateKeyException;
|
||||
import java.io.IOException;
|
||||
import java.sql.Timestamp;
|
||||
import java.util.ArrayList;
|
||||
@@ -200,9 +200,9 @@ public class AccountConfig extends VersionedMetaData implements ValidationError.
|
||||
* Creates a new account.
|
||||
*
|
||||
* @return the new account
|
||||
* @throws OrmDuplicateKeyException if the user branch already exists
|
||||
* @throws DuplicateKeyException if the user branch already exists
|
||||
*/
|
||||
public Account getNewAccount() throws OrmDuplicateKeyException {
|
||||
public Account getNewAccount() throws DuplicateKeyException {
|
||||
return getNewAccount(TimeUtil.nowTs());
|
||||
}
|
||||
|
||||
@@ -210,12 +210,12 @@ public class AccountConfig extends VersionedMetaData implements ValidationError.
|
||||
* Creates a new account.
|
||||
*
|
||||
* @return the new account
|
||||
* @throws OrmDuplicateKeyException if the user branch already exists
|
||||
* @throws DuplicateKeyException if the user branch already exists
|
||||
*/
|
||||
Account getNewAccount(Timestamp registeredOn) throws OrmDuplicateKeyException {
|
||||
Account getNewAccount(Timestamp registeredOn) throws DuplicateKeyException {
|
||||
checkLoaded();
|
||||
if (revision != null) {
|
||||
throw new OrmDuplicateKeyException(String.format("account %s already exists", accountId));
|
||||
throw new DuplicateKeyException(String.format("account %s already exists", accountId));
|
||||
}
|
||||
this.loadedAccountProperties =
|
||||
Optional.of(new AccountProperties(accountId, registeredOn, new Config(), null));
|
||||
|
@@ -26,6 +26,7 @@ import com.google.gerrit.common.data.AccessSection;
|
||||
import com.google.gerrit.common.data.GlobalCapability;
|
||||
import com.google.gerrit.common.data.Permission;
|
||||
import com.google.gerrit.exceptions.NoSuchGroupException;
|
||||
import com.google.gerrit.exceptions.StorageException;
|
||||
import com.google.gerrit.extensions.client.AccountFieldName;
|
||||
import com.google.gerrit.reviewdb.client.Account;
|
||||
import com.google.gerrit.reviewdb.client.AccountGroup;
|
||||
@@ -42,7 +43,6 @@ import com.google.gerrit.server.group.db.InternalGroupUpdate;
|
||||
import com.google.gerrit.server.notedb.Sequences;
|
||||
import com.google.gerrit.server.project.ProjectCache;
|
||||
import com.google.gerrit.server.ssh.SshKeyCache;
|
||||
import com.google.gwtorm.server.OrmException;
|
||||
import com.google.inject.Inject;
|
||||
import com.google.inject.Provider;
|
||||
import com.google.inject.Singleton;
|
||||
@@ -163,7 +163,7 @@ public class AccountManager {
|
||||
// return the identity to the caller.
|
||||
update(who, extId);
|
||||
return new AuthResult(extId.accountId(), who.getExternalIdKey(), false);
|
||||
} catch (OrmException | ConfigInvalidException e) {
|
||||
} catch (StorageException | ConfigInvalidException e) {
|
||||
throw new AccountException("Authentication error", e);
|
||||
}
|
||||
}
|
||||
@@ -214,7 +214,7 @@ public class AccountManager {
|
||||
}
|
||||
|
||||
private void update(AuthRequest who, ExternalId extId)
|
||||
throws OrmException, IOException, ConfigInvalidException, AccountException {
|
||||
throws StorageException, IOException, ConfigInvalidException, AccountException {
|
||||
IdentifiedUser user = userFactory.create(extId.accountId());
|
||||
List<Consumer<InternalAccountUpdate.Builder>> accountUpdates = new ArrayList<>();
|
||||
|
||||
@@ -266,12 +266,12 @@ public class AccountManager {
|
||||
user.getAccountId(),
|
||||
AccountUpdater.joinConsumers(accountUpdates))
|
||||
.orElseThrow(
|
||||
() -> new OrmException("Account " + user.getAccountId() + " has been deleted"));
|
||||
() -> new StorageException("Account " + user.getAccountId() + " has been deleted"));
|
||||
}
|
||||
}
|
||||
|
||||
private AuthResult create(AuthRequest who)
|
||||
throws OrmException, AccountException, IOException, ConfigInvalidException {
|
||||
throws StorageException, AccountException, IOException, ConfigInvalidException {
|
||||
Account.Id newId = new Account.Id(sequences.nextAccountId());
|
||||
logger.atFine().log("Assigning new Id %s to account", newId);
|
||||
|
||||
@@ -375,7 +375,7 @@ public class AccountManager {
|
||||
}
|
||||
|
||||
private void addGroupMember(AccountGroup.UUID groupUuid, IdentifiedUser user)
|
||||
throws OrmException, IOException, ConfigInvalidException, AccountException {
|
||||
throws StorageException, IOException, ConfigInvalidException, AccountException {
|
||||
// The user initiated this request by logging in. -> Attribute all modifications to that user.
|
||||
GroupsUpdate groupsUpdate = groupsUpdateFactory.create(user);
|
||||
InternalGroupUpdate groupUpdate =
|
||||
@@ -400,7 +400,7 @@ public class AccountManager {
|
||||
* this time.
|
||||
*/
|
||||
public AuthResult link(Account.Id to, AuthRequest who)
|
||||
throws AccountException, OrmException, IOException, ConfigInvalidException {
|
||||
throws AccountException, StorageException, IOException, ConfigInvalidException {
|
||||
Optional<ExternalId> optionalExtId = externalIds.get(who.getExternalIdKey());
|
||||
if (optionalExtId.isPresent()) {
|
||||
ExternalId extId = optionalExtId.get();
|
||||
@@ -437,12 +437,12 @@ public class AccountManager {
|
||||
* @param to account to link the identity onto.
|
||||
* @param who the additional identity.
|
||||
* @return the result of linking the identity to the user.
|
||||
* @throws OrmException
|
||||
* @throws StorageException
|
||||
* @throws AccountException the identity belongs to a different account, or it cannot be linked at
|
||||
* this time.
|
||||
*/
|
||||
public AuthResult updateLink(Account.Id to, AuthRequest who)
|
||||
throws OrmException, AccountException, IOException, ConfigInvalidException {
|
||||
throws StorageException, AccountException, IOException, ConfigInvalidException {
|
||||
accountsUpdateProvider
|
||||
.get()
|
||||
.update(
|
||||
@@ -474,7 +474,7 @@ public class AccountManager {
|
||||
* found
|
||||
*/
|
||||
public void unlink(Account.Id from, ExternalId.Key extIdKey)
|
||||
throws AccountException, OrmException, IOException, ConfigInvalidException {
|
||||
throws AccountException, StorageException, IOException, ConfigInvalidException {
|
||||
unlink(from, ImmutableList.of(extIdKey));
|
||||
}
|
||||
|
||||
@@ -487,7 +487,7 @@ public class AccountManager {
|
||||
* identity was not found
|
||||
*/
|
||||
public void unlink(Account.Id from, Collection<ExternalId.Key> extIdKeys)
|
||||
throws AccountException, OrmException, IOException, ConfigInvalidException {
|
||||
throws AccountException, StorageException, IOException, ConfigInvalidException {
|
||||
if (extIdKeys.isEmpty()) {
|
||||
return;
|
||||
}
|
||||
|
@@ -26,6 +26,7 @@ import com.google.common.base.Suppliers;
|
||||
import com.google.common.collect.ImmutableList;
|
||||
import com.google.common.collect.ImmutableSet;
|
||||
import com.google.common.collect.Streams;
|
||||
import com.google.gerrit.exceptions.StorageException;
|
||||
import com.google.gerrit.extensions.restapi.UnprocessableEntityException;
|
||||
import com.google.gerrit.index.Schema;
|
||||
import com.google.gerrit.reviewdb.client.Account;
|
||||
@@ -34,7 +35,6 @@ import com.google.gerrit.server.IdentifiedUser;
|
||||
import com.google.gerrit.server.account.externalids.ExternalId;
|
||||
import com.google.gerrit.server.config.AnonymousCowardName;
|
||||
import com.google.gerrit.server.query.account.InternalAccountQuery;
|
||||
import com.google.gwtorm.server.OrmException;
|
||||
import com.google.inject.Inject;
|
||||
import com.google.inject.Provider;
|
||||
import com.google.inject.Singleton;
|
||||
@@ -216,14 +216,15 @@ public class AccountResolver {
|
||||
return false;
|
||||
}
|
||||
|
||||
Optional<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();
|
||||
|
||||
default Optional<Stream<AccountState>> trySearch(String input)
|
||||
throws OrmException, IOException, ConfigInvalidException {
|
||||
throws StorageException, IOException, ConfigInvalidException {
|
||||
Optional<I> parsed = tryParse(input);
|
||||
return parsed.isPresent() ? Optional.of(search(parsed.get())) : Optional.empty();
|
||||
}
|
||||
@@ -335,7 +336,7 @@ public class AccountResolver {
|
||||
}
|
||||
|
||||
@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>
|
||||
int lt = nameOrEmail.indexOf('<');
|
||||
int gt = nameOrEmail.indexOf('>');
|
||||
@@ -368,7 +369,7 @@ public class AccountResolver {
|
||||
}
|
||||
|
||||
@Override
|
||||
public Stream<AccountState> search(String input) throws OrmException, IOException {
|
||||
public Stream<AccountState> search(String input) throws StorageException, IOException {
|
||||
return toAccountStates(emails.getAccountFor(input));
|
||||
}
|
||||
|
||||
@@ -397,7 +398,7 @@ public class AccountResolver {
|
||||
}
|
||||
|
||||
@Override
|
||||
public Optional<AccountState> tryParse(String input) throws OrmException {
|
||||
public Optional<AccountState> tryParse(String input) throws StorageException {
|
||||
List<AccountState> results =
|
||||
accountQueryProvider.get().enforceVisibility(true).byFullName(input);
|
||||
return results.size() == 1 ? Optional.of(results.get(0)) : Optional.empty();
|
||||
@@ -426,7 +427,7 @@ public class AccountResolver {
|
||||
}
|
||||
|
||||
@Override
|
||||
public Stream<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
|
||||
// up with a reasonable result list.
|
||||
// TODO(dborowitz): This doesn't match the documentation; consider whether it's possible to be
|
||||
@@ -513,11 +514,11 @@ public class AccountResolver {
|
||||
*
|
||||
* @param input input string.
|
||||
* @return a result describing matching accounts. Never null even if the result set is empty.
|
||||
* @throws OrmException if an error occurs.
|
||||
* @throws StorageException if an error occurs.
|
||||
* @throws ConfigInvalidException if an error occurs.
|
||||
* @throws IOException if an error occurs.
|
||||
*/
|
||||
public Result resolve(String input) throws OrmException, ConfigInvalidException, IOException {
|
||||
public Result resolve(String input) throws StorageException, ConfigInvalidException, IOException {
|
||||
return searchImpl(input, searchers, visibilitySupplier());
|
||||
}
|
||||
|
||||
@@ -539,7 +540,7 @@ public class AccountResolver {
|
||||
*
|
||||
* @param input input string.
|
||||
* @return a result describing matching accounts. Never null even if the result set is empty.
|
||||
* @throws OrmException if an error occurs.
|
||||
* @throws StorageException if an error occurs.
|
||||
* @throws ConfigInvalidException if an error occurs.
|
||||
* @throws IOException if an error occurs.
|
||||
* @deprecated for use only by MailUtil for parsing commit footers; that class needs to be
|
||||
@@ -547,7 +548,7 @@ public class AccountResolver {
|
||||
*/
|
||||
@Deprecated
|
||||
public Result resolveByNameOrEmail(String input)
|
||||
throws OrmException, ConfigInvalidException, IOException {
|
||||
throws StorageException, ConfigInvalidException, IOException {
|
||||
return searchImpl(input, nameOrEmailSearchers, visibilitySupplier());
|
||||
}
|
||||
|
||||
@@ -560,7 +561,7 @@ public class AccountResolver {
|
||||
String input,
|
||||
ImmutableList<Searcher<?>> searchers,
|
||||
Supplier<Predicate<AccountState>> visibilitySupplier)
|
||||
throws OrmException, ConfigInvalidException, IOException {
|
||||
throws StorageException, ConfigInvalidException, IOException {
|
||||
visibilitySupplier = Suppliers.memoize(visibilitySupplier::get);
|
||||
List<AccountState> inactive = new ArrayList<>();
|
||||
|
||||
|
@@ -24,6 +24,8 @@ import com.google.common.base.Throwables;
|
||||
import com.google.common.collect.Iterables;
|
||||
import com.google.common.collect.Lists;
|
||||
import com.google.common.util.concurrent.Runnables;
|
||||
import com.google.gerrit.exceptions.DuplicateKeyException;
|
||||
import com.google.gerrit.exceptions.StorageException;
|
||||
import com.google.gerrit.git.LockFailureException;
|
||||
import com.google.gerrit.git.RefUpdateUtil;
|
||||
import com.google.gerrit.reviewdb.client.Account;
|
||||
@@ -41,8 +43,6 @@ import com.google.gerrit.server.notedb.Sequences;
|
||||
import com.google.gerrit.server.update.RetryHelper;
|
||||
import com.google.gerrit.server.update.RetryHelper.Action;
|
||||
import com.google.gerrit.server.update.RetryHelper.ActionType;
|
||||
import com.google.gwtorm.server.OrmDuplicateKeyException;
|
||||
import com.google.gwtorm.server.OrmException;
|
||||
import com.google.inject.Provider;
|
||||
import com.google.inject.assistedinject.Assisted;
|
||||
import com.google.inject.assistedinject.AssistedInject;
|
||||
@@ -293,14 +293,14 @@ public class AccountsUpdate {
|
||||
* @param accountId ID of the new account
|
||||
* @param init consumer to populate the new account
|
||||
* @return the newly created account
|
||||
* @throws OrmDuplicateKeyException if the account already exists
|
||||
* @throws DuplicateKeyException if the account already exists
|
||||
* @throws IOException if creating the user branch fails due to an IO error
|
||||
* @throws OrmException if creating the user branch fails
|
||||
* @throws StorageException if creating the user branch fails
|
||||
* @throws ConfigInvalidException if any of the account fields has an invalid value
|
||||
*/
|
||||
public AccountState insert(
|
||||
String message, Account.Id accountId, Consumer<InternalAccountUpdate.Builder> init)
|
||||
throws OrmException, IOException, ConfigInvalidException {
|
||||
throws StorageException, IOException, ConfigInvalidException {
|
||||
return insert(message, accountId, AccountUpdater.fromConsumer(init));
|
||||
}
|
||||
|
||||
@@ -311,13 +311,13 @@ public class AccountsUpdate {
|
||||
* @param accountId ID of the new account
|
||||
* @param updater updater to populate the new account
|
||||
* @return the newly created account
|
||||
* @throws OrmDuplicateKeyException if the account already exists
|
||||
* @throws DuplicateKeyException if the account already exists
|
||||
* @throws IOException if creating the user branch fails due to an IO error
|
||||
* @throws OrmException if creating the user branch fails
|
||||
* @throws StorageException if creating the user branch fails
|
||||
* @throws ConfigInvalidException if any of the account fields has an invalid value
|
||||
*/
|
||||
public AccountState insert(String message, Account.Id accountId, AccountUpdater updater)
|
||||
throws OrmException, IOException, ConfigInvalidException {
|
||||
throws StorageException, IOException, ConfigInvalidException {
|
||||
return updateAccount(
|
||||
r -> {
|
||||
AccountConfig accountConfig = read(r, accountId);
|
||||
@@ -351,12 +351,12 @@ public class AccountsUpdate {
|
||||
* @throws IOException if updating the user branch fails due to an IO error
|
||||
* @throws LockFailureException if updating the user branch still fails due to concurrent updates
|
||||
* after the retry timeout exceeded
|
||||
* @throws OrmException if updating the user branch fails
|
||||
* @throws StorageException if updating the user branch fails
|
||||
* @throws ConfigInvalidException if any of the account fields has an invalid value
|
||||
*/
|
||||
public Optional<AccountState> 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));
|
||||
}
|
||||
|
||||
@@ -372,11 +372,11 @@ public class AccountsUpdate {
|
||||
* @throws IOException if updating the user branch fails due to an IO error
|
||||
* @throws LockFailureException if updating the user branch still fails due to concurrent updates
|
||||
* after the retry timeout exceeded
|
||||
* @throws OrmException if updating the user branch fails
|
||||
* @throws StorageException if updating the user branch fails
|
||||
* @throws ConfigInvalidException if any of the account fields has an invalid value
|
||||
*/
|
||||
public Optional<AccountState> update(String message, Account.Id accountId, AccountUpdater updater)
|
||||
throws OrmException, LockFailureException, IOException, ConfigInvalidException {
|
||||
throws StorageException, LockFailureException, IOException, ConfigInvalidException {
|
||||
return updateAccount(
|
||||
r -> {
|
||||
AccountConfig accountConfig = read(r, accountId);
|
||||
@@ -407,7 +407,7 @@ public class AccountsUpdate {
|
||||
}
|
||||
|
||||
private Optional<AccountState> updateAccount(AccountUpdate accountUpdate)
|
||||
throws IOException, ConfigInvalidException, OrmException {
|
||||
throws IOException, ConfigInvalidException, StorageException {
|
||||
return executeAccountUpdate(
|
||||
() -> {
|
||||
try (Repository allUsersRepo = repoManager.openRepository(allUsersName)) {
|
||||
@@ -423,7 +423,7 @@ public class AccountsUpdate {
|
||||
}
|
||||
|
||||
private Optional<AccountState> executeAccountUpdate(Action<Optional<AccountState>> action)
|
||||
throws IOException, ConfigInvalidException, OrmException {
|
||||
throws IOException, ConfigInvalidException, StorageException {
|
||||
try {
|
||||
return retryHelper.execute(
|
||||
ActionType.ACCOUNT_UPDATE, action, LockFailureException.class::isInstance);
|
||||
@@ -431,8 +431,8 @@ public class AccountsUpdate {
|
||||
Throwables.throwIfUnchecked(e);
|
||||
Throwables.throwIfInstanceOf(e, IOException.class);
|
||||
Throwables.throwIfInstanceOf(e, ConfigInvalidException.class);
|
||||
Throwables.throwIfInstanceOf(e, OrmException.class);
|
||||
throw new OrmException(e);
|
||||
Throwables.throwIfInstanceOf(e, StorageException.class);
|
||||
throw new StorageException(e);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -441,7 +441,7 @@ public class AccountsUpdate {
|
||||
Optional<ObjectId> rev,
|
||||
Account.Id accountId,
|
||||
InternalAccountUpdate update)
|
||||
throws IOException, ConfigInvalidException, OrmDuplicateKeyException {
|
||||
throws IOException, ConfigInvalidException, DuplicateKeyException {
|
||||
ExternalIdNotes.checkSameAccount(
|
||||
Iterables.concat(
|
||||
update.getCreatedExternalIds(),
|
||||
@@ -563,7 +563,7 @@ public class AccountsUpdate {
|
||||
@FunctionalInterface
|
||||
private static interface AccountUpdate {
|
||||
UpdatedAccount update(Repository allUsersRepo)
|
||||
throws IOException, ConfigInvalidException, OrmException;
|
||||
throws IOException, ConfigInvalidException, StorageException;
|
||||
}
|
||||
|
||||
private static class UpdatedAccount {
|
||||
|
@@ -16,11 +16,11 @@ package com.google.gerrit.server.account;
|
||||
|
||||
import com.google.common.annotations.VisibleForTesting;
|
||||
import com.google.common.base.Strings;
|
||||
import com.google.gerrit.exceptions.StorageException;
|
||||
import com.google.gerrit.extensions.client.AccountFieldName;
|
||||
import com.google.gerrit.extensions.client.AuthType;
|
||||
import com.google.gerrit.reviewdb.client.Account;
|
||||
import com.google.gerrit.server.config.AuthConfig;
|
||||
import com.google.gwtorm.server.OrmException;
|
||||
import com.google.inject.Inject;
|
||||
import com.google.inject.Provider;
|
||||
import com.google.inject.Singleton;
|
||||
@@ -87,7 +87,7 @@ public class DefaultRealm extends AbstractRealm {
|
||||
if (1 == c.size()) {
|
||||
return c.iterator().next();
|
||||
}
|
||||
} catch (OrmException e) {
|
||||
} catch (StorageException e) {
|
||||
throw new IOException("Failed to query accounts by email", e);
|
||||
}
|
||||
}
|
||||
|
@@ -20,6 +20,7 @@ import com.google.common.base.Throwables;
|
||||
import com.google.common.collect.ImmutableSet;
|
||||
import com.google.common.collect.ImmutableSetMultimap;
|
||||
import com.google.common.collect.Streams;
|
||||
import com.google.gerrit.exceptions.StorageException;
|
||||
import com.google.gerrit.reviewdb.client.Account;
|
||||
import com.google.gerrit.server.account.externalids.ExternalId;
|
||||
import com.google.gerrit.server.account.externalids.ExternalIds;
|
||||
@@ -27,7 +28,6 @@ import com.google.gerrit.server.query.account.InternalAccountQuery;
|
||||
import com.google.gerrit.server.update.RetryHelper;
|
||||
import com.google.gerrit.server.update.RetryHelper.Action;
|
||||
import com.google.gerrit.server.update.RetryHelper.ActionType;
|
||||
import com.google.gwtorm.server.OrmException;
|
||||
import com.google.inject.Inject;
|
||||
import com.google.inject.Provider;
|
||||
import com.google.inject.Singleton;
|
||||
@@ -69,7 +69,7 @@ public class Emails {
|
||||
*
|
||||
* @see #getAccountsFor(String...)
|
||||
*/
|
||||
public ImmutableSet<Account.Id> getAccountFor(String email) throws IOException, OrmException {
|
||||
public ImmutableSet<Account.Id> getAccountFor(String email) throws IOException, StorageException {
|
||||
return Streams.concat(
|
||||
externalIds.byEmail(email).stream().map(ExternalId::accountId),
|
||||
executeIndexQuery(() -> queryProvider.get().byPreferredEmail(email).stream())
|
||||
@@ -83,7 +83,7 @@ public class Emails {
|
||||
* @see #getAccountFor(String)
|
||||
*/
|
||||
public ImmutableSetMultimap<String, Account.Id> getAccountsFor(String... emails)
|
||||
throws IOException, OrmException {
|
||||
throws IOException, StorageException {
|
||||
ImmutableSetMultimap.Builder<String, Account.Id> builder = ImmutableSetMultimap.builder();
|
||||
externalIds.byEmails(emails).entries().stream()
|
||||
.forEach(e -> builder.put(e.getKey(), e.getValue().accountId()));
|
||||
@@ -102,13 +102,14 @@ public class Emails {
|
||||
return externalIds.byEmail(email).stream().map(ExternalId::accountId).collect(toImmutableSet());
|
||||
}
|
||||
|
||||
private <T> T executeIndexQuery(Action<T> action) throws OrmException {
|
||||
private <T> T executeIndexQuery(Action<T> action) throws StorageException {
|
||||
try {
|
||||
return retryHelper.execute(ActionType.INDEX_QUERY, action, OrmException.class::isInstance);
|
||||
return retryHelper.execute(
|
||||
ActionType.INDEX_QUERY, action, StorageException.class::isInstance);
|
||||
} catch (Exception e) {
|
||||
Throwables.throwIfUnchecked(e);
|
||||
Throwables.throwIfInstanceOf(e, OrmException.class);
|
||||
throw new OrmException(e);
|
||||
Throwables.throwIfInstanceOf(e, StorageException.class);
|
||||
throw new StorageException(e);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@@ -22,6 +22,7 @@ import com.google.common.cache.LoadingCache;
|
||||
import com.google.common.collect.ImmutableList;
|
||||
import com.google.common.collect.ImmutableSet;
|
||||
import com.google.common.flogger.FluentLogger;
|
||||
import com.google.gerrit.exceptions.StorageException;
|
||||
import com.google.gerrit.reviewdb.client.Account;
|
||||
import com.google.gerrit.reviewdb.client.AccountGroup;
|
||||
import com.google.gerrit.server.cache.CacheModule;
|
||||
@@ -30,7 +31,6 @@ import com.google.gerrit.server.group.db.Groups;
|
||||
import com.google.gerrit.server.logging.TraceContext;
|
||||
import com.google.gerrit.server.logging.TraceContext.TraceTimer;
|
||||
import com.google.gerrit.server.query.group.InternalGroupQuery;
|
||||
import com.google.gwtorm.server.OrmException;
|
||||
import com.google.inject.Inject;
|
||||
import com.google.inject.Module;
|
||||
import com.google.inject.Provider;
|
||||
@@ -152,7 +152,7 @@ public class GroupIncludeCacheImpl implements GroupIncludeCache {
|
||||
}
|
||||
|
||||
@Override
|
||||
public ImmutableSet<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)) {
|
||||
return groupQueryProvider.get().byMember(memberId).stream()
|
||||
.map(InternalGroup::getGroupUUID)
|
||||
@@ -171,7 +171,7 @@ public class GroupIncludeCacheImpl implements GroupIncludeCache {
|
||||
}
|
||||
|
||||
@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)) {
|
||||
return groupQueryProvider.get().bySubgroup(key).stream()
|
||||
.map(InternalGroup::getGroupUUID)
|
||||
|
@@ -14,6 +14,7 @@
|
||||
|
||||
package com.google.gerrit.server.account;
|
||||
|
||||
import com.google.gerrit.exceptions.StorageException;
|
||||
import com.google.gerrit.extensions.restapi.ResourceConflictException;
|
||||
import com.google.gerrit.extensions.restapi.ResourceNotFoundException;
|
||||
import com.google.gerrit.extensions.restapi.Response;
|
||||
@@ -23,7 +24,6 @@ import com.google.gerrit.server.ServerInitiated;
|
||||
import com.google.gerrit.server.plugincontext.PluginSetContext;
|
||||
import com.google.gerrit.server.validators.AccountActivationValidationListener;
|
||||
import com.google.gerrit.server.validators.ValidationException;
|
||||
import com.google.gwtorm.server.OrmException;
|
||||
import com.google.inject.Inject;
|
||||
import com.google.inject.Provider;
|
||||
import com.google.inject.Singleton;
|
||||
@@ -48,7 +48,7 @@ public class SetInactiveFlag {
|
||||
}
|
||||
|
||||
public Response<?> deactivate(Account.Id accountId)
|
||||
throws RestApiException, IOException, ConfigInvalidException, OrmException {
|
||||
throws RestApiException, IOException, ConfigInvalidException, StorageException {
|
||||
AtomicBoolean alreadyInactive = new AtomicBoolean(false);
|
||||
AtomicReference<Optional<RestApiException>> exception = new AtomicReference<>(Optional.empty());
|
||||
accountsUpdateProvider
|
||||
@@ -81,7 +81,7 @@ public class SetInactiveFlag {
|
||||
}
|
||||
|
||||
public Response<String> activate(Account.Id accountId)
|
||||
throws RestApiException, IOException, ConfigInvalidException, OrmException {
|
||||
throws RestApiException, IOException, ConfigInvalidException, StorageException {
|
||||
AtomicBoolean alreadyActive = new AtomicBoolean(false);
|
||||
AtomicReference<Optional<RestApiException>> exception = new AtomicReference<>(Optional.empty());
|
||||
accountsUpdateProvider
|
||||
|
@@ -14,13 +14,13 @@
|
||||
|
||||
package com.google.gerrit.server.account.externalids;
|
||||
|
||||
import com.google.gwtorm.server.OrmDuplicateKeyException;
|
||||
import com.google.gerrit.exceptions.DuplicateKeyException;
|
||||
|
||||
/**
|
||||
* Exception that is thrown if an external ID cannot be inserted because an external ID with the
|
||||
* same key already exists.
|
||||
*/
|
||||
public class DuplicateExternalIdKeyException extends OrmDuplicateKeyException {
|
||||
public class DuplicateExternalIdKeyException extends DuplicateKeyException {
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
private final ExternalId.Key duplicateKey;
|
||||
|
@@ -7,13 +7,13 @@ java_library(
|
||||
deps = [
|
||||
"//java/com/google/gerrit/common:annotations",
|
||||
"//java/com/google/gerrit/common:server",
|
||||
"//java/com/google/gerrit/exceptions",
|
||||
"//java/com/google/gerrit/extensions:api",
|
||||
"//java/com/google/gerrit/lifecycle",
|
||||
"//java/com/google/gerrit/reviewdb:server",
|
||||
"//java/com/google/gerrit/server",
|
||||
"//java/com/google/gerrit/server/restapi",
|
||||
"//java/com/google/gerrit/util/cli",
|
||||
"//java/com/google/gwtorm",
|
||||
"//lib:args4j",
|
||||
"//lib:guava",
|
||||
"//lib:servlet-api-3_1",
|
||||
|
@@ -19,6 +19,7 @@ import static com.google.gerrit.server.api.ApiUtil.asRestApiException;
|
||||
import com.google.common.collect.ImmutableListMultimap;
|
||||
import com.google.common.collect.ListMultimap;
|
||||
import com.google.gerrit.common.Nullable;
|
||||
import com.google.gerrit.exceptions.StorageException;
|
||||
import com.google.gerrit.extensions.api.changes.AbandonInput;
|
||||
import com.google.gerrit.extensions.api.changes.AddReviewerInput;
|
||||
import com.google.gerrit.extensions.api.changes.AddReviewerResult;
|
||||
@@ -103,7 +104,6 @@ import com.google.gerrit.server.restapi.change.SubmittedTogether;
|
||||
import com.google.gerrit.server.restapi.change.SuggestChangeReviewers;
|
||||
import com.google.gerrit.server.restapi.change.Unignore;
|
||||
import com.google.gerrit.util.cli.CmdLineParser;
|
||||
import com.google.gwtorm.server.OrmException;
|
||||
import com.google.inject.Inject;
|
||||
import com.google.inject.Injector;
|
||||
import com.google.inject.Provider;
|
||||
@@ -613,7 +613,7 @@ class ChangeApiImpl implements ChangeApi {
|
||||
} else {
|
||||
unignore.apply(change, new Input());
|
||||
}
|
||||
} catch (OrmException | IllegalLabelException e) {
|
||||
} catch (StorageException | IllegalLabelException e) {
|
||||
throw asRestApiException("Cannot ignore change", e);
|
||||
}
|
||||
}
|
||||
@@ -622,7 +622,7 @@ class ChangeApiImpl implements ChangeApi {
|
||||
public boolean ignored() throws RestApiException {
|
||||
try {
|
||||
return stars.isIgnored(change);
|
||||
} catch (OrmException e) {
|
||||
} catch (StorageException e) {
|
||||
throw asRestApiException("Cannot check if ignored", e);
|
||||
}
|
||||
}
|
||||
@@ -637,7 +637,7 @@ class ChangeApiImpl implements ChangeApi {
|
||||
} else {
|
||||
markAsUnreviewed.apply(change, new Input());
|
||||
}
|
||||
} catch (OrmException | IllegalLabelException e) {
|
||||
} catch (StorageException | IllegalLabelException e) {
|
||||
throw asRestApiException(
|
||||
"Cannot mark change as " + (reviewed ? "reviewed" : "unreviewed"), e);
|
||||
}
|
||||
|
@@ -16,6 +16,7 @@ package com.google.gerrit.server.api.changes;
|
||||
|
||||
import static com.google.gerrit.server.api.ApiUtil.asRestApiException;
|
||||
|
||||
import com.google.gerrit.exceptions.StorageException;
|
||||
import com.google.gerrit.extensions.api.changes.ChangeEditApi;
|
||||
import com.google.gerrit.extensions.api.changes.PublishChangeEditInput;
|
||||
import com.google.gerrit.extensions.client.ChangeEditDetailOption;
|
||||
@@ -34,7 +35,6 @@ import com.google.gerrit.server.restapi.change.ChangeEdits;
|
||||
import com.google.gerrit.server.restapi.change.DeleteChangeEdit;
|
||||
import com.google.gerrit.server.restapi.change.PublishChangeEdit;
|
||||
import com.google.gerrit.server.restapi.change.RebaseChangeEdit;
|
||||
import com.google.gwtorm.server.OrmException;
|
||||
import com.google.inject.Inject;
|
||||
import com.google.inject.Provider;
|
||||
import com.google.inject.assistedinject.Assisted;
|
||||
@@ -242,7 +242,7 @@ public class ChangeEditApiImpl implements ChangeEditApi {
|
||||
}
|
||||
|
||||
private ChangeEditResource getChangeEditResource(String filePath)
|
||||
throws ResourceNotFoundException, AuthException, IOException, OrmException {
|
||||
throws ResourceNotFoundException, AuthException, IOException, StorageException {
|
||||
return changeEdits.parse(changeResource, IdString.fromDecoded(filePath));
|
||||
}
|
||||
}
|
||||
|
@@ -16,6 +16,7 @@ package com.google.gerrit.server.api.projects;
|
||||
|
||||
import static com.google.gerrit.server.api.ApiUtil.asRestApiException;
|
||||
|
||||
import com.google.gerrit.exceptions.StorageException;
|
||||
import com.google.gerrit.extensions.api.projects.ProjectApi;
|
||||
import com.google.gerrit.extensions.api.projects.ProjectInput;
|
||||
import com.google.gerrit.extensions.api.projects.Projects;
|
||||
@@ -28,7 +29,6 @@ import com.google.gerrit.server.restapi.project.ListProjects;
|
||||
import com.google.gerrit.server.restapi.project.ListProjects.FilterType;
|
||||
import com.google.gerrit.server.restapi.project.ProjectsCollection;
|
||||
import com.google.gerrit.server.restapi.project.QueryProjects;
|
||||
import com.google.gwtorm.server.OrmException;
|
||||
import com.google.inject.Inject;
|
||||
import com.google.inject.Provider;
|
||||
import com.google.inject.Singleton;
|
||||
@@ -155,7 +155,7 @@ class ProjectsImpl implements Projects {
|
||||
.withLimit(r.getLimit())
|
||||
.withStart(r.getStart())
|
||||
.apply();
|
||||
} catch (OrmException e) {
|
||||
} catch (StorageException e) {
|
||||
throw new RestApiException("Cannot query projects", e);
|
||||
}
|
||||
}
|
||||
|
@@ -16,6 +16,7 @@ package com.google.gerrit.server.args4j;
|
||||
|
||||
import static com.google.gerrit.util.cli.Localizable.localizable;
|
||||
|
||||
import com.google.gerrit.exceptions.StorageException;
|
||||
import com.google.gerrit.extensions.client.AuthType;
|
||||
import com.google.gerrit.extensions.restapi.UnprocessableEntityException;
|
||||
import com.google.gerrit.reviewdb.client.Account;
|
||||
@@ -25,7 +26,6 @@ import com.google.gerrit.server.account.AccountResolver;
|
||||
import com.google.gerrit.server.account.AuthRequest;
|
||||
import com.google.gerrit.server.account.externalids.ExternalId;
|
||||
import com.google.gerrit.server.config.AuthConfig;
|
||||
import com.google.gwtorm.server.OrmException;
|
||||
import com.google.inject.Inject;
|
||||
import com.google.inject.assistedinject.Assisted;
|
||||
import java.io.IOException;
|
||||
@@ -81,7 +81,7 @@ public class AccountIdHandler extends OptionHandler<Account.Id> {
|
||||
throw new CmdLineException(owner, localizable("user \"%s\" not found"), token);
|
||||
}
|
||||
}
|
||||
} catch (OrmException e) {
|
||||
} catch (StorageException e) {
|
||||
throw new CmdLineException(owner, localizable("database is down"));
|
||||
} catch (IOException e) {
|
||||
throw new CmdLineException(owner, "Failed to load account", e);
|
||||
|
@@ -17,12 +17,12 @@ package com.google.gerrit.server.args4j;
|
||||
import static com.google.gerrit.util.cli.Localizable.localizable;
|
||||
|
||||
import com.google.common.base.Splitter;
|
||||
import com.google.gerrit.exceptions.StorageException;
|
||||
import com.google.gerrit.reviewdb.client.Branch;
|
||||
import com.google.gerrit.reviewdb.client.Change;
|
||||
import com.google.gerrit.reviewdb.client.Project;
|
||||
import com.google.gerrit.server.query.change.ChangeData;
|
||||
import com.google.gerrit.server.query.change.InternalChangeQuery;
|
||||
import com.google.gwtorm.server.OrmException;
|
||||
import com.google.inject.Inject;
|
||||
import com.google.inject.Provider;
|
||||
import com.google.inject.assistedinject.Assisted;
|
||||
@@ -67,7 +67,7 @@ public class ChangeIdHandler extends OptionHandler<Change.Id> {
|
||||
}
|
||||
} catch (IllegalArgumentException e) {
|
||||
throw new CmdLineException(owner, localizable("Change-Id is not valid"));
|
||||
} catch (OrmException e) {
|
||||
} catch (StorageException e) {
|
||||
throw new CmdLineException(owner, localizable("Database error: %s"), e.getMessage());
|
||||
}
|
||||
|
||||
|
@@ -21,7 +21,6 @@ java_library(
|
||||
"//java/com/google/gerrit/server/util/time",
|
||||
"//java/com/google/gerrit/util/cli",
|
||||
"//java/com/google/gerrit/util/ssl",
|
||||
"//java/com/google/gwtorm",
|
||||
"//java/org/apache/commons/net",
|
||||
"//java/org/eclipse/jgit:server",
|
||||
"//lib:args4j",
|
||||
|
@@ -17,6 +17,7 @@ package com.google.gerrit.server.change;
|
||||
import com.google.common.base.Strings;
|
||||
import com.google.common.flogger.FluentLogger;
|
||||
import com.google.gerrit.common.Nullable;
|
||||
import com.google.gerrit.exceptions.StorageException;
|
||||
import com.google.gerrit.extensions.restapi.ResourceConflictException;
|
||||
import com.google.gerrit.reviewdb.client.Change;
|
||||
import com.google.gerrit.reviewdb.client.ChangeMessage;
|
||||
@@ -32,7 +33,6 @@ import com.google.gerrit.server.notedb.ChangeUpdate;
|
||||
import com.google.gerrit.server.update.BatchUpdateOp;
|
||||
import com.google.gerrit.server.update.ChangeContext;
|
||||
import com.google.gerrit.server.update.Context;
|
||||
import com.google.gwtorm.server.OrmException;
|
||||
import com.google.inject.Inject;
|
||||
import com.google.inject.assistedinject.Assisted;
|
||||
|
||||
@@ -79,7 +79,8 @@ public class AbandonOp implements BatchUpdateOp {
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean updateChange(ChangeContext ctx) throws OrmException, ResourceConflictException {
|
||||
public boolean updateChange(ChangeContext ctx)
|
||||
throws StorageException, ResourceConflictException {
|
||||
change = ctx.getChange();
|
||||
PatchSet.Id psId = change.currentPatchSetId();
|
||||
ChangeUpdate update = ctx.getUpdate(psId);
|
||||
@@ -108,7 +109,7 @@ public class AbandonOp implements BatchUpdateOp {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void postUpdate(Context ctx) throws OrmException {
|
||||
public void postUpdate(Context ctx) throws StorageException {
|
||||
NotifyResolver.Result notify = ctx.getNotify(change.getId());
|
||||
try {
|
||||
ReplyToChangeSender cm = abandonedSenderFactory.create(ctx.getProject(), change.getId());
|
||||
|
@@ -17,6 +17,7 @@ package com.google.gerrit.server.change;
|
||||
import com.google.common.collect.ImmutableListMultimap;
|
||||
import com.google.common.collect.ListMultimap;
|
||||
import com.google.common.flogger.FluentLogger;
|
||||
import com.google.gerrit.exceptions.StorageException;
|
||||
import com.google.gerrit.index.query.QueryParseException;
|
||||
import com.google.gerrit.reviewdb.client.Project;
|
||||
import com.google.gerrit.server.InternalUser;
|
||||
@@ -25,7 +26,6 @@ import com.google.gerrit.server.query.change.ChangeData;
|
||||
import com.google.gerrit.server.query.change.ChangeQueryBuilder;
|
||||
import com.google.gerrit.server.query.change.ChangeQueryProcessor;
|
||||
import com.google.gerrit.server.update.BatchUpdate;
|
||||
import com.google.gwtorm.server.OrmException;
|
||||
import com.google.inject.Inject;
|
||||
import com.google.inject.Provider;
|
||||
import com.google.inject.Singleton;
|
||||
@@ -96,14 +96,14 @@ public class AbandonUtil {
|
||||
}
|
||||
}
|
||||
logger.atInfo().log("Auto-Abandoned %d of %d changes.", count, changesToAbandon.size());
|
||||
} catch (QueryParseException | OrmException e) {
|
||||
} catch (QueryParseException | StorageException e) {
|
||||
logger.atSevere().withCause(e).log(
|
||||
"Failed to query inactive open changes for auto-abandoning.");
|
||||
}
|
||||
}
|
||||
|
||||
private Collection<ChangeData> getValidChanges(Collection<ChangeData> changes, String query)
|
||||
throws OrmException, QueryParseException {
|
||||
throws StorageException, QueryParseException {
|
||||
Collection<ChangeData> validChanges = new ArrayList<>();
|
||||
for (ChangeData cd : changes) {
|
||||
String newQuery = query + " change:" + cd.getId();
|
||||
|
@@ -16,9 +16,9 @@ package com.google.gerrit.server.change;
|
||||
|
||||
import com.google.auto.value.AutoValue;
|
||||
import com.google.common.collect.ImmutableSet;
|
||||
import com.google.gerrit.exceptions.StorageException;
|
||||
import com.google.gerrit.reviewdb.client.Account;
|
||||
import com.google.gerrit.reviewdb.client.PatchSet;
|
||||
import com.google.gwtorm.server.OrmException;
|
||||
import java.util.Collection;
|
||||
import java.util.Optional;
|
||||
|
||||
@@ -54,9 +54,9 @@ public interface AccountPatchReviewStore {
|
||||
* @param path file path
|
||||
* @return {@code true} if the reviewed flag was updated, {@code false} if the reviewed flag was
|
||||
* already set
|
||||
* @throws OrmException thrown if updating the reviewed flag failed
|
||||
* @throws StorageException thrown if updating the reviewed flag failed
|
||||
*/
|
||||
boolean markReviewed(PatchSet.Id psId, Account.Id accountId, String path) throws OrmException;
|
||||
boolean markReviewed(PatchSet.Id psId, Account.Id accountId, String path) throws StorageException;
|
||||
|
||||
/**
|
||||
* Marks the given files in the given patch set as reviewed by the given user.
|
||||
@@ -64,10 +64,10 @@ public interface AccountPatchReviewStore {
|
||||
* @param psId patch set ID
|
||||
* @param accountId account ID of the user
|
||||
* @param paths file paths
|
||||
* @throws OrmException thrown if updating the reviewed flag failed
|
||||
* @throws StorageException thrown if updating the reviewed flag failed
|
||||
*/
|
||||
void markReviewed(PatchSet.Id psId, Account.Id accountId, Collection<String> paths)
|
||||
throws OrmException;
|
||||
throws StorageException;
|
||||
|
||||
/**
|
||||
* Clears the reviewed flag for the given file in the given patch set for the given user.
|
||||
@@ -75,17 +75,17 @@ public interface AccountPatchReviewStore {
|
||||
* @param psId patch set ID
|
||||
* @param accountId account ID of the user
|
||||
* @param path file path
|
||||
* @throws OrmException thrown if clearing the reviewed flag failed
|
||||
* @throws StorageException thrown if clearing the reviewed flag failed
|
||||
*/
|
||||
void clearReviewed(PatchSet.Id psId, Account.Id accountId, String path) throws OrmException;
|
||||
void clearReviewed(PatchSet.Id psId, Account.Id accountId, String path) throws StorageException;
|
||||
|
||||
/**
|
||||
* Clears the reviewed flags for all files in the given patch set for all users.
|
||||
*
|
||||
* @param psId patch set ID
|
||||
* @throws OrmException thrown if clearing the reviewed flags failed
|
||||
* @throws StorageException thrown if clearing the reviewed flags failed
|
||||
*/
|
||||
void clearReviewed(PatchSet.Id psId) throws OrmException;
|
||||
void clearReviewed(PatchSet.Id psId) throws StorageException;
|
||||
|
||||
/**
|
||||
* Find the latest patch set, that is smaller or equals to the given patch set, where at least,
|
||||
@@ -95,8 +95,8 @@ public interface AccountPatchReviewStore {
|
||||
* @param accountId account ID of the user
|
||||
* @return optionally, all files the have been reviewed by the given user that belong to the patch
|
||||
* set that is smaller or equals to the given patch set
|
||||
* @throws OrmException thrown if accessing the reviewed flags failed
|
||||
* @throws StorageException thrown if accessing the reviewed flags failed
|
||||
*/
|
||||
Optional<PatchSetWithReviewedFiles> findReviewed(PatchSet.Id psId, Account.Id accountId)
|
||||
throws OrmException;
|
||||
throws StorageException;
|
||||
}
|
||||
|
@@ -20,6 +20,7 @@ import com.google.common.collect.ImmutableMap;
|
||||
import com.google.common.collect.Iterables;
|
||||
import com.google.common.collect.Lists;
|
||||
import com.google.gerrit.common.Nullable;
|
||||
import com.google.gerrit.exceptions.StorageException;
|
||||
import com.google.gerrit.extensions.api.changes.ActionVisitor;
|
||||
import com.google.gerrit.extensions.common.ActionInfo;
|
||||
import com.google.gerrit.extensions.common.ChangeInfo;
|
||||
@@ -32,7 +33,6 @@ import com.google.gerrit.extensions.webui.UiAction;
|
||||
import com.google.gerrit.server.CurrentUser;
|
||||
import com.google.gerrit.server.extensions.webui.UiActions;
|
||||
import com.google.gerrit.server.notedb.ChangeNotes;
|
||||
import com.google.gwtorm.server.OrmException;
|
||||
import com.google.inject.Inject;
|
||||
import com.google.inject.Provider;
|
||||
import com.google.inject.Singleton;
|
||||
@@ -70,7 +70,7 @@ public class ActionJson {
|
||||
this.userProvider = userProvider;
|
||||
}
|
||||
|
||||
public Map<String, ActionInfo> format(RevisionResource rsrc) throws OrmException {
|
||||
public Map<String, ActionInfo> format(RevisionResource rsrc) throws StorageException {
|
||||
ChangeInfo changeInfo = null;
|
||||
RevisionInfo revisionInfo = null;
|
||||
List<ActionVisitor> visitors = visitors();
|
||||
@@ -97,7 +97,8 @@ public class ActionJson {
|
||||
}
|
||||
|
||||
public RevisionInfo addRevisionActions(
|
||||
@Nullable ChangeInfo changeInfo, RevisionInfo to, RevisionResource rsrc) throws OrmException {
|
||||
@Nullable ChangeInfo changeInfo, RevisionInfo to, RevisionResource rsrc)
|
||||
throws StorageException {
|
||||
List<ActionVisitor> visitors = visitors();
|
||||
if (!visitors.isEmpty()) {
|
||||
if (changeInfo != null) {
|
||||
|
@@ -27,6 +27,7 @@ import com.google.common.collect.ImmutableList;
|
||||
import com.google.common.collect.ImmutableSet;
|
||||
import com.google.common.collect.Lists;
|
||||
import com.google.common.collect.Streams;
|
||||
import com.google.gerrit.exceptions.StorageException;
|
||||
import com.google.gerrit.extensions.client.ReviewerState;
|
||||
import com.google.gerrit.extensions.restapi.RestApiException;
|
||||
import com.google.gerrit.mail.Address;
|
||||
@@ -44,7 +45,6 @@ import com.google.gerrit.server.project.ProjectCache;
|
||||
import com.google.gerrit.server.update.BatchUpdateOp;
|
||||
import com.google.gerrit.server.update.ChangeContext;
|
||||
import com.google.gerrit.server.update.Context;
|
||||
import com.google.gwtorm.server.OrmException;
|
||||
import com.google.inject.Inject;
|
||||
import com.google.inject.assistedinject.Assisted;
|
||||
import java.io.IOException;
|
||||
@@ -158,7 +158,7 @@ public class AddReviewersOp implements BatchUpdateOp {
|
||||
|
||||
@Override
|
||||
public boolean updateChange(ChangeContext ctx)
|
||||
throws RestApiException, OrmException, IOException {
|
||||
throws RestApiException, StorageException, IOException {
|
||||
change = ctx.getChange();
|
||||
if (!accountIds.isEmpty()) {
|
||||
if (state == CC) {
|
||||
|
@@ -20,6 +20,7 @@ import com.google.common.collect.ImmutableList;
|
||||
import com.google.common.collect.ImmutableSet;
|
||||
import com.google.common.collect.Sets;
|
||||
import com.google.common.primitives.Ints;
|
||||
import com.google.gerrit.exceptions.StorageException;
|
||||
import com.google.gerrit.extensions.restapi.DeprecatedIdentifierException;
|
||||
import com.google.gerrit.extensions.restapi.Url;
|
||||
import com.google.gerrit.index.IndexConfig;
|
||||
@@ -37,7 +38,6 @@ import com.google.gerrit.server.notedb.ChangeNotes;
|
||||
import com.google.gerrit.server.project.NoSuchChangeException;
|
||||
import com.google.gerrit.server.query.change.ChangeData;
|
||||
import com.google.gerrit.server.query.change.InternalChangeQuery;
|
||||
import com.google.gwtorm.server.OrmException;
|
||||
import com.google.inject.Inject;
|
||||
import com.google.inject.Module;
|
||||
import com.google.inject.Provider;
|
||||
@@ -106,7 +106,7 @@ public class ChangeFinder {
|
||||
this.allowedIdTypes = ImmutableSet.copyOf(configuredChangeIdTypes);
|
||||
}
|
||||
|
||||
public ChangeNotes findOne(String id) throws OrmException {
|
||||
public ChangeNotes findOne(String id) throws StorageException {
|
||||
List<ChangeNotes> ctls = find(id);
|
||||
if (ctls.size() != 1) {
|
||||
return null;
|
||||
@@ -119,14 +119,14 @@ public class ChangeFinder {
|
||||
*
|
||||
* @param id change identifier.
|
||||
* @return possibly-empty list of notes for all matching changes; may or may not be visible.
|
||||
* @throws OrmException if an error occurred querying the database.
|
||||
* @throws StorageException if an error occurred querying the database.
|
||||
*/
|
||||
public List<ChangeNotes> find(String id) throws OrmException {
|
||||
public List<ChangeNotes> find(String id) throws StorageException {
|
||||
try {
|
||||
return find(id, false);
|
||||
} catch (DeprecatedIdentifierException e) {
|
||||
// This can't happen because we don't enforce deprecation
|
||||
throw new OrmException(e);
|
||||
throw new StorageException(e);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -137,11 +137,11 @@ public class ChangeFinder {
|
||||
* @param enforceDeprecation boolean to see if we should throw {@link
|
||||
* DeprecatedIdentifierException} in case the identifier is deprecated
|
||||
* @return possibly-empty list of notes for all matching changes; may or may not be visible.
|
||||
* @throws OrmException if an error occurred querying the database
|
||||
* @throws StorageException if an error occurred querying the database
|
||||
* @throws DeprecatedIdentifierException if the identifier is deprecated.
|
||||
*/
|
||||
public List<ChangeNotes> find(String id, boolean enforceDeprecation)
|
||||
throws OrmException, DeprecatedIdentifierException {
|
||||
throws StorageException, DeprecatedIdentifierException {
|
||||
if (id.isEmpty()) {
|
||||
return Collections.emptyList();
|
||||
}
|
||||
@@ -195,16 +195,16 @@ public class ChangeFinder {
|
||||
}
|
||||
|
||||
private List<ChangeNotes> fromProjectNumber(String project, int changeNumber)
|
||||
throws OrmException {
|
||||
throws StorageException {
|
||||
Change.Id cId = new Change.Id(changeNumber);
|
||||
try {
|
||||
return ImmutableList.of(
|
||||
changeNotesFactory.createChecked(Project.NameKey.parse(project), cId));
|
||||
} catch (NoSuchChangeException e) {
|
||||
return Collections.emptyList();
|
||||
} catch (OrmException e) {
|
||||
} catch (StorageException e) {
|
||||
// Distinguish between a RepositoryNotFoundException (project argument invalid) and
|
||||
// other OrmExceptions (failure in the persistence layer).
|
||||
// other StorageExceptions (failure in the persistence layer).
|
||||
if (Throwables.getRootCause(e) instanceof RepositoryNotFoundException) {
|
||||
return Collections.emptyList();
|
||||
}
|
||||
@@ -212,7 +212,7 @@ public class ChangeFinder {
|
||||
}
|
||||
}
|
||||
|
||||
public ChangeNotes findOne(Change.Id id) throws OrmException {
|
||||
public ChangeNotes findOne(Change.Id id) throws StorageException {
|
||||
List<ChangeNotes> notes = find(id);
|
||||
if (notes.size() != 1) {
|
||||
throw new NoSuchChangeException(id);
|
||||
@@ -220,7 +220,7 @@ public class ChangeFinder {
|
||||
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);
|
||||
if (project != null) {
|
||||
return fromProjectNumber(project, id.get());
|
||||
@@ -236,7 +236,7 @@ public class ChangeFinder {
|
||||
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());
|
||||
if (!indexConfig.separateChangeSubIndexes()) {
|
||||
for (ChangeData cd : cds) {
|
||||
|
@@ -30,6 +30,7 @@ import com.google.common.flogger.FluentLogger;
|
||||
import com.google.gerrit.common.FooterConstants;
|
||||
import com.google.gerrit.common.data.LabelType;
|
||||
import com.google.gerrit.common.data.LabelTypes;
|
||||
import com.google.gerrit.exceptions.StorageException;
|
||||
import com.google.gerrit.extensions.api.changes.NotifyHandling;
|
||||
import com.google.gerrit.extensions.client.ReviewerState;
|
||||
import com.google.gerrit.extensions.restapi.ResourceConflictException;
|
||||
@@ -68,7 +69,6 @@ import com.google.gerrit.server.update.Context;
|
||||
import com.google.gerrit.server.update.InsertChangeOp;
|
||||
import com.google.gerrit.server.update.RepoContext;
|
||||
import com.google.gerrit.server.util.RequestScopePropagator;
|
||||
import com.google.gwtorm.server.OrmException;
|
||||
import com.google.inject.Inject;
|
||||
import com.google.inject.assistedinject.Assisted;
|
||||
import java.io.IOException;
|
||||
@@ -369,7 +369,7 @@ public class ChangeInserter implements InsertChangeOp {
|
||||
|
||||
@Override
|
||||
public boolean updateChange(ChangeContext ctx)
|
||||
throws RestApiException, OrmException, IOException, PermissionBackendException,
|
||||
throws RestApiException, StorageException, IOException, PermissionBackendException,
|
||||
ConfigInvalidException {
|
||||
change = ctx.getChange(); // Use defensive copy created by ChangeControl.
|
||||
patchSetInfo =
|
||||
|
@@ -48,6 +48,7 @@ import com.google.gerrit.common.data.SubmitRecord;
|
||||
import com.google.gerrit.common.data.SubmitRecord.Status;
|
||||
import com.google.gerrit.common.data.SubmitRequirement;
|
||||
import com.google.gerrit.common.data.SubmitTypeRecord;
|
||||
import com.google.gerrit.exceptions.StorageException;
|
||||
import com.google.gerrit.extensions.api.changes.FixInput;
|
||||
import com.google.gerrit.extensions.client.ListChangesOption;
|
||||
import com.google.gerrit.extensions.client.ReviewerState;
|
||||
@@ -96,7 +97,6 @@ import com.google.gerrit.server.project.RemoveReviewerControl;
|
||||
import com.google.gerrit.server.project.SubmitRuleOptions;
|
||||
import com.google.gerrit.server.query.change.ChangeData;
|
||||
import com.google.gerrit.server.query.change.ChangeData.ChangedLines;
|
||||
import com.google.gwtorm.server.OrmException;
|
||||
import com.google.inject.Inject;
|
||||
import com.google.inject.Provider;
|
||||
import com.google.inject.Singleton;
|
||||
@@ -268,23 +268,23 @@ public class ChangeJson {
|
||||
return this;
|
||||
}
|
||||
|
||||
public ChangeInfo format(ChangeResource rsrc) throws OrmException {
|
||||
public ChangeInfo format(ChangeResource rsrc) throws StorageException {
|
||||
return format(changeDataFactory.create(rsrc.getNotes()));
|
||||
}
|
||||
|
||||
public ChangeInfo format(Change change) throws OrmException {
|
||||
public ChangeInfo format(Change change) throws StorageException {
|
||||
return format(changeDataFactory.create(change));
|
||||
}
|
||||
|
||||
public ChangeInfo format(Project.NameKey project, Change.Id id) throws OrmException {
|
||||
public ChangeInfo format(Project.NameKey project, Change.Id id) throws StorageException {
|
||||
return format(project, id, ChangeInfo::new);
|
||||
}
|
||||
|
||||
public ChangeInfo format(ChangeData cd) throws OrmException {
|
||||
public ChangeInfo format(ChangeData cd) throws StorageException {
|
||||
return format(cd, Optional.empty(), true, ChangeInfo::new);
|
||||
}
|
||||
|
||||
public ChangeInfo format(RevisionResource rsrc) throws OrmException {
|
||||
public ChangeInfo format(RevisionResource rsrc) throws StorageException {
|
||||
ChangeData cd = changeDataFactory.create(rsrc.getNotes());
|
||||
return format(cd, Optional.of(rsrc.getPatchSet().getId()), true, ChangeInfo::new);
|
||||
}
|
||||
@@ -309,7 +309,7 @@ public class ChangeJson {
|
||||
}
|
||||
|
||||
public List<ChangeInfo> format(Collection<ChangeData> in)
|
||||
throws OrmException, PermissionBackendException {
|
||||
throws StorageException, PermissionBackendException {
|
||||
accountLoader = accountLoaderFactory.create(has(DETAILED_ACCOUNTS));
|
||||
ensureLoaded(in);
|
||||
List<ChangeInfo> out = new ArrayList<>(in.size());
|
||||
@@ -321,11 +321,12 @@ public class ChangeJson {
|
||||
}
|
||||
|
||||
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;
|
||||
try {
|
||||
notes = notesFactory.createChecked(project, id);
|
||||
} catch (OrmException e) {
|
||||
} catch (StorageException e) {
|
||||
if (!has(CHECK)) {
|
||||
throw e;
|
||||
}
|
||||
@@ -367,7 +368,7 @@ public class ChangeJson {
|
||||
Optional<PatchSet.Id> limitToPsId,
|
||||
boolean fillAccountLoader,
|
||||
Supplier<I> changeInfoSupplier)
|
||||
throws OrmException {
|
||||
throws StorageException {
|
||||
try {
|
||||
if (fillAccountLoader) {
|
||||
accountLoader = accountLoaderFactory.create(has(DETAILED_ACCOUNTS));
|
||||
@@ -378,19 +379,19 @@ public class ChangeJson {
|
||||
return toChangeInfo(cd, limitToPsId, changeInfoSupplier);
|
||||
} catch (PatchListNotAvailableException
|
||||
| GpgException
|
||||
| OrmException
|
||||
| StorageException
|
||||
| IOException
|
||||
| PermissionBackendException
|
||||
| RuntimeException e) {
|
||||
if (!has(CHECK)) {
|
||||
Throwables.throwIfInstanceOf(e, OrmException.class);
|
||||
throw new OrmException(e);
|
||||
Throwables.throwIfInstanceOf(e, StorageException.class);
|
||||
throw new StorageException(e);
|
||||
}
|
||||
return checkOnly(cd, changeInfoSupplier);
|
||||
}
|
||||
}
|
||||
|
||||
private void ensureLoaded(Iterable<ChangeData> all) throws OrmException {
|
||||
private void ensureLoaded(Iterable<ChangeData> all) throws StorageException {
|
||||
if (lazyLoad) {
|
||||
ChangeData.ensureChangeLoaded(all);
|
||||
if (has(ALL_REVISIONS)) {
|
||||
@@ -425,7 +426,7 @@ public class ChangeJson {
|
||||
try {
|
||||
ensureLoaded(Collections.singleton(cd));
|
||||
changeInfos.add(format(cd, Optional.empty(), false, ChangeInfo::new));
|
||||
} catch (OrmException | RuntimeException e) {
|
||||
} catch (StorageException | RuntimeException e) {
|
||||
logger.atWarning().withCause(e).log(
|
||||
"Omitting corrupt change %s from results", cd.getId());
|
||||
}
|
||||
@@ -438,7 +439,7 @@ public class ChangeJson {
|
||||
ChangeNotes notes;
|
||||
try {
|
||||
notes = cd.notes();
|
||||
} catch (OrmException e) {
|
||||
} catch (StorageException e) {
|
||||
String msg = "Error loading change";
|
||||
logger.atWarning().withCause(e).log(msg + " %s", cd.getId());
|
||||
I info = changeInfoSupplier.get();
|
||||
@@ -477,8 +478,8 @@ public class ChangeJson {
|
||||
|
||||
private <I extends ChangeInfo> I toChangeInfo(
|
||||
ChangeData cd, Optional<PatchSet.Id> limitToPsId, Supplier<I> changeInfoSupplier)
|
||||
throws PatchListNotAvailableException, GpgException, OrmException, PermissionBackendException,
|
||||
IOException {
|
||||
throws PatchListNotAvailableException, GpgException, StorageException,
|
||||
PermissionBackendException, IOException {
|
||||
try (Timer0.Context ignored = metrics.toChangeInfoLatency.start()) {
|
||||
return toChangeInfoImpl(cd, limitToPsId, changeInfoSupplier);
|
||||
}
|
||||
@@ -486,8 +487,8 @@ public class ChangeJson {
|
||||
|
||||
private <I extends ChangeInfo> I toChangeInfoImpl(
|
||||
ChangeData cd, Optional<PatchSet.Id> limitToPsId, Supplier<I> changeInfoSupplier)
|
||||
throws PatchListNotAvailableException, GpgException, OrmException, PermissionBackendException,
|
||||
IOException {
|
||||
throws PatchListNotAvailableException, GpgException, StorageException,
|
||||
PermissionBackendException, IOException {
|
||||
I out = changeInfoSupplier.get();
|
||||
CurrentUser user = userProvider.get();
|
||||
|
||||
@@ -638,7 +639,7 @@ public class ChangeJson {
|
||||
return reviewerMap;
|
||||
}
|
||||
|
||||
private Collection<ReviewerUpdateInfo> reviewerUpdates(ChangeData cd) throws OrmException {
|
||||
private Collection<ReviewerUpdateInfo> reviewerUpdates(ChangeData cd) throws StorageException {
|
||||
List<ReviewerStatusUpdate> reviewerUpdates = cd.reviewerUpdates();
|
||||
List<ReviewerUpdateInfo> result = new ArrayList<>(reviewerUpdates.size());
|
||||
for (ReviewerStatusUpdate c : reviewerUpdates) {
|
||||
@@ -656,7 +657,7 @@ public class ChangeJson {
|
||||
return SubmitRecord.allRecordsOK(cd.submitRecords(SUBMIT_RULE_OPTIONS_STRICT));
|
||||
}
|
||||
|
||||
private void setSubmitter(ChangeData cd, ChangeInfo out) throws OrmException {
|
||||
private void setSubmitter(ChangeData cd, ChangeInfo out) throws StorageException {
|
||||
Optional<PatchSetApproval> s = cd.getSubmitApproval();
|
||||
if (!s.isPresent()) {
|
||||
return;
|
||||
@@ -665,7 +666,7 @@ public class ChangeJson {
|
||||
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());
|
||||
if (messages.isEmpty()) {
|
||||
return Collections.emptyList();
|
||||
@@ -679,7 +680,7 @@ public class ChangeJson {
|
||||
}
|
||||
|
||||
private Collection<AccountInfo> removableReviewers(ChangeData cd, ChangeInfo out)
|
||||
throws PermissionBackendException, OrmException {
|
||||
throws PermissionBackendException, StorageException {
|
||||
// Although this is called removableReviewers, this method also determines
|
||||
// which CCs are removable.
|
||||
//
|
||||
@@ -768,7 +769,7 @@ public class ChangeJson {
|
||||
}
|
||||
|
||||
private Map<PatchSet.Id, PatchSet> loadPatchSets(ChangeData cd, Optional<PatchSet.Id> limitToPsId)
|
||||
throws OrmException {
|
||||
throws StorageException {
|
||||
Collection<PatchSet> src;
|
||||
if (has(ALL_REVISIONS) || has(MESSAGES)) {
|
||||
src = cd.patchSets();
|
||||
@@ -777,12 +778,12 @@ public class ChangeJson {
|
||||
if (limitToPsId.isPresent()) {
|
||||
ps = cd.patchSet(limitToPsId.get());
|
||||
if (ps == null) {
|
||||
throw new OrmException("missing patch set " + limitToPsId.get());
|
||||
throw new StorageException("missing patch set " + limitToPsId.get());
|
||||
}
|
||||
} else {
|
||||
ps = cd.currentPatchSet();
|
||||
if (ps == null) {
|
||||
throw new OrmException("missing current patch set for change " + cd.getId());
|
||||
throw new StorageException("missing current patch set for change " + cd.getId());
|
||||
}
|
||||
}
|
||||
src = Collections.singletonList(ps);
|
||||
@@ -800,7 +801,7 @@ public class ChangeJson {
|
||||
* lazyload}.
|
||||
*/
|
||||
private PermissionBackend.ForChange permissionBackendForChange(CurrentUser user, ChangeData cd)
|
||||
throws OrmException {
|
||||
throws StorageException {
|
||||
PermissionBackend.WithUser withUser = permissionBackend.user(user);
|
||||
return lazyLoad
|
||||
? withUser.change(cd)
|
||||
|
@@ -23,6 +23,7 @@ import com.google.common.cache.Weigher;
|
||||
import com.google.common.collect.FluentIterable;
|
||||
import com.google.common.flogger.FluentLogger;
|
||||
import com.google.gerrit.common.Nullable;
|
||||
import com.google.gerrit.exceptions.StorageException;
|
||||
import com.google.gerrit.extensions.client.ChangeKind;
|
||||
import com.google.gerrit.proto.Protos;
|
||||
import com.google.gerrit.reviewdb.client.Change;
|
||||
@@ -38,7 +39,6 @@ import com.google.gerrit.server.git.GitRepositoryManager;
|
||||
import com.google.gerrit.server.git.InMemoryInserter;
|
||||
import com.google.gerrit.server.git.MergeUtil;
|
||||
import com.google.gerrit.server.query.change.ChangeData;
|
||||
import com.google.gwtorm.server.OrmException;
|
||||
import com.google.inject.Inject;
|
||||
import com.google.inject.Module;
|
||||
import com.google.inject.name.Named;
|
||||
@@ -392,7 +392,7 @@ public class ChangeKindCacheImpl implements ChangeKindCache {
|
||||
ObjectId.fromString(priorPs.getRevision().get()),
|
||||
ObjectId.fromString(patch.getRevision().get()));
|
||||
}
|
||||
} catch (OrmException e) {
|
||||
} catch (StorageException e) {
|
||||
// Do nothing; assume we have a complex change
|
||||
logger.atWarning().withCause(e).log(
|
||||
"Unable to get change kind for patchSet %s of change %s",
|
||||
|
@@ -21,6 +21,7 @@ import com.google.common.collect.ImmutableList;
|
||||
import com.google.common.flogger.FluentLogger;
|
||||
import com.google.common.hash.Hasher;
|
||||
import com.google.common.hash.Hashing;
|
||||
import com.google.gerrit.exceptions.StorageException;
|
||||
import com.google.gerrit.extensions.restapi.RestResource;
|
||||
import com.google.gerrit.extensions.restapi.RestResource.HasETag;
|
||||
import com.google.gerrit.extensions.restapi.RestView;
|
||||
@@ -39,7 +40,6 @@ import com.google.gerrit.server.notedb.ChangeNotes;
|
||||
import com.google.gerrit.server.permissions.PermissionBackend;
|
||||
import com.google.gerrit.server.project.ProjectCache;
|
||||
import com.google.gerrit.server.project.ProjectState;
|
||||
import com.google.gwtorm.server.OrmException;
|
||||
import com.google.inject.Inject;
|
||||
import com.google.inject.TypeLiteral;
|
||||
import com.google.inject.assistedinject.Assisted;
|
||||
@@ -159,7 +159,7 @@ public class ChangeResource implements RestResource, HasETag {
|
||||
// message is automatically added as reviewer. Hence if we include removed reviewers we can
|
||||
// be sure that we have all accounts that posted messages on the change.
|
||||
accounts.addAll(approvalUtil.getReviewers(notes).all());
|
||||
} catch (OrmException e) {
|
||||
} catch (StorageException e) {
|
||||
// This ETag will be invalidated if it loads next time.
|
||||
}
|
||||
|
||||
@@ -175,7 +175,7 @@ public class ChangeResource implements RestResource, HasETag {
|
||||
ObjectId noteId;
|
||||
try {
|
||||
noteId = notes.loadRevision();
|
||||
} catch (OrmException e) {
|
||||
} catch (StorageException e) {
|
||||
noteId = null; // This ETag will be invalidated if it loads next time.
|
||||
}
|
||||
hashObjectId(h, noteId, buf);
|
||||
|
@@ -30,6 +30,7 @@ import com.google.common.collect.SetMultimap;
|
||||
import com.google.common.flogger.FluentLogger;
|
||||
import com.google.gerrit.common.FooterConstants;
|
||||
import com.google.gerrit.common.Nullable;
|
||||
import com.google.gerrit.exceptions.StorageException;
|
||||
import com.google.gerrit.extensions.api.changes.FixInput;
|
||||
import com.google.gerrit.extensions.common.ProblemInfo;
|
||||
import com.google.gerrit.extensions.common.ProblemInfo.Status;
|
||||
@@ -55,7 +56,6 @@ import com.google.gerrit.server.update.RepoContext;
|
||||
import com.google.gerrit.server.update.RetryHelper;
|
||||
import com.google.gerrit.server.update.UpdateException;
|
||||
import com.google.gerrit.server.util.time.TimeUtil;
|
||||
import com.google.gwtorm.server.OrmException;
|
||||
import com.google.inject.Inject;
|
||||
import com.google.inject.Provider;
|
||||
import java.io.IOException;
|
||||
@@ -232,7 +232,7 @@ public class ConsistencyChecker {
|
||||
problem(
|
||||
String.format("Current patch set %d not found", change().currentPatchSetId().get()));
|
||||
}
|
||||
} catch (OrmException e) {
|
||||
} catch (StorageException e) {
|
||||
error("Failed to look up current patch set", e);
|
||||
}
|
||||
}
|
||||
@@ -256,7 +256,7 @@ public class ConsistencyChecker {
|
||||
try {
|
||||
// Iterate in descending order.
|
||||
all = PS_ID_ORDER.sortedCopy(psUtil.byChange(notes));
|
||||
} catch (OrmException e) {
|
||||
} catch (StorageException e) {
|
||||
return error("Failed to look up patch sets", e);
|
||||
}
|
||||
patchSetsBySha = MultimapBuilder.hashKeys(all.size()).treeSetValues(PS_ID_ORDER).build();
|
||||
@@ -425,7 +425,7 @@ public class ConsistencyChecker {
|
||||
if (!c.getDest().equals(change().getDest())) {
|
||||
continue;
|
||||
}
|
||||
} catch (OrmException e) {
|
||||
} catch (StorageException e) {
|
||||
warn(e);
|
||||
// Include this patch set; should cause an error below, which is good.
|
||||
}
|
||||
@@ -556,7 +556,7 @@ public class ConsistencyChecker {
|
||||
notes = notesFactory.createChecked(inserter.getChange());
|
||||
insertPatchSetProblem.status = Status.FIXED;
|
||||
insertPatchSetProblem.outcome = "Inserted as patch set " + psId.get();
|
||||
} catch (OrmException | IOException | UpdateException | RestApiException e) {
|
||||
} catch (StorageException | IOException | UpdateException | RestApiException e) {
|
||||
warn(e);
|
||||
for (ProblemInfo pi : currProblems) {
|
||||
pi.status = Status.FIX_FAILED;
|
||||
@@ -574,7 +574,7 @@ public class ConsistencyChecker {
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean updateChange(ChangeContext ctx) throws OrmException {
|
||||
public boolean updateChange(ChangeContext ctx) throws StorageException {
|
||||
ctx.getChange().setStatus(Change.Status.MERGED);
|
||||
ctx.getUpdate(ctx.getChange().currentPatchSetId()).fixStatus(Change.Status.MERGED);
|
||||
p.status = Status.FIXED;
|
||||
@@ -673,9 +673,9 @@ public class ConsistencyChecker {
|
||||
|
||||
@Override
|
||||
public boolean updateChange(ChangeContext ctx)
|
||||
throws OrmException, PatchSetInfoNotAvailableException {
|
||||
throws StorageException, PatchSetInfoNotAvailableException {
|
||||
// Delete dangling key references.
|
||||
accountPatchReviewStore.run(s -> s.clearReviewed(psId), OrmException.class);
|
||||
accountPatchReviewStore.run(s -> s.clearReviewed(psId), StorageException.class);
|
||||
|
||||
// For NoteDb setting the state to deleted is sufficient to filter everything out.
|
||||
ctx.getUpdate(psId).setPatchSetState(PatchSetState.DELETED);
|
||||
@@ -706,7 +706,8 @@ public class ConsistencyChecker {
|
||||
|
||||
@Override
|
||||
public boolean updateChange(ChangeContext ctx)
|
||||
throws OrmException, PatchSetInfoNotAvailableException, NoPatchSetsWouldRemainException {
|
||||
throws StorageException, PatchSetInfoNotAvailableException,
|
||||
NoPatchSetsWouldRemainException {
|
||||
if (!toDelete.contains(ctx.getChange().currentPatchSetId())) {
|
||||
return false;
|
||||
}
|
||||
|
@@ -14,6 +14,7 @@
|
||||
|
||||
package com.google.gerrit.server.change;
|
||||
|
||||
import com.google.gerrit.exceptions.StorageException;
|
||||
import com.google.gerrit.extensions.restapi.MethodNotAllowedException;
|
||||
import com.google.gerrit.extensions.restapi.ResourceConflictException;
|
||||
import com.google.gerrit.extensions.restapi.RestApiException;
|
||||
@@ -27,7 +28,6 @@ import com.google.gerrit.server.project.NoSuchChangeException;
|
||||
import com.google.gerrit.server.update.BatchUpdateOp;
|
||||
import com.google.gerrit.server.update.ChangeContext;
|
||||
import com.google.gerrit.server.update.RepoContext;
|
||||
import com.google.gwtorm.server.OrmException;
|
||||
import com.google.inject.Inject;
|
||||
import com.google.inject.assistedinject.Assisted;
|
||||
import java.io.IOException;
|
||||
@@ -67,7 +67,7 @@ public class DeleteChangeOp implements BatchUpdateOp {
|
||||
// fail gracefully if the second delete fails, but fortunately that's not what happens.
|
||||
@Override
|
||||
public boolean updateChange(ChangeContext ctx)
|
||||
throws RestApiException, OrmException, IOException {
|
||||
throws RestApiException, StorageException, IOException {
|
||||
Collection<PatchSet> patchSets = psUtil.byChange(ctx.getNotes());
|
||||
|
||||
ensureDeletable(ctx, id, patchSets);
|
||||
@@ -107,9 +107,9 @@ public class DeleteChangeOp implements BatchUpdateOp {
|
||||
}
|
||||
|
||||
private void cleanUpReferences(ChangeContext ctx, Change.Id id, Collection<PatchSet> patchSets)
|
||||
throws OrmException, NoSuchChangeException {
|
||||
throws StorageException, NoSuchChangeException {
|
||||
for (PatchSet ps : patchSets) {
|
||||
accountPatchReviewStore.run(s -> s.clearReviewed(ps.getId()), OrmException.class);
|
||||
accountPatchReviewStore.run(s -> s.clearReviewed(ps.getId()), StorageException.class);
|
||||
}
|
||||
|
||||
// Non-atomic operation on Accounts table; not much we can do to make it
|
||||
|
@@ -15,6 +15,7 @@
|
||||
package com.google.gerrit.server.change;
|
||||
|
||||
import com.google.common.flogger.FluentLogger;
|
||||
import com.google.gerrit.exceptions.StorageException;
|
||||
import com.google.gerrit.mail.Address;
|
||||
import com.google.gerrit.reviewdb.client.Change;
|
||||
import com.google.gerrit.reviewdb.client.ChangeMessage;
|
||||
@@ -24,7 +25,6 @@ import com.google.gerrit.server.mail.send.DeleteReviewerSender;
|
||||
import com.google.gerrit.server.update.BatchUpdateOp;
|
||||
import com.google.gerrit.server.update.ChangeContext;
|
||||
import com.google.gerrit.server.update.Context;
|
||||
import com.google.gwtorm.server.OrmException;
|
||||
import com.google.inject.Inject;
|
||||
import com.google.inject.assistedinject.Assisted;
|
||||
import java.util.Collections;
|
||||
@@ -50,7 +50,7 @@ public class DeleteReviewerByEmailOp implements BatchUpdateOp {
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean updateChange(ChangeContext ctx) throws OrmException {
|
||||
public boolean updateChange(ChangeContext ctx) throws StorageException {
|
||||
change = ctx.getChange();
|
||||
PatchSet.Id psId = ctx.getChange().currentPatchSetId();
|
||||
String msg = "Removed reviewer " + reviewer;
|
||||
|
@@ -19,6 +19,7 @@ import com.google.common.flogger.FluentLogger;
|
||||
import com.google.gerrit.common.data.LabelType;
|
||||
import com.google.gerrit.common.data.LabelTypes;
|
||||
import com.google.gerrit.exceptions.EmailException;
|
||||
import com.google.gerrit.exceptions.StorageException;
|
||||
import com.google.gerrit.extensions.api.changes.DeleteReviewerInput;
|
||||
import com.google.gerrit.extensions.api.changes.NotifyHandling;
|
||||
import com.google.gerrit.extensions.restapi.AuthException;
|
||||
@@ -43,7 +44,6 @@ import com.google.gerrit.server.project.RemoveReviewerControl;
|
||||
import com.google.gerrit.server.update.BatchUpdateOp;
|
||||
import com.google.gerrit.server.update.ChangeContext;
|
||||
import com.google.gerrit.server.update.Context;
|
||||
import com.google.gwtorm.server.OrmException;
|
||||
import com.google.inject.Inject;
|
||||
import com.google.inject.Provider;
|
||||
import com.google.inject.assistedinject.Assisted;
|
||||
@@ -108,7 +108,7 @@ public class DeleteReviewerOp implements BatchUpdateOp {
|
||||
|
||||
@Override
|
||||
public boolean updateChange(ChangeContext ctx)
|
||||
throws AuthException, ResourceNotFoundException, OrmException, PermissionBackendException,
|
||||
throws AuthException, ResourceNotFoundException, StorageException, PermissionBackendException,
|
||||
IOException {
|
||||
Account.Id reviewerId = reviewer.getAccount().getId();
|
||||
// Check of removing this reviewer (even if there is no vote processed by the loop below) is OK
|
||||
@@ -195,7 +195,7 @@ public class DeleteReviewerOp implements BatchUpdateOp {
|
||||
}
|
||||
|
||||
private Iterable<PatchSetApproval> approvals(ChangeContext ctx, Account.Id accountId)
|
||||
throws OrmException {
|
||||
throws StorageException {
|
||||
Iterable<PatchSetApproval> approvals;
|
||||
approvals = approvalsUtil.byChange(ctx.getNotes()).values();
|
||||
return Iterables.filter(approvals, psa -> accountId.equals(psa.getAccountId()));
|
||||
|
@@ -36,6 +36,7 @@ import com.google.gerrit.common.data.LabelType;
|
||||
import com.google.gerrit.common.data.LabelTypes;
|
||||
import com.google.gerrit.common.data.LabelValue;
|
||||
import com.google.gerrit.common.data.SubmitRecord;
|
||||
import com.google.gerrit.exceptions.StorageException;
|
||||
import com.google.gerrit.extensions.client.ListChangesOption;
|
||||
import com.google.gerrit.extensions.common.ApprovalInfo;
|
||||
import com.google.gerrit.extensions.common.LabelInfo;
|
||||
@@ -51,7 +52,6 @@ import com.google.gerrit.server.permissions.LabelPermission;
|
||||
import com.google.gerrit.server.permissions.PermissionBackend;
|
||||
import com.google.gerrit.server.permissions.PermissionBackendException;
|
||||
import com.google.gerrit.server.query.change.ChangeData;
|
||||
import com.google.gwtorm.server.OrmException;
|
||||
import com.google.inject.Inject;
|
||||
import com.google.inject.assistedinject.Assisted;
|
||||
import java.sql.Timestamp;
|
||||
@@ -100,7 +100,7 @@ public class LabelsJson {
|
||||
*/
|
||||
Map<String, LabelInfo> labelsFor(
|
||||
AccountLoader accountLoader, ChangeData cd, boolean standard, boolean detailed)
|
||||
throws OrmException, PermissionBackendException {
|
||||
throws StorageException, PermissionBackendException {
|
||||
if (!standard && !detailed) {
|
||||
return null;
|
||||
}
|
||||
@@ -115,7 +115,7 @@ public class LabelsJson {
|
||||
|
||||
/** Returns all labels that the provided user has permission to vote on. */
|
||||
Map<String, Collection<String>> permittedLabels(Account.Id filterApprovalsBy, ChangeData cd)
|
||||
throws OrmException, PermissionBackendException {
|
||||
throws StorageException, PermissionBackendException {
|
||||
boolean isMerged = cd.change().isMerged();
|
||||
LabelTypes labelTypes = cd.getLabelTypes();
|
||||
Map<String, LabelType> toCheck = new HashMap<>();
|
||||
@@ -194,7 +194,7 @@ public class LabelsJson {
|
||||
LabelTypes labelTypes,
|
||||
boolean standard,
|
||||
boolean detailed)
|
||||
throws OrmException, PermissionBackendException {
|
||||
throws StorageException, PermissionBackendException {
|
||||
Map<String, LabelWithStatus> labels = initLabels(accountLoader, cd, labelTypes, standard);
|
||||
if (detailed) {
|
||||
setAllApprovals(accountLoader, cd, labels);
|
||||
@@ -253,7 +253,7 @@ public class LabelsJson {
|
||||
}
|
||||
|
||||
private Map<String, Short> currentLabels(Account.Id accountId, ChangeData cd)
|
||||
throws OrmException {
|
||||
throws StorageException {
|
||||
Map<String, Short> result = new HashMap<>();
|
||||
for (PatchSetApproval psa :
|
||||
approvalsUtil.byPatchSetUser(
|
||||
@@ -273,7 +273,7 @@ public class LabelsJson {
|
||||
LabelTypes labelTypes,
|
||||
boolean standard,
|
||||
boolean detailed)
|
||||
throws OrmException, PermissionBackendException {
|
||||
throws StorageException, PermissionBackendException {
|
||||
Set<Account.Id> allUsers = new HashSet<>();
|
||||
if (detailed) {
|
||||
// Users expect to see all reviewers on closed changes, even if they
|
||||
@@ -431,7 +431,7 @@ public class LabelsJson {
|
||||
|
||||
private void setAllApprovals(
|
||||
AccountLoader accountLoader, ChangeData cd, Map<String, LabelWithStatus> labels)
|
||||
throws OrmException, PermissionBackendException {
|
||||
throws StorageException, PermissionBackendException {
|
||||
checkState(
|
||||
!cd.change().isMerged(),
|
||||
"should not call setAllApprovals on %s change",
|
||||
@@ -500,7 +500,7 @@ public class LabelsJson {
|
||||
* lazyload}.
|
||||
*/
|
||||
private PermissionBackend.ForChange permissionBackendForChange(Account.Id user, ChangeData cd)
|
||||
throws OrmException {
|
||||
throws StorageException {
|
||||
PermissionBackend.WithUser withUser = permissionBackend.absentUser(user);
|
||||
return lazyLoad
|
||||
? withUser.change(cd)
|
||||
|
@@ -21,6 +21,7 @@ import com.google.auto.value.AutoValue;
|
||||
import com.google.common.collect.ImmutableList;
|
||||
import com.google.common.collect.ImmutableSetMultimap;
|
||||
import com.google.gerrit.common.Nullable;
|
||||
import com.google.gerrit.exceptions.StorageException;
|
||||
import com.google.gerrit.extensions.api.changes.NotifyHandling;
|
||||
import com.google.gerrit.extensions.api.changes.NotifyInfo;
|
||||
import com.google.gerrit.extensions.api.changes.RecipientType;
|
||||
@@ -28,7 +29,6 @@ import com.google.gerrit.extensions.restapi.BadRequestException;
|
||||
import com.google.gerrit.extensions.restapi.UnprocessableEntityException;
|
||||
import com.google.gerrit.reviewdb.client.Account;
|
||||
import com.google.gerrit.server.account.AccountResolver;
|
||||
import com.google.gwtorm.server.OrmException;
|
||||
import com.google.inject.Inject;
|
||||
import com.google.inject.Singleton;
|
||||
import java.io.IOException;
|
||||
@@ -81,7 +81,7 @@ public class NotifyResolver {
|
||||
|
||||
public Result resolve(
|
||||
NotifyHandling handling, @Nullable Map<RecipientType, NotifyInfo> notifyDetails)
|
||||
throws BadRequestException, OrmException, IOException, ConfigInvalidException {
|
||||
throws BadRequestException, StorageException, IOException, ConfigInvalidException {
|
||||
requireNonNull(handling);
|
||||
ImmutableSetMultimap.Builder<RecipientType, Account.Id> b = ImmutableSetMultimap.builder();
|
||||
if (notifyDetails != null) {
|
||||
@@ -93,7 +93,7 @@ public class NotifyResolver {
|
||||
}
|
||||
|
||||
private ImmutableList<Account.Id> find(@Nullable List<String> inputs)
|
||||
throws OrmException, BadRequestException, IOException, ConfigInvalidException {
|
||||
throws StorageException, BadRequestException, IOException, ConfigInvalidException {
|
||||
if (inputs == null || inputs.isEmpty()) {
|
||||
return ImmutableList.of();
|
||||
}
|
||||
|
@@ -20,6 +20,7 @@ import static com.google.gerrit.server.notedb.ReviewerStateInternal.REVIEWER;
|
||||
import static java.util.Objects.requireNonNull;
|
||||
|
||||
import com.google.common.flogger.FluentLogger;
|
||||
import com.google.gerrit.exceptions.StorageException;
|
||||
import com.google.gerrit.extensions.api.changes.NotifyHandling;
|
||||
import com.google.gerrit.extensions.restapi.AuthException;
|
||||
import com.google.gerrit.extensions.restapi.ResourceConflictException;
|
||||
@@ -49,7 +50,6 @@ import com.google.gerrit.server.update.BatchUpdateOp;
|
||||
import com.google.gerrit.server.update.ChangeContext;
|
||||
import com.google.gerrit.server.update.Context;
|
||||
import com.google.gerrit.server.update.RepoContext;
|
||||
import com.google.gwtorm.server.OrmException;
|
||||
import com.google.inject.Inject;
|
||||
import com.google.inject.assistedinject.Assisted;
|
||||
import java.io.IOException;
|
||||
@@ -187,7 +187,7 @@ public class PatchSetInserter implements BatchUpdateOp {
|
||||
|
||||
@Override
|
||||
public void updateRepo(RepoContext ctx)
|
||||
throws AuthException, ResourceConflictException, IOException, OrmException,
|
||||
throws AuthException, ResourceConflictException, IOException, StorageException,
|
||||
PermissionBackendException {
|
||||
validate(ctx);
|
||||
ctx.addRefUpdate(ObjectId.zeroId(), commitId, getPatchSetId().toRefName());
|
||||
@@ -195,7 +195,7 @@ public class PatchSetInserter implements BatchUpdateOp {
|
||||
|
||||
@Override
|
||||
public boolean updateChange(ChangeContext ctx)
|
||||
throws ResourceConflictException, OrmException, IOException {
|
||||
throws ResourceConflictException, StorageException, IOException {
|
||||
change = ctx.getChange();
|
||||
ChangeUpdate update = ctx.getUpdate(psId);
|
||||
update.setSubjectForCommit("Create patch set " + psId.get());
|
||||
@@ -272,7 +272,7 @@ public class PatchSetInserter implements BatchUpdateOp {
|
||||
|
||||
private void validate(RepoContext ctx)
|
||||
throws AuthException, ResourceConflictException, IOException, PermissionBackendException,
|
||||
OrmException {
|
||||
StorageException {
|
||||
// Not allowed to create a new patch set if the current patch set is locked.
|
||||
psUtil.checkPatchSetNotLocked(origNotes);
|
||||
|
||||
|
@@ -14,12 +14,12 @@
|
||||
|
||||
package com.google.gerrit.server.change;
|
||||
|
||||
import com.google.gerrit.exceptions.StorageException;
|
||||
import com.google.gerrit.extensions.restapi.BadRequestException;
|
||||
import com.google.gerrit.extensions.restapi.ResourceConflictException;
|
||||
import com.google.gerrit.reviewdb.client.PatchSet;
|
||||
import com.google.gerrit.server.git.PureRevertCache;
|
||||
import com.google.gerrit.server.notedb.ChangeNotes;
|
||||
import com.google.gwtorm.server.OrmException;
|
||||
import com.google.inject.Inject;
|
||||
import com.google.inject.Singleton;
|
||||
import java.io.IOException;
|
||||
@@ -38,7 +38,7 @@ public class PureRevert {
|
||||
}
|
||||
|
||||
public boolean get(ChangeNotes notes, Optional<String> claimedOriginal)
|
||||
throws OrmException, IOException, BadRequestException, ResourceConflictException {
|
||||
throws StorageException, IOException, BadRequestException, ResourceConflictException {
|
||||
PatchSet currentPatchSet = notes.getCurrentPatchSet();
|
||||
if (currentPatchSet == null) {
|
||||
throw new ResourceConflictException("current revision is missing");
|
||||
|
@@ -16,6 +16,7 @@ package com.google.gerrit.server.change;
|
||||
|
||||
import static com.google.common.base.Preconditions.checkState;
|
||||
|
||||
import com.google.gerrit.exceptions.StorageException;
|
||||
import com.google.gerrit.extensions.restapi.MergeConflictException;
|
||||
import com.google.gerrit.extensions.restapi.ResourceConflictException;
|
||||
import com.google.gerrit.extensions.restapi.RestApiException;
|
||||
@@ -37,7 +38,6 @@ import com.google.gerrit.server.update.BatchUpdateOp;
|
||||
import com.google.gerrit.server.update.ChangeContext;
|
||||
import com.google.gerrit.server.update.Context;
|
||||
import com.google.gerrit.server.update.RepoContext;
|
||||
import com.google.gwtorm.server.OrmException;
|
||||
import com.google.inject.Inject;
|
||||
import com.google.inject.assistedinject.Assisted;
|
||||
import java.io.IOException;
|
||||
@@ -149,7 +149,7 @@ public class RebaseChangeOp implements BatchUpdateOp {
|
||||
@Override
|
||||
public void updateRepo(RepoContext ctx)
|
||||
throws MergeConflictException, InvalidChangeOperationException, RestApiException, IOException,
|
||||
OrmException, NoSuchChangeException, PermissionBackendException {
|
||||
StorageException, NoSuchChangeException, PermissionBackendException {
|
||||
// Ok that originalPatchSet was not read in a transaction, since we just
|
||||
// need its revision.
|
||||
RevId oldRev = originalPatchSet.getRevision();
|
||||
@@ -214,14 +214,14 @@ public class RebaseChangeOp implements BatchUpdateOp {
|
||||
|
||||
@Override
|
||||
public boolean updateChange(ChangeContext ctx)
|
||||
throws ResourceConflictException, OrmException, IOException {
|
||||
throws ResourceConflictException, StorageException, IOException {
|
||||
boolean ret = patchSetInserter.updateChange(ctx);
|
||||
rebasedPatchSet = patchSetInserter.getPatchSet();
|
||||
return ret;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void postUpdate(Context ctx) throws OrmException {
|
||||
public void postUpdate(Context ctx) throws StorageException {
|
||||
patchSetInserter.postUpdate(ctx);
|
||||
}
|
||||
|
||||
|
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user