Factor out RevisionJson from ChangeJson

ChangeJson has grow in size and became very hard to read. This commit is
a first step at modularizing the logic by factoring out RevisionJson.

It makes the concept of lazyloading purely internal to
{Change,Revision}Json by removing the parameter and deriving the
parameter based on the provided options only.

Change-Id: Ie04ec27723d145518277c84970462ab0e6c01979
This commit is contained in:
Patrick Hiesel
2018-10-09 09:25:05 +02:00
parent 021e6f9c13
commit ed56ba1370
10 changed files with 438 additions and 328 deletions

View File

@@ -29,6 +29,7 @@ import com.google.gerrit.reviewdb.server.ReviewDb;
import com.google.gerrit.server.GpgException;
import com.google.gerrit.server.account.AccountState;
import com.google.gerrit.server.change.ChangeJson;
import com.google.gerrit.server.change.RevisionJson;
import com.google.gerrit.server.patch.PatchListNotAvailableException;
import com.google.gerrit.server.permissions.PermissionBackendException;
import com.google.gerrit.server.query.change.ChangeData;
@@ -64,15 +65,18 @@ public class EventUtil {
private final ChangeData.Factory changeDataFactory;
private final Provider<ReviewDb> db;
private final ChangeJson.Factory changeJsonFactory;
private final RevisionJson.Factory revisionJsonFactory;
@Inject
EventUtil(
ChangeJson.Factory changeJsonFactory,
RevisionJson.Factory revisionJsonFactory,
ChangeData.Factory changeDataFactory,
Provider<ReviewDb> db) {
this.changeDataFactory = changeDataFactory;
this.db = db;
this.changeJsonFactory = changeJsonFactory;
this.revisionJsonFactory = revisionJsonFactory;
}
public ChangeInfo changeInfo(Change change) throws OrmException {
@@ -89,7 +93,7 @@ public class EventUtil {
throws OrmException, PatchListNotAvailableException, GpgException, IOException,
PermissionBackendException {
ChangeData cd = changeDataFactory.create(db.get(), project, ps.getId().getParentKey());
return changeJsonFactory.create(CHANGE_OPTIONS).getRevisionInfo(cd, ps);
return revisionJsonFactory.create(CHANGE_OPTIONS).getRevisionInfo(cd, ps);
}
public AccountInfo accountInfo(AccountState accountState) {