Adapt to new StorageException class name and package
Change-Id: I75cd47a6189c5cff2ca7e8ee92ef678abb8fe44d
diff --git a/src/main/java/com/googlesource/gerrit/plugins/findowners/Action.java b/src/main/java/com/googlesource/gerrit/plugins/findowners/Action.java
index 85b3f2a..2d5e78c 100644
--- a/src/main/java/com/googlesource/gerrit/plugins/findowners/Action.java
+++ b/src/main/java/com/googlesource/gerrit/plugins/findowners/Action.java
@@ -18,6 +18,7 @@
import com.google.common.collect.Streams;
import com.google.common.flogger.FluentLogger;
+import com.google.gerrit.exceptions.StorageException;
import com.google.gerrit.extensions.restapi.BadRequestException;
import com.google.gerrit.extensions.restapi.Response;
import com.google.gerrit.extensions.restapi.RestReadView;
@@ -35,7 +36,6 @@
import com.google.gerrit.server.project.ProjectCache;
import com.google.gerrit.server.project.ProjectState;
import com.google.gerrit.server.query.change.ChangeData;
-import com.google.gwtorm.server.OrmException;
import com.google.inject.Inject;
import com.google.inject.Provider;
import java.io.IOException;
@@ -109,13 +109,13 @@
@Override
public Response<RestResult> apply(RevisionResource rev)
- throws IOException, OrmException, BadRequestException {
+ throws IOException, StorageException, BadRequestException {
return apply(rev.getChangeResource(), new Parameters());
}
// Used by integration tests, because they do not have ReviewDb Provider.
public Response<RestResult> apply(ChangeResource rsrc, Parameters params)
- throws IOException, OrmException, BadRequestException {
+ throws IOException, StorageException, BadRequestException {
ChangeData changeData = changeDataFactory.create(rsrc.getChange());
return getChangeData(params, changeData);
}
@@ -130,7 +130,7 @@
.map(a -> a.getAccount().getPreferredEmail())
.filter(Objects::nonNull)
.collect(toList());
- } catch (OrmException e) {
+ } catch (StorageException e) {
logger.atSevere().withCause(e).log("Exception for %s", Config.getChangeId(changeData));
return new ArrayList<>();
}
@@ -138,7 +138,7 @@
/** Returns the current patchset number or the given patchsetNum if it is valid. */
static int getValidPatchsetNum(ChangeData changeData, Integer patchsetNum)
- throws OrmException, BadRequestException {
+ throws StorageException, BadRequestException {
int patchset = changeData.currentPatchSet().getId().get();
if (patchsetNum != null) {
if (patchsetNum < 1 || patchsetNum > patchset) {
@@ -155,7 +155,7 @@
/** REST API to return owners info of a change. */
public Response<RestResult> getChangeData(Parameters params, ChangeData changeData)
- throws OrmException, BadRequestException, IOException {
+ throws StorageException, BadRequestException, IOException {
int patchset = getValidPatchsetNum(changeData, params.patchset);
ProjectState projectState = projectCache.get(changeData.project());
Boolean useCache = params.nocache == null || !params.nocache;
@@ -235,7 +235,7 @@
.setLabel("Find Owners")
.setTitle("Find owners to add to Reviewers list")
.setVisible(needFindOwners);
- } catch (IOException | OrmException e) {
+ } catch (IOException | StorageException e) {
logger.atSevere().withCause(e).log("Exception for %s", Config.getChangeId(changeData));
throw new IllegalStateException(e);
}
diff --git a/src/main/java/com/googlesource/gerrit/plugins/findowners/Cache.java b/src/main/java/com/googlesource/gerrit/plugins/findowners/Cache.java
index 072c087..71fa1f9 100644
--- a/src/main/java/com/googlesource/gerrit/plugins/findowners/Cache.java
+++ b/src/main/java/com/googlesource/gerrit/plugins/findowners/Cache.java
@@ -18,13 +18,13 @@
import com.google.common.cache.CacheBuilder;
import com.google.common.flogger.FluentLogger;
+import com.google.gerrit.exceptions.StorageException;
import com.google.gerrit.server.account.AccountCache;
import com.google.gerrit.server.account.Emails;
import com.google.gerrit.server.config.PluginConfigFactory;
import com.google.gerrit.server.git.GitRepositoryManager;
import com.google.gerrit.server.project.ProjectState;
import com.google.gerrit.server.query.change.ChangeData;
-import com.google.gwtorm.server.OrmException;
import java.io.IOException;
import java.util.Collection;
import java.util.Collections;
@@ -98,7 +98,7 @@
GitRepositoryManager repoManager,
PluginConfigFactory configFactory,
ChangeData changeData)
- throws OrmException, IOException {
+ throws StorageException, IOException {
return get(
useCache,
projectState,
@@ -120,7 +120,7 @@
PluginConfigFactory configFactory,
ChangeData changeData,
int patchset)
- throws OrmException, IOException {
+ throws StorageException, IOException {
String branch = changeData.change().getDest().get();
String dbKey = Cache.makeKey(changeData.getId().get(), patchset, repoManager);
// TODO: get changed files of the given patchset?
diff --git a/src/main/java/com/googlesource/gerrit/plugins/findowners/Checker.java b/src/main/java/com/googlesource/gerrit/plugins/findowners/Checker.java
index 21af450..be9558d 100644
--- a/src/main/java/com/googlesource/gerrit/plugins/findowners/Checker.java
+++ b/src/main/java/com/googlesource/gerrit/plugins/findowners/Checker.java
@@ -15,6 +15,7 @@
package com.googlesource.gerrit.plugins.findowners;
import com.google.common.flogger.FluentLogger;
+import com.google.gerrit.exceptions.StorageException;
import com.google.gerrit.reviewdb.client.Change.Status;
import com.google.gerrit.reviewdb.client.PatchSetApproval;
import com.google.gerrit.server.account.AccountCache;
@@ -24,7 +25,6 @@
import com.google.gerrit.server.project.ProjectState;
import com.google.gerrit.server.query.change.ChangeData;
import com.google.gerrit.server.rules.StoredValues;
-import com.google.gwtorm.server.OrmException;
import com.googlecode.prolog_cafe.lang.Prolog;
import java.io.IOException;
import java.util.HashMap;
@@ -63,7 +63,7 @@
/** Returns a map from reviewer email to vote value. */
Map<String, Integer> getVotes(AccountCache accountCache, ChangeData changeData)
- throws OrmException {
+ throws StorageException {
Map<String, Integer> map = new HashMap<>();
for (PatchSetApproval p : changeData.currentApprovals()) {
// Only collect non-zero Code-Review votes.
@@ -107,7 +107,7 @@
}
/** Returns 1 if owner approval is found, -1 if missing, 0 if unneeded. */
- int findApproval(AccountCache accountCache, OwnersDb db) throws OrmException, IOException {
+ int findApproval(AccountCache accountCache, OwnersDb db) throws StorageException, IOException {
Map<String, Set<String>> file2Owners = db.findOwners(changeData.currentFilePaths());
if (file2Owners.isEmpty()) { // do not need owner approval
return 0;
@@ -135,14 +135,14 @@
minVoteLevel);
return checker.findApproval(
StoredValues.ACCOUNT_CACHE.get(engine), StoredValues.EMAILS.get(engine));
- } catch (OrmException | IOException e) {
+ } catch (StorageException | IOException e) {
logger.atSevere().withCause(e).log("Exception for %s ", Config.getChangeId(changeData));
return 0; // owner approval may or may not be required.
}
}
/** Returns 1 if owner approval is found, -1 if missing, 0 if unneeded. */
- int findApproval(AccountCache accountCache, Emails emails) throws OrmException, IOException {
+ int findApproval(AccountCache accountCache, Emails emails) throws StorageException, IOException {
if (isExemptFromOwnerApproval(changeData)) {
return 0;
}
@@ -162,13 +162,13 @@
}
/** Returns true if exempt from owner approval. */
- static boolean isExemptFromOwnerApproval(ChangeData changeData) throws OrmException {
+ static boolean isExemptFromOwnerApproval(ChangeData changeData) throws StorageException {
try {
String message = changeData.commitMessage();
if (message.contains(EXEMPT_MESSAGE1) || message.contains(EXEMPT_MESSAGE2)) {
return true;
}
- } catch (IOException | OrmException e) {
+ } catch (IOException | StorageException e) {
logger.atSevere().withCause(e).log(
"Cannot get commit message for %s", Config.getChangeId(changeData));
return true; // exempt from owner approval due to lack of data
diff --git a/src/main/java/com/googlesource/gerrit/plugins/findowners/GetOwners.java b/src/main/java/com/googlesource/gerrit/plugins/findowners/GetOwners.java
index f08056d..5735ced 100644
--- a/src/main/java/com/googlesource/gerrit/plugins/findowners/GetOwners.java
+++ b/src/main/java/com/googlesource/gerrit/plugins/findowners/GetOwners.java
@@ -15,6 +15,7 @@
package com.googlesource.gerrit.plugins.findowners;
import com.google.common.flogger.FluentLogger;
+import com.google.gerrit.exceptions.StorageException;
import com.google.gerrit.extensions.restapi.BadRequestException;
import com.google.gerrit.extensions.restapi.Response;
import com.google.gerrit.extensions.restapi.RestReadView;
@@ -26,7 +27,6 @@
import com.google.gerrit.server.git.GitRepositoryManager;
import com.google.gerrit.server.project.ProjectCache;
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;
@@ -71,7 +71,7 @@
}
@Override
- public Response<RestResult> apply(ChangeResource rsrc) throws IOException, OrmException {
+ public Response<RestResult> apply(ChangeResource rsrc) throws IOException, StorageException {
Action.Parameters params = new Action.Parameters();
params.patchset = patchset;
params.debug = (debug != null) ? Util.parseBoolean(debug) : null;