Merge "Merge branch 'stable-2.11'"

This commit is contained in:
Edwin Kempin
2015-05-04 14:43:35 +00:00
committed by Gerrit Code Review
8 changed files with 19 additions and 14 deletions

View File

@@ -433,7 +433,7 @@ public class ChangeJson {
cd.setSubmitRecords(new SubmitRuleEvaluator(cd).setPatchSet(ps)
.setFastEvalLabels(true)
.setAllowDraft(true)
.canSubmit());
.evaluate());
return cd.getSubmitRecords();
}

View File

@@ -113,7 +113,7 @@ public class ReviewerJson {
.setPatchSet(ps)
.setFastEvalLabels(true)
.setAllowDraft(true)
.canSubmit()) {
.evaluate()) {
if (rec.labels == null) {
continue;
}

View File

@@ -573,7 +573,7 @@ public class Submit implements RestModifyView<RevisionResource, SubmitInput>,
throws ResourceConflictException, OrmException {
List<SubmitRecord> results = new SubmitRuleEvaluator(cd)
.setPatchSet(patchSet)
.canSubmit();
.evaluate();
Optional<SubmitRecord> ok = findOkRecord(results);
if (ok.isPresent()) {
// Rules supplied a valid solution.
@@ -582,7 +582,7 @@ public class Submit implements RestModifyView<RevisionResource, SubmitInput>,
return results;
} else if (results.isEmpty()) {
throw new IllegalStateException(String.format(
"ChangeControl.canSubmit returned empty list for %s in %s",
"SubmitRuleEvaluator.evaluate returned empty list for %s in %s",
patchSet.getId(),
cd.change().getProject().get()));
}

View File

@@ -85,7 +85,7 @@ public class TestSubmitRule implements RestModifyView<RevisionResource, Input> {
.setLogErrors(false)
.setSkipSubmitFilters(input.filters == Filters.SKIP)
.setRule(input.rule)
.canSubmit();
.evaluate();
List<Record> out = Lists.newArrayListWithCapacity(records.size());
AccountLoader accounts = accountInfoFactory.create(true);
for (SubmitRecord r : records) {

View File

@@ -212,7 +212,7 @@ public class CreateProject implements RestModifyView<TopLevelResource, ProjectIn
projectControlFactory.controlFor(p.getNameKey(), currentUser.get());
PutConfig.Input in = new PutConfig.Input();
in.pluginConfigValues = input.pluginConfigValues;
putConfig.get().apply(new ProjectResource(projectControl), in);
putConfig.get().apply(projectControl, in);
} catch (NoSuchProjectException e) {
throw new ResourceNotFoundException(p.getName());
}

View File

@@ -115,11 +115,16 @@ public class PutConfig implements RestModifyView<ProjectResource, Input> {
public ConfigInfo apply(ProjectResource rsrc, Input input)
throws ResourceNotFoundException, BadRequestException,
ResourceConflictException {
Project.NameKey projectName = rsrc.getNameKey();
if (!rsrc.getControl().isOwner()) {
throw new ResourceNotFoundException(projectName.get());
throw new ResourceNotFoundException(rsrc.getName());
}
return apply(rsrc.getControl(), input);
}
public ConfigInfo apply(ProjectControl ctrl, Input input)
throws ResourceNotFoundException, BadRequestException,
ResourceConflictException {
Project.NameKey projectName = ctrl.getProject().getNameKey();
if (input == null) {
throw new BadRequestException("config is required");
}
@@ -169,7 +174,7 @@ public class PutConfig implements RestModifyView<ProjectResource, Input> {
}
if (input.pluginConfigValues != null) {
setPluginConfigValues(rsrc.getControl().getProjectState(),
setPluginConfigValues(ctrl.getProjectState(),
projectConfig, input.pluginConfigValues);
}

View File

@@ -117,7 +117,7 @@ public class SubmitRuleEvaluator {
/**
* @param ps patch set of the change to evaluate. If not set, the current
* patch set will be loaded from {@link #canSubmit()} or {@link
* patch set will be loaded from {@link #evaluate()} or {@link
* #getSubmitType}.
* @return this
*/
@@ -139,7 +139,7 @@ public class SubmitRuleEvaluator {
}
/**
* @param allow whether to allow {@link #canSubmit()} on closed changes.
* @param allow whether to allow {@link #evaluate()} on closed changes.
* @return this
*/
public SubmitRuleEvaluator setAllowClosed(boolean allow) {
@@ -148,7 +148,7 @@ public class SubmitRuleEvaluator {
}
/**
* @param allow whether to allow {@link #canSubmit()} on closed changes.
* @param allow whether to allow {@link #evaluate()} on draft changes.
* @return this
*/
public SubmitRuleEvaluator setAllowDraft(boolean allow) {
@@ -194,7 +194,7 @@ public class SubmitRuleEvaluator {
* @return List of {@link SubmitRecord} objects returned from the evaluated
* rules, including any errors.
*/
public List<SubmitRecord> canSubmit() {
public List<SubmitRecord> evaluate() {
try {
initPatchSet();
} catch (OrmException e) {

View File

@@ -200,7 +200,7 @@ public class OutputStreamQuery {
eventFactory.addSubmitRecords(c, new SubmitRuleEvaluator(d)
.setAllowClosed(true)
.setAllowDraft(true)
.canSubmit());
.evaluate());
}
if (includeCommitMessage) {