Adapt to removal of SchemaFactory

Change-Id: If6410bfc7539cde9f64cf169c46be6dabffd9075
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 8b33f73..8edb479 100644
--- a/src/main/java/com/googlesource/gerrit/plugins/findowners/Action.java
+++ b/src/main/java/com/googlesource/gerrit/plugins/findowners/Action.java
@@ -26,7 +26,6 @@
 import com.google.gerrit.extensions.webui.UiAction;
 import com.google.gerrit.reviewdb.client.Change;
 import com.google.gerrit.reviewdb.client.Change.Status;
-import com.google.gerrit.reviewdb.server.ReviewDb;
 import com.google.gerrit.server.CurrentUser;
 import com.google.gerrit.server.IdentifiedUser;
 import com.google.gerrit.server.account.AccountCache;
@@ -39,7 +38,6 @@
 import com.google.gerrit.server.project.ProjectState;
 import com.google.gerrit.server.query.change.ChangeData;
 import com.google.gwtorm.server.OrmException;
-import com.google.gwtorm.server.SchemaFactory;
 import com.google.inject.Inject;
 import com.google.inject.Provider;
 import java.io.IOException;
@@ -61,7 +59,6 @@
   private ChangeData.Factory changeDataFactory;
   private GitRepositoryManager repoManager;
   private Provider<CurrentUser> userProvider;
-  private SchemaFactory<ReviewDb> reviewDbProvider;
   private ProjectCache projectCache;
 
   static class Parameters {
@@ -75,14 +72,12 @@
       @PluginName String pluginName,
       PluginConfigFactory configFactory,
       Provider<CurrentUser> userProvider,
-      SchemaFactory<ReviewDb> reviewDbProvider,
       ChangeData.Factory changeDataFactory,
       AccountCache accountCache,
       Emails emails,
       GitRepositoryManager repoManager,
       ProjectCache projectCache) {
     this.userProvider = userProvider;
-    this.reviewDbProvider = reviewDbProvider;
     this.changeDataFactory = changeDataFactory;
     this.accountCache = accountCache;
     this.emails = emails;
@@ -122,18 +117,10 @@
     return apply(rev.getChangeResource(), new Parameters());
   }
 
-  // Used by both Action.apply and GetOwners.apply.
+  // Used by integration tests, because they do not have ReviewDb Provider.
   public Response<RestResult> apply(ChangeResource rsrc, Parameters params)
       throws IOException, OrmException, BadRequestException {
-    try (ReviewDb reviewDb = reviewDbProvider.open()) {
-      return apply(reviewDb, rsrc, params);
-    }
-  }
-
-  // Used by integration tests, because they do not have ReviewDb Provider.
-  public Response<RestResult> apply(ReviewDb reviewDb, ChangeResource rsrc, Parameters params)
-      throws IOException, OrmException, BadRequestException {
-    ChangeData changeData = changeDataFactory.create(reviewDb, rsrc.getChange());
+    ChangeData changeData = changeDataFactory.create(rsrc.getChange());
     return getChangeData(params, changeData);
   }
 
@@ -211,8 +198,8 @@
   public Description getDescription(RevisionResource resource) {
     Change change = resource.getChangeResource().getChange();
     ChangeData changeData = null;
-    try (ReviewDb reviewDb = reviewDbProvider.open()) {
-      changeData = changeDataFactory.create(reviewDb, change);
+    try {
+      changeData = changeDataFactory.create(change);
       if (changeData.change().getDest().get() == null) {
         if (!Checker.isExemptFromOwnerApproval(changeData)) {
           logger.atSevere().log("Cannot get branch of change: %d", changeData.getId().get());
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 5d19399..f1b2303 100644
--- a/src/main/java/com/googlesource/gerrit/plugins/findowners/GetOwners.java
+++ b/src/main/java/com/googlesource/gerrit/plugins/findowners/GetOwners.java
@@ -19,7 +19,6 @@
 import com.google.gerrit.extensions.restapi.BadRequestException;
 import com.google.gerrit.extensions.restapi.Response;
 import com.google.gerrit.extensions.restapi.RestReadView;
-import com.google.gerrit.reviewdb.server.ReviewDb;
 import com.google.gerrit.server.CurrentUser;
 import com.google.gerrit.server.account.AccountCache;
 import com.google.gerrit.server.account.Emails;
@@ -29,7 +28,6 @@
 import com.google.gerrit.server.project.ProjectCache;
 import com.google.gerrit.server.query.change.ChangeData;
 import com.google.gwtorm.server.OrmException;
-import com.google.gwtorm.server.SchemaFactory;
 import com.google.inject.Inject;
 import com.google.inject.Provider;
 import java.io.IOException;
@@ -58,7 +56,6 @@
       @PluginName String pluginName,
       PluginConfigFactory configFactory,
       Provider<CurrentUser> userProvider,
-      SchemaFactory<ReviewDb> reviewDbProvider,
       ChangeData.Factory dataFactory,
       AccountCache accountCache,
       Emails emails,
@@ -69,7 +66,6 @@
             pluginName,
             configFactory,
             userProvider,
-            reviewDbProvider,
             dataFactory,
             accountCache,
             emails,