Merge "Adapt to new StorageException class name and package"
diff --git a/java/com/google/gerrit/plugins/checks/CheckerQuery.java b/java/com/google/gerrit/plugins/checks/CheckerQuery.java
index 5bff722..71f7ff2 100644
--- a/java/com/google/gerrit/plugins/checks/CheckerQuery.java
+++ b/java/com/google/gerrit/plugins/checks/CheckerQuery.java
@@ -28,6 +28,7 @@
import com.google.common.collect.ImmutableSortedSet;
import com.google.common.flogger.FluentLogger;
import com.google.gerrit.common.Nullable;
+import com.google.gerrit.exceptions.StorageException;
import com.google.gerrit.index.query.IndexPredicate;
import com.google.gerrit.index.query.Predicate;
import com.google.gerrit.index.query.QueryParseException;
@@ -42,7 +43,6 @@
import com.google.gerrit.server.query.change.ProjectPredicate;
import com.google.gerrit.server.update.RetryHelper;
import com.google.gerrit.server.update.RetryHelper.ActionType;
-import com.google.gwtorm.server.OrmException;
import com.google.inject.Inject;
import com.google.inject.Provider;
import java.util.List;
@@ -184,7 +184,7 @@
this.queryBuilder = queryBuilderProvider.get().asUser(anonymousUserProvider.get());
}
- public boolean isCheckerRelevant(Checker checker, ChangeData cd) throws OrmException {
+ public boolean isCheckerRelevant(Checker checker, ChangeData cd) throws StorageException {
if (!checker.getQuery().isPresent()) {
return cd.change().isNew();
}
@@ -221,7 +221,7 @@
* of the allowed set.
*/
public String validate(CheckerUuid checkerUuid, Project.NameKey repository, String query)
- throws ConfigInvalidException, OrmException {
+ throws ConfigInvalidException, StorageException {
// This parses the query string twice, which is unavoidable since there is currently no
// QueryProcessor API which takes an Antlr Tree. That's ok; the parse cost is vastly outweighed
// by the actual query execution.
@@ -235,7 +235,7 @@
}
public List<ChangeData> queryMatchingChanges(Checker checker)
- throws ConfigInvalidException, OrmException {
+ throws ConfigInvalidException, StorageException {
return queryMatchingChanges(
checker.getUuid(), checker.getRepository(), checker.getQuery(), qp -> {});
}
@@ -245,7 +245,7 @@
Project.NameKey repository,
Optional<String> optionalQuery,
Consumer<ChangeQueryProcessor> queryProcessorSetup)
- throws ConfigInvalidException, OrmException {
+ throws ConfigInvalidException, StorageException {
try {
return executeIndexQueryWithRetry(
queryProcessorSetup, createQueryPredicate(checkerUuid, repository, optionalQuery));
@@ -299,7 +299,7 @@
// TODO(ekempin): Retrying the query should be done by ChangeQueryProcessor.
private List<ChangeData> executeIndexQueryWithRetry(
Consumer<ChangeQueryProcessor> queryProcessorSetup, Predicate<ChangeData> predicate)
- throws OrmException, QueryParseException {
+ throws StorageException, QueryParseException {
try {
return retryHelper.execute(
ActionType.INDEX_QUERY,
@@ -308,12 +308,12 @@
queryProcessorSetup.accept(qp);
return qp.query(predicate).entities();
},
- OrmException.class::isInstance);
+ StorageException.class::isInstance);
} catch (Exception e) {
Throwables.throwIfUnchecked(e);
Throwables.throwIfInstanceOf(e, QueryParseException.class);
- Throwables.throwIfInstanceOf(e, OrmException.class);
- throw new OrmException(e);
+ Throwables.throwIfInstanceOf(e, StorageException.class);
+ throw new StorageException(e);
}
}
diff --git a/java/com/google/gerrit/plugins/checks/CheckersUpdate.java b/java/com/google/gerrit/plugins/checks/CheckersUpdate.java
index 41ad59e..874066e 100644
--- a/java/com/google/gerrit/plugins/checks/CheckersUpdate.java
+++ b/java/com/google/gerrit/plugins/checks/CheckersUpdate.java
@@ -14,7 +14,7 @@
package com.google.gerrit.plugins.checks;
-import com.google.gwtorm.server.OrmDuplicateKeyException;
+import com.google.gerrit.exceptions.DuplicateKeyException;
import java.io.IOException;
import org.eclipse.jgit.errors.ConfigInvalidException;
@@ -39,14 +39,14 @@
* @param checkerUpdate an {@code CheckerUpdate} which specifies optional properties of the
* checker. If this {@code CheckerUpdate} updates a property which was already specified by
* the {@code CheckerCreation}, the value of this {@code CheckerUpdate} wins.
- * @throws OrmDuplicateKeyException if a checker with the chosen UUID already exists
+ * @throws DuplicateKeyException if a checker with the chosen UUID already exists
* @throws IOException if an error occurs while reading/writing from/to storage
* @throws ConfigInvalidException if a checker with the same UUID already exists but can't be read
* due to an invalid format
* @return the created {@code Checker}
*/
Checker createChecker(CheckerCreation checkerCreation, CheckerUpdate checkerUpdate)
- throws OrmDuplicateKeyException, IOException, ConfigInvalidException;
+ throws DuplicateKeyException, IOException, ConfigInvalidException;
/**
* Updates the specified checker.
diff --git a/java/com/google/gerrit/plugins/checks/Checks.java b/java/com/google/gerrit/plugins/checks/Checks.java
index 7d6cd03..4c80cd4 100644
--- a/java/com/google/gerrit/plugins/checks/Checks.java
+++ b/java/com/google/gerrit/plugins/checks/Checks.java
@@ -16,10 +16,10 @@
import com.google.auto.value.AutoValue;
import com.google.common.collect.ImmutableList;
+import com.google.gerrit.exceptions.StorageException;
import com.google.gerrit.plugins.checks.api.CombinedCheckState;
import com.google.gerrit.reviewdb.client.PatchSet;
import com.google.gerrit.reviewdb.client.Project;
-import com.google.gwtorm.server.OrmException;
import java.io.IOException;
import java.util.List;
import java.util.Optional;
@@ -42,11 +42,11 @@
* @param patchSetId the ID of the patch set
* @param options options for getting checks.
* @return the checks, {@link Optional#empty()} if no checks with the given UUID exists
- * @throws OrmException if the checks couldn't be retrieved from the storage
+ * @throws StorageException if the checks couldn't be retrieved from the storage
*/
ImmutableList<Check> getChecks(
Project.NameKey projectName, PatchSet.Id patchSetId, GetCheckOptions options)
- throws OrmException, IOException;
+ throws StorageException, IOException;
/**
* Returns a {@link Optional} holding a single check. {@code Optional.empty()} if the check does
@@ -56,11 +56,11 @@
* @param options options for getting a check.
* @return the target check if it exists. A backfilled check will be returned if {@link
* GetCheckOptions#backfillChecks()} is true.
- * @throws OrmException if the check couldn't be retrieved from the storage
+ * @throws StorageException if the check couldn't be retrieved from the storage
* @throws IOException if the check couldn't be retrieved from the storage
*/
Optional<Check> getCheck(CheckKey checkKey, GetCheckOptions options)
- throws OrmException, IOException;
+ throws StorageException, IOException;
/**
* Returns the combined check state of a given patch set.
@@ -69,10 +69,10 @@
* @param patchSetId the ID of the patch set
* @return the {@link CombinedCheckState} of the current patch set.
* @throws IOException if failed to get the {@link CombinedCheckState}.
- * @throws OrmException if failed to get the {@link CombinedCheckState}.
+ * @throws StorageException if failed to get the {@link CombinedCheckState}.
*/
CombinedCheckState getCombinedCheckState(Project.NameKey projectName, PatchSet.Id patchSetId)
- throws IOException, OrmException;
+ throws IOException, StorageException;
@AutoValue
abstract class GetCheckOptions {
diff --git a/java/com/google/gerrit/plugins/checks/ChecksUpdate.java b/java/com/google/gerrit/plugins/checks/ChecksUpdate.java
index 7a44421..ba58afa 100644
--- a/java/com/google/gerrit/plugins/checks/ChecksUpdate.java
+++ b/java/com/google/gerrit/plugins/checks/ChecksUpdate.java
@@ -14,12 +14,12 @@
package com.google.gerrit.plugins.checks;
-import com.google.gwtorm.server.OrmDuplicateKeyException;
+import com.google.gerrit.exceptions.DuplicateKeyException;
import java.io.IOException;
public interface ChecksUpdate {
Check createCheck(CheckKey key, CheckUpdate checkUpdate)
- throws OrmDuplicateKeyException, IOException;
+ throws DuplicateKeyException, IOException;
Check updateCheck(CheckKey key, CheckUpdate checkUpdate) throws IOException;
}
diff --git a/java/com/google/gerrit/plugins/checks/acceptance/testsuite/CheckerOperationsImpl.java b/java/com/google/gerrit/plugins/checks/acceptance/testsuite/CheckerOperationsImpl.java
index 6e7af66..7600dcb 100644
--- a/java/com/google/gerrit/plugins/checks/acceptance/testsuite/CheckerOperationsImpl.java
+++ b/java/com/google/gerrit/plugins/checks/acceptance/testsuite/CheckerOperationsImpl.java
@@ -23,6 +23,7 @@
import com.google.common.base.Splitter;
import com.google.common.collect.ImmutableSet;
import com.google.common.collect.Streams;
+import com.google.gerrit.exceptions.DuplicateKeyException;
import com.google.gerrit.plugins.checks.Checker;
import com.google.gerrit.plugins.checks.CheckerCreation;
import com.google.gerrit.plugins.checks.CheckerJson;
@@ -38,7 +39,6 @@
import com.google.gerrit.server.ServerInitiated;
import com.google.gerrit.server.config.AllProjectsName;
import com.google.gerrit.server.git.GitRepositoryManager;
-import com.google.gwtorm.server.OrmDuplicateKeyException;
import com.google.inject.Inject;
import com.google.inject.Provider;
import com.google.inject.Singleton;
@@ -103,7 +103,7 @@
}
private CheckerUuid createNewChecker(TestCheckerCreation testCheckerCreation)
- throws OrmDuplicateKeyException, ConfigInvalidException, IOException {
+ throws DuplicateKeyException, ConfigInvalidException, IOException {
CheckerCreation checkerCreation = toCheckerCreation(testCheckerCreation);
CheckerUpdate checkerUpdate = toCheckerUpdate(testCheckerCreation);
Checker checker = checkersUpdate.get().createChecker(checkerCreation, checkerUpdate);
diff --git a/java/com/google/gerrit/plugins/checks/api/ChangeCheckAttributeFactory.java b/java/com/google/gerrit/plugins/checks/api/ChangeCheckAttributeFactory.java
index aacbb1e..d2f76b0 100644
--- a/java/com/google/gerrit/plugins/checks/api/ChangeCheckAttributeFactory.java
+++ b/java/com/google/gerrit/plugins/checks/api/ChangeCheckAttributeFactory.java
@@ -14,12 +14,12 @@
package com.google.gerrit.plugins.checks.api;
+import com.google.gerrit.exceptions.StorageException;
import com.google.gerrit.plugins.checks.Checks;
import com.google.gerrit.server.DynamicOptions.BeanProvider;
import com.google.gerrit.server.DynamicOptions.DynamicBean;
import com.google.gerrit.server.change.ChangeAttributeFactory;
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;
@@ -54,14 +54,14 @@
return forGetChange(cd, (GetChangeOptions) opts);
}
// TODO(dborowitz): Compute from cache in query path.
- } catch (OrmException | IOException e) {
+ } catch (StorageException | IOException e) {
throw new RuntimeException(e);
}
throw new IllegalStateException("unexpected options type: " + opts);
}
private ChangeCheckInfo forGetChange(ChangeData cd, GetChangeOptions opts)
- throws OrmException, IOException {
+ throws StorageException, IOException {
if (opts == null || !opts.combined) {
return null;
}
diff --git a/java/com/google/gerrit/plugins/checks/api/ChecksCollection.java b/java/com/google/gerrit/plugins/checks/api/ChecksCollection.java
index 7a02911..666bbe1 100644
--- a/java/com/google/gerrit/plugins/checks/api/ChecksCollection.java
+++ b/java/com/google/gerrit/plugins/checks/api/ChecksCollection.java
@@ -14,6 +14,7 @@
package com.google.gerrit.plugins.checks.api;
+import com.google.gerrit.exceptions.StorageException;
import com.google.gerrit.extensions.registration.DynamicMap;
import com.google.gerrit.extensions.restapi.BadRequestException;
import com.google.gerrit.extensions.restapi.ChildCollection;
@@ -29,7 +30,6 @@
import com.google.gerrit.plugins.checks.Checks.GetCheckOptions;
import com.google.gerrit.server.change.RevisionResource;
import com.google.gerrit.server.permissions.PermissionBackendException;
-import com.google.gwtorm.server.OrmException;
import com.google.inject.Inject;
import com.google.inject.Singleton;
import java.io.IOException;
@@ -56,7 +56,7 @@
@Override
public CheckResource parse(RevisionResource parent, IdString id)
- throws RestApiException, PermissionBackendException, IOException, OrmException {
+ throws RestApiException, PermissionBackendException, IOException, StorageException {
CheckerUuid checkerUuid =
CheckerUuid.tryParse(id.get())
.orElseThrow(
diff --git a/java/com/google/gerrit/plugins/checks/api/CreateChecker.java b/java/com/google/gerrit/plugins/checks/api/CreateChecker.java
index a935f14..c722bfc 100644
--- a/java/com/google/gerrit/plugins/checks/api/CreateChecker.java
+++ b/java/com/google/gerrit/plugins/checks/api/CreateChecker.java
@@ -16,6 +16,8 @@
import com.google.common.base.Strings;
import com.google.common.collect.ImmutableSortedSet;
+import com.google.gerrit.exceptions.DuplicateKeyException;
+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.ResourceConflictException;
@@ -41,8 +43,6 @@
import com.google.gerrit.server.permissions.PermissionBackendException;
import com.google.gerrit.server.project.ProjectCache;
import com.google.gerrit.server.project.ProjectState;
-import com.google.gwtorm.server.OrmDuplicateKeyException;
-import com.google.gwtorm.server.OrmException;
import com.google.inject.Inject;
import com.google.inject.Provider;
import com.google.inject.Singleton;
@@ -81,7 +81,7 @@
@Override
public Response<CheckerInfo> apply(TopLevelResource parentResource, CheckerInput input)
throws RestApiException, PermissionBackendException, IOException, ConfigInvalidException,
- OrmException {
+ StorageException {
if (!self.get().isIdentifiedUser()) {
throw new AuthException("Authentication required");
}
@@ -129,7 +129,7 @@
.get()
.createChecker(checkerCreationBuilder.build(), checkerUpdateBuilder.build());
return Response.created(checkerJson.format(checker));
- } catch (OrmDuplicateKeyException e) {
+ } catch (DuplicateKeyException e) {
throw new ResourceConflictException(e.getMessage());
}
}
@@ -149,7 +149,7 @@
}
private String validateQuery(CheckerUuid checkerUuid, Project.NameKey repository, String query)
- throws BadRequestException, OrmException {
+ throws BadRequestException, StorageException {
try {
return checkerQueryProvider.get().validate(checkerUuid, repository, query);
} catch (ConfigInvalidException e) {
diff --git a/java/com/google/gerrit/plugins/checks/api/ListChecks.java b/java/com/google/gerrit/plugins/checks/api/ListChecks.java
index ed76af0..21b2734 100644
--- a/java/com/google/gerrit/plugins/checks/api/ListChecks.java
+++ b/java/com/google/gerrit/plugins/checks/api/ListChecks.java
@@ -15,6 +15,7 @@
package com.google.gerrit.plugins.checks.api;
import com.google.common.collect.ImmutableList;
+import com.google.gerrit.exceptions.StorageException;
import com.google.gerrit.extensions.client.ListOption;
import com.google.gerrit.extensions.restapi.AuthException;
import com.google.gerrit.extensions.restapi.BadRequestException;
@@ -26,7 +27,6 @@
import com.google.gerrit.plugins.checks.Checks.GetCheckOptions;
import com.google.gerrit.plugins.checks.ListChecksOption;
import com.google.gerrit.server.change.RevisionResource;
-import com.google.gwtorm.server.OrmException;
import com.google.inject.Inject;
import java.io.IOException;
import java.util.EnumSet;
@@ -56,7 +56,7 @@
@Override
public ImmutableList<CheckInfo> apply(RevisionResource resource)
- throws AuthException, BadRequestException, ResourceConflictException, OrmException,
+ throws AuthException, BadRequestException, ResourceConflictException, StorageException,
IOException {
ImmutableList.Builder<CheckInfo> result = ImmutableList.builder();
diff --git a/java/com/google/gerrit/plugins/checks/api/PostCheck.java b/java/com/google/gerrit/plugins/checks/api/PostCheck.java
index d6934e7..0780e60 100644
--- a/java/com/google/gerrit/plugins/checks/api/PostCheck.java
+++ b/java/com/google/gerrit/plugins/checks/api/PostCheck.java
@@ -14,6 +14,7 @@
package com.google.gerrit.plugins.checks.api;
+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;
@@ -35,7 +36,6 @@
import com.google.gerrit.server.change.RevisionResource;
import com.google.gerrit.server.permissions.PermissionBackend;
import com.google.gerrit.server.permissions.PermissionBackendException;
-import com.google.gwtorm.server.OrmException;
import java.io.IOException;
import java.util.Optional;
import javax.inject.Inject;
@@ -74,7 +74,7 @@
@Override
public CheckInfo apply(RevisionResource rsrc, CheckInput input)
- throws OrmException, IOException, RestApiException, PermissionBackendException,
+ throws StorageException, IOException, RestApiException, PermissionBackendException,
ConfigInvalidException {
if (!self.get().isIdentifiedUser()) {
throw new AuthException("Authentication required");
diff --git a/java/com/google/gerrit/plugins/checks/api/QueryPendingChecks.java b/java/com/google/gerrit/plugins/checks/api/QueryPendingChecks.java
index 908aa30..a620493 100644
--- a/java/com/google/gerrit/plugins/checks/api/QueryPendingChecks.java
+++ b/java/com/google/gerrit/plugins/checks/api/QueryPendingChecks.java
@@ -18,6 +18,7 @@
import com.google.common.collect.ImmutableList;
import com.google.common.collect.ImmutableMap;
+import com.google.gerrit.exceptions.StorageException;
import com.google.gerrit.extensions.restapi.BadRequestException;
import com.google.gerrit.extensions.restapi.RestApiException;
import com.google.gerrit.extensions.restapi.RestReadView;
@@ -39,7 +40,6 @@
import com.google.gerrit.reviewdb.client.PatchSet;
import com.google.gerrit.reviewdb.client.Project;
import com.google.gerrit.server.query.change.ChangeData;
-import com.google.gwtorm.server.OrmException;
import com.google.inject.Inject;
import com.google.inject.Provider;
import java.io.IOException;
@@ -80,13 +80,13 @@
}
public List<PendingChecksInfo> apply()
- throws RestApiException, IOException, ConfigInvalidException, OrmException {
+ throws RestApiException, IOException, ConfigInvalidException, StorageException {
return apply(TopLevelResource.INSTANCE);
}
@Override
public List<PendingChecksInfo> apply(TopLevelResource resource)
- throws RestApiException, IOException, ConfigInvalidException, OrmException {
+ throws RestApiException, IOException, ConfigInvalidException, StorageException {
if (queryString == null) {
throw new BadRequestException("query is required");
}
diff --git a/java/com/google/gerrit/plugins/checks/api/UpdateCheck.java b/java/com/google/gerrit/plugins/checks/api/UpdateCheck.java
index 2a97201..ef7539f 100644
--- a/java/com/google/gerrit/plugins/checks/api/UpdateCheck.java
+++ b/java/com/google/gerrit/plugins/checks/api/UpdateCheck.java
@@ -14,11 +14,11 @@
package com.google.gerrit.plugins.checks.api;
+import com.google.gerrit.exceptions.StorageException;
import com.google.gerrit.extensions.restapi.BadRequestException;
import com.google.gerrit.extensions.restapi.RestApiException;
import com.google.gerrit.extensions.restapi.RestModifyView;
import com.google.gerrit.server.permissions.PermissionBackendException;
-import com.google.gwtorm.server.OrmException;
import com.google.inject.Inject;
import com.google.inject.Singleton;
import java.io.IOException;
@@ -35,7 +35,7 @@
@Override
public CheckInfo apply(CheckResource checkResource, CheckInput input)
- throws RestApiException, IOException, OrmException, PermissionBackendException,
+ throws RestApiException, IOException, StorageException, PermissionBackendException,
ConfigInvalidException {
if (input == null) {
input = new CheckInput();
diff --git a/java/com/google/gerrit/plugins/checks/api/UpdateChecker.java b/java/com/google/gerrit/plugins/checks/api/UpdateChecker.java
index 1892351..c1dc7f5 100644
--- a/java/com/google/gerrit/plugins/checks/api/UpdateChecker.java
+++ b/java/com/google/gerrit/plugins/checks/api/UpdateChecker.java
@@ -15,6 +15,7 @@
package com.google.gerrit.plugins.checks.api;
import com.google.common.collect.ImmutableSortedSet;
+import com.google.gerrit.exceptions.StorageException;
import com.google.gerrit.extensions.restapi.BadRequestException;
import com.google.gerrit.extensions.restapi.RestApiException;
import com.google.gerrit.extensions.restapi.RestModifyView;
@@ -35,7 +36,6 @@
import com.google.gerrit.server.permissions.PermissionBackendException;
import com.google.gerrit.server.project.ProjectCache;
import com.google.gerrit.server.project.ProjectState;
-import com.google.gwtorm.server.OrmException;
import com.google.inject.Inject;
import com.google.inject.Provider;
import java.io.IOException;
@@ -70,7 +70,7 @@
@Override
public CheckerInfo apply(CheckerResource resource, CheckerInput input)
throws RestApiException, PermissionBackendException, NoSuchCheckerException, IOException,
- ConfigInvalidException, OrmException {
+ ConfigInvalidException, StorageException {
permissionBackend.currentUser().check(permission);
CheckerUuid checkerUuid = resource.getChecker().getUuid();
@@ -138,7 +138,7 @@
}
private String validateQuery(CheckerUuid checkerUuid, Project.NameKey repository, String query)
- throws BadRequestException, OrmException {
+ throws BadRequestException, StorageException {
try {
return checkerQueryProvider.get().validate(checkerUuid, repository, query);
} catch (ConfigInvalidException e) {
diff --git a/java/com/google/gerrit/plugins/checks/db/CheckBackfiller.java b/java/com/google/gerrit/plugins/checks/db/CheckBackfiller.java
index 41d3592..512b63e 100644
--- a/java/com/google/gerrit/plugins/checks/db/CheckBackfiller.java
+++ b/java/com/google/gerrit/plugins/checks/db/CheckBackfiller.java
@@ -15,6 +15,7 @@
package com.google.gerrit.plugins.checks.db;
import com.google.common.collect.ImmutableList;
+import com.google.gerrit.exceptions.StorageException;
import com.google.gerrit.plugins.checks.Check;
import com.google.gerrit.plugins.checks.Checker;
import com.google.gerrit.plugins.checks.CheckerQuery;
@@ -23,7 +24,6 @@
import com.google.gerrit.plugins.checks.api.CheckerStatus;
import com.google.gerrit.reviewdb.client.PatchSet;
import com.google.gerrit.server.query.change.ChangeData;
-import com.google.gwtorm.server.OrmException;
import com.google.inject.Inject;
import com.google.inject.Provider;
import com.google.inject.Singleton;
@@ -44,7 +44,7 @@
}
ImmutableList<Check> getBackfilledChecksForRelevantCheckers(
- Collection<Checker> candidates, ChangeData cd, PatchSet.Id psId) throws OrmException {
+ Collection<Checker> candidates, ChangeData cd, PatchSet.Id psId) throws StorageException {
if (candidates.isEmpty()) {
return ImmutableList.of();
}
@@ -68,7 +68,7 @@
}
Optional<Check> getBackfilledCheckForRelevantChecker(
- CheckerUuid candidate, ChangeData cd, PatchSet.Id psId) throws OrmException, IOException {
+ CheckerUuid candidate, ChangeData cd, PatchSet.Id psId) throws StorageException, IOException {
if (!psId.equals(cd.change().currentPatchSetId())) {
// The query system can only match against the current patch set; it doesn't make sense to
// backfill checkers for old patch sets.
diff --git a/java/com/google/gerrit/plugins/checks/db/CheckerConfig.java b/java/com/google/gerrit/plugins/checks/db/CheckerConfig.java
index 98738d4..61bd436 100644
--- a/java/com/google/gerrit/plugins/checks/db/CheckerConfig.java
+++ b/java/com/google/gerrit/plugins/checks/db/CheckerConfig.java
@@ -19,6 +19,7 @@
import com.google.common.annotations.VisibleForTesting;
import com.google.common.base.Strings;
+import com.google.gerrit.exceptions.DuplicateKeyException;
import com.google.gerrit.plugins.checks.Checker;
import com.google.gerrit.plugins.checks.CheckerCreation;
import com.google.gerrit.plugins.checks.CheckerRef;
@@ -31,7 +32,6 @@
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.Arrays;
@@ -91,11 +91,11 @@
* @throws IOException if the repository can't be accessed for some reason
* @throws ConfigInvalidException if a checker with the same UUID already exists but can't be read
* due to an invalid format
- * @throws OrmDuplicateKeyException if a checker with the same UUID already exists
+ * @throws DuplicateKeyException if a checker with the same UUID already exists
*/
public static CheckerConfig createForNewChecker(
Project.NameKey projectName, Repository repository, CheckerCreation checkerCreation)
- throws IOException, ConfigInvalidException, OrmDuplicateKeyException {
+ throws IOException, ConfigInvalidException, DuplicateKeyException {
CheckerConfig checkerConfig =
loadForChecker(projectName, repository, checkerCreation.getCheckerUuid());
checkerConfig.setCheckerCreation(checkerCreation);
@@ -226,10 +226,10 @@
this.checkerUpdate = Optional.of(checkerUpdate);
}
- private void setCheckerCreation(CheckerCreation checkerCreation) throws OrmDuplicateKeyException {
+ private void setCheckerCreation(CheckerCreation checkerCreation) throws DuplicateKeyException {
checkLoaded();
if (loadedChecker.isPresent()) {
- throw new OrmDuplicateKeyException(
+ throw new DuplicateKeyException(
String.format("Checker %s already exists", loadedChecker.get().getUuid()));
}
diff --git a/java/com/google/gerrit/plugins/checks/db/NoteDbCheckersUpdate.java b/java/com/google/gerrit/plugins/checks/db/NoteDbCheckersUpdate.java
index 5c3ccd6..7c106e7 100644
--- a/java/com/google/gerrit/plugins/checks/db/NoteDbCheckersUpdate.java
+++ b/java/com/google/gerrit/plugins/checks/db/NoteDbCheckersUpdate.java
@@ -15,6 +15,7 @@
package com.google.gerrit.plugins.checks.db;
import com.google.common.base.Throwables;
+import com.google.gerrit.exceptions.DuplicateKeyException;
import com.google.gerrit.git.LockFailureException;
import com.google.gerrit.git.RefUpdateUtil;
import com.google.gerrit.plugins.checks.Checker;
@@ -33,7 +34,6 @@
import com.google.gerrit.server.git.meta.MetaDataUpdate;
import com.google.gerrit.server.update.RetryHelper;
import com.google.gerrit.server.update.RetryHelper.ActionType;
-import com.google.gwtorm.server.OrmDuplicateKeyException;
import com.google.inject.assistedinject.Assisted;
import com.google.inject.assistedinject.AssistedInject;
import java.io.IOException;
@@ -135,7 +135,7 @@
@Override
public Checker createChecker(CheckerCreation checkerCreation, CheckerUpdate checkerUpdate)
- throws OrmDuplicateKeyException, IOException, ConfigInvalidException {
+ throws DuplicateKeyException, IOException, ConfigInvalidException {
try {
return retryHelper.execute(
RetryHelper.ActionType.PLUGIN_UPDATE,
@@ -143,7 +143,7 @@
LockFailureException.class::isInstance);
} catch (Exception e) {
Throwables.throwIfUnchecked(e);
- Throwables.throwIfInstanceOf(e, OrmDuplicateKeyException.class);
+ Throwables.throwIfInstanceOf(e, DuplicateKeyException.class);
Throwables.throwIfInstanceOf(e, IOException.class);
Throwables.throwIfInstanceOf(e, ConfigInvalidException.class);
throw new IOException(e);
@@ -152,7 +152,7 @@
private Checker createCheckerInNoteDb(
CheckerCreation checkerCreation, CheckerUpdate checkerUpdate)
- throws OrmDuplicateKeyException, IOException, ConfigInvalidException {
+ throws DuplicateKeyException, IOException, ConfigInvalidException {
try (Repository allProjectsRepo = repoManager.openRepository(allProjectsName)) {
CheckerConfig checkerConfig =
CheckerConfig.createForNewChecker(allProjectsName, allProjectsRepo, checkerCreation);
diff --git a/java/com/google/gerrit/plugins/checks/db/NoteDbChecks.java b/java/com/google/gerrit/plugins/checks/db/NoteDbChecks.java
index 8a3f2fd..69c8665 100644
--- a/java/com/google/gerrit/plugins/checks/db/NoteDbChecks.java
+++ b/java/com/google/gerrit/plugins/checks/db/NoteDbChecks.java
@@ -21,6 +21,7 @@
import com.google.common.collect.ImmutableListMultimap;
import com.google.common.collect.ImmutableMap;
import com.google.common.collect.ImmutableSet;
+import com.google.gerrit.exceptions.StorageException;
import com.google.gerrit.plugins.checks.Check;
import com.google.gerrit.plugins.checks.CheckKey;
import com.google.gerrit.plugins.checks.Checker;
@@ -36,7 +37,6 @@
import com.google.gerrit.reviewdb.client.Project;
import com.google.gerrit.reviewdb.client.Project.NameKey;
import com.google.gerrit.server.query.change.ChangeData;
-import com.google.gwtorm.server.OrmException;
import com.google.inject.Inject;
import com.google.inject.Provider;
import com.google.inject.Singleton;
@@ -72,13 +72,13 @@
@Override
public ImmutableList<Check> getChecks(
Project.NameKey projectName, PatchSet.Id psId, GetCheckOptions options)
- throws IOException, OrmException {
+ throws IOException, StorageException {
return getChecksFromNoteDb(projectName, psId, options);
}
@Override
public Optional<Check> getCheck(CheckKey checkKey, GetCheckOptions options)
- throws OrmException, IOException {
+ throws StorageException, IOException {
// TODO(gerrit-team): Instead of reading the complete notes map, read just one note.
Optional<Check> result =
getChecksFromNoteDb(checkKey.repository(), checkKey.patchSet(), GetCheckOptions.defaults())
@@ -98,7 +98,7 @@
private ImmutableList<Check> getChecksFromNoteDb(
Project.NameKey repositoryName, PatchSet.Id psId, GetCheckOptions options)
- throws OrmException, IOException {
+ throws StorageException, IOException {
// TODO(gerrit-team): Instead of reading the complete notes map, read just one note.
ChangeData changeData = changeDataFactory.create(repositoryName, psId.getParentKey());
PatchSet patchSet = changeData.patchSet(psId);
@@ -127,7 +127,7 @@
@Override
public CombinedCheckState getCombinedCheckState(NameKey projectName, Id patchSetId)
- throws IOException, OrmException {
+ throws IOException, StorageException {
ChangeData changeData = changeDataFactory.create(projectName, patchSetId.changeId);
CheckerQuery checkerQuery = checkerQueryProvider.get();
ImmutableMap<String, Checker> allCheckersOfProject =
diff --git a/java/com/google/gerrit/plugins/checks/db/NoteDbChecksUpdate.java b/java/com/google/gerrit/plugins/checks/db/NoteDbChecksUpdate.java
index cb57c79..fe00c4d 100644
--- a/java/com/google/gerrit/plugins/checks/db/NoteDbChecksUpdate.java
+++ b/java/com/google/gerrit/plugins/checks/db/NoteDbChecksUpdate.java
@@ -20,6 +20,7 @@
import com.google.common.base.Throwables;
import com.google.common.collect.Maps;
+import com.google.gerrit.exceptions.DuplicateKeyException;
import com.google.gerrit.git.LockFailureException;
import com.google.gerrit.git.RefUpdateUtil;
import com.google.gerrit.plugins.checks.Check;
@@ -36,7 +37,6 @@
import com.google.gerrit.server.git.GitRepositoryManager;
import com.google.gerrit.server.notedb.ChangeNoteUtil;
import com.google.gerrit.server.update.RetryHelper;
-import com.google.gwtorm.server.OrmDuplicateKeyException;
import com.google.inject.assistedinject.Assisted;
import com.google.inject.assistedinject.AssistedInject;
import java.io.ByteArrayOutputStream;
@@ -126,7 +126,7 @@
@Override
public Check createCheck(CheckKey checkKey, CheckUpdate checkUpdate)
- throws OrmDuplicateKeyException, IOException {
+ throws DuplicateKeyException, IOException {
try {
return retryHelper.execute(
RetryHelper.ActionType.PLUGIN_UPDATE,
@@ -134,7 +134,7 @@
LockFailureException.class::isInstance);
} catch (Exception e) {
Throwables.throwIfUnchecked(e);
- Throwables.throwIfInstanceOf(e, OrmDuplicateKeyException.class);
+ Throwables.throwIfInstanceOf(e, DuplicateKeyException.class);
Throwables.throwIfInstanceOf(e, IOException.class);
throw new IOException(e);
}
@@ -155,7 +155,7 @@
}
private Check upsertCheckInNoteDb(CheckKey checkKey, CheckUpdate checkUpdate, Operation operation)
- throws IOException, ConfigInvalidException, OrmDuplicateKeyException {
+ throws IOException, ConfigInvalidException, DuplicateKeyException {
if (operation == Operation.CREATE) {
assertCheckerIsPresent(checkKey.checkerUuid());
}
@@ -216,7 +216,7 @@
ObjectId curr,
CommitBuilder cb,
Operation operation)
- throws ConfigInvalidException, IOException, OrmDuplicateKeyException {
+ throws ConfigInvalidException, IOException, DuplicateKeyException {
Ref patchSetRef = repo.exactRef(checkKey.patchSet().toRefName());
if (patchSetRef == null) {
throw new IOException(String.format("patchset %s not found", checkKey.patchSet()));
@@ -247,7 +247,7 @@
writeNotesMap(newNotes, cb, ins);
return true;
} else if (operation == Operation.CREATE) {
- throw new OrmDuplicateKeyException(
+ throw new DuplicateKeyException(
String.format("checker %s already exists", checkKey.checkerUuid()));
}
diff --git a/java/com/google/gerrit/plugins/checks/index/CheckStatePredicate.java b/java/com/google/gerrit/plugins/checks/index/CheckStatePredicate.java
index 74cca68..3d9e21b 100644
--- a/java/com/google/gerrit/plugins/checks/index/CheckStatePredicate.java
+++ b/java/com/google/gerrit/plugins/checks/index/CheckStatePredicate.java
@@ -17,10 +17,10 @@
import static java.util.Objects.requireNonNull;
import com.google.common.base.Enums;
+import com.google.gerrit.exceptions.StorageException;
import com.google.gerrit.index.query.QueryParseException;
import com.google.gerrit.plugins.checks.Check;
import com.google.gerrit.plugins.checks.api.CheckState;
-import com.google.gwtorm.server.OrmException;
import java.util.Optional;
public class CheckStatePredicate extends CheckPredicate {
@@ -53,7 +53,7 @@
}
@Override
- public boolean match(Check check) throws OrmException {
+ public boolean match(Check check) throws StorageException {
return checkState.equals(check.state());
}
}
diff --git a/java/com/google/gerrit/plugins/checks/index/CheckerPredicate.java b/java/com/google/gerrit/plugins/checks/index/CheckerPredicate.java
index 0050ce9..e4de380 100644
--- a/java/com/google/gerrit/plugins/checks/index/CheckerPredicate.java
+++ b/java/com/google/gerrit/plugins/checks/index/CheckerPredicate.java
@@ -16,10 +16,10 @@
import static java.util.Objects.requireNonNull;
+import com.google.gerrit.exceptions.StorageException;
import com.google.gerrit.index.query.QueryParseException;
import com.google.gerrit.plugins.checks.Check;
import com.google.gerrit.plugins.checks.CheckerUuid;
-import com.google.gwtorm.server.OrmException;
public class CheckerPredicate extends CheckPredicate {
public static CheckerPredicate parse(String value) throws QueryParseException {
@@ -37,7 +37,7 @@
}
@Override
- public boolean match(Check check) throws OrmException {
+ public boolean match(Check check) throws StorageException {
return checkerUuid.equals(check.key().checkerUuid());
}
diff --git a/java/com/google/gerrit/plugins/checks/rules/ChecksSubmitRule.java b/java/com/google/gerrit/plugins/checks/rules/ChecksSubmitRule.java
index 30b5b5c..5a8cbf6 100644
--- a/java/com/google/gerrit/plugins/checks/rules/ChecksSubmitRule.java
+++ b/java/com/google/gerrit/plugins/checks/rules/ChecksSubmitRule.java
@@ -20,6 +20,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.exceptions.StorageException;
import com.google.gerrit.extensions.annotations.Exports;
import com.google.gerrit.extensions.config.FactoryModule;
import com.google.gerrit.plugins.checks.Checks;
@@ -30,7 +31,6 @@
import com.google.gerrit.server.project.SubmitRuleOptions;
import com.google.gerrit.server.query.change.ChangeData;
import com.google.gerrit.server.rules.SubmitRule;
-import com.google.gwtorm.server.OrmException;
import com.google.inject.Inject;
import com.google.inject.Singleton;
import java.io.IOException;
@@ -70,7 +70,7 @@
PatchSet.Id currentPathSetId;
try {
currentPathSetId = changeData.currentPatchSet().getId();
- } catch (OrmException e) {
+ } catch (StorageException e) {
String errorMessage =
String.format("failed to load the current patch set of change %s", changeId);
logger.atSevere().withCause(e).log(errorMessage);
@@ -80,7 +80,7 @@
CombinedCheckState combinedCheckState;
try {
combinedCheckState = checks.getCombinedCheckState(project, currentPathSetId);
- } catch (IOException | OrmException e) {
+ } catch (IOException | StorageException e) {
String errorMessage =
String.format("failed to evaluate check states for change %s", changeId);
logger.atSevere().withCause(e).log(errorMessage);
diff --git a/javatests/com/google/gerrit/plugins/checks/rules/BUILD b/javatests/com/google/gerrit/plugins/checks/rules/BUILD
index 8fc3b58..60e3d91 100644
--- a/javatests/com/google/gerrit/plugins/checks/rules/BUILD
+++ b/javatests/com/google/gerrit/plugins/checks/rules/BUILD
@@ -6,6 +6,7 @@
srcs = glob(["*.java"]),
deps = [
"//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/gerrit/testing:gerrit-test-util",
diff --git a/javatests/com/google/gerrit/plugins/checks/rules/ChecksSubmitRuleTest.java b/javatests/com/google/gerrit/plugins/checks/rules/ChecksSubmitRuleTest.java
index 27f7522..43a5090 100644
--- a/javatests/com/google/gerrit/plugins/checks/rules/ChecksSubmitRuleTest.java
+++ b/javatests/com/google/gerrit/plugins/checks/rules/ChecksSubmitRuleTest.java
@@ -21,6 +21,7 @@
import com.google.common.collect.Iterables;
import com.google.gerrit.common.data.SubmitRecord;
+import com.google.gerrit.exceptions.StorageException;
import com.google.gerrit.plugins.checks.Checks;
import com.google.gerrit.reviewdb.client.Change;
import com.google.gerrit.reviewdb.client.PatchSet;
@@ -28,7 +29,6 @@
import com.google.gerrit.server.project.SubmitRuleOptions;
import com.google.gerrit.server.query.change.ChangeData;
import com.google.gerrit.testing.GerritBaseTests;
-import com.google.gwtorm.server.OrmException;
import java.util.Collection;
import org.easymock.EasyMock;
import org.junit.Test;
@@ -42,7 +42,7 @@
ChangeData cd = EasyMock.createStrictMock(ChangeData.class);
expect(cd.project()).andReturn(new Project.NameKey("My-Project"));
expect(cd.getId()).andReturn(new Change.Id(1));
- expect(cd.currentPatchSet()).andThrow(new OrmException("Fail for test"));
+ expect(cd.currentPatchSet()).andThrow(new StorageException("Fail for test"));
replay(cd);
Collection<SubmitRecord> submitRecords =
@@ -54,7 +54,7 @@
public void getCombinedCheckStateFails() throws Exception {
Checks checks = EasyMock.createStrictMock(Checks.class);
expect(checks.getCombinedCheckState(anyObject(), anyObject()))
- .andThrow(new OrmException("Fail for test"));
+ .andThrow(new StorageException("Fail for test"));
replay(checks);
ChecksSubmitRule checksSubmitRule = new ChecksSubmitRule(checks);