Access LabelTypes through ProjectState rather than globally
We want to allow projects to define their own labels, so we can't assume the label list is global. In typical cases, we can access it through a ProjectControl, ChangeControl, or related factory. This does result in a few more places where we propagate NoSuchProject/ChangeExceptions where there were none before. This is intended: operations that query/modify labels on, say, a bare Change.Id now do need to verify that the project/change exists. For now, leave code in LabelTypesProvider, but try not to inject LabelTypes where at all possible. Change-Id: I4936ccafdb41848aaac3e335adf4648369d6abbc
This commit is contained in:
@@ -43,17 +43,14 @@ import java.util.TreeMap;
|
||||
|
||||
public class ReviewerJson {
|
||||
private final Provider<ReviewDb> db;
|
||||
private final LabelTypes labelTypes;
|
||||
private final FunctionState.Factory functionState;
|
||||
private final AccountInfo.Loader.Factory accountLoaderFactory;
|
||||
|
||||
@Inject
|
||||
ReviewerJson(Provider<ReviewDb> db,
|
||||
LabelTypes labelTypes,
|
||||
FunctionState.Factory functionState,
|
||||
AccountInfo.Loader.Factory accountLoaderFactory) {
|
||||
this.db = db;
|
||||
this.labelTypes = labelTypes;
|
||||
this.functionState = functionState;
|
||||
this.accountLoaderFactory = accountLoaderFactory;
|
||||
}
|
||||
@@ -84,6 +81,7 @@ public class ReviewerJson {
|
||||
.byPatchSetUser(psId, out._id));
|
||||
}
|
||||
|
||||
LabelTypes labelTypes = ctl.getLabelTypes();
|
||||
FunctionState fs = functionState.create(ctl, psId, approvals);
|
||||
for (LabelType at : labelTypes.getLabelTypes()) {
|
||||
CategoryFunction.forType(at).run(at, fs);
|
||||
|
Reference in New Issue
Block a user