SubmittedTogether: Error out on nonVisibleChanges unless o=NON_VISIBLE_CHANGES passed
Make SubmittedTogether#apply(ChangeResource, EnumSet) fail if it is called (for example from ChangeApi) for a change set with non-visible changes without the NON_VISIBLE_CHANGES option. Without this change only #apply(ChangeResource) would fail in that case. As a side effect, this stops Eclipse from warning about the unused EnumSet parameter. Change-Id: I1dbc58d9bc6c799661ecec44439d535ee93017b8
This commit is contained in:
@@ -81,10 +81,6 @@ public class SubmittedTogether implements RestReadView<ChangeResource> {
|
||||
ResourceConflictException, IOException, OrmException {
|
||||
SubmittedTogetherInfo info = apply(resource, options);
|
||||
if (options.isEmpty()) {
|
||||
if (info.nonVisibleChanges != 0) {
|
||||
throw new AuthException(
|
||||
"change would be submitted with a change that you cannot see");
|
||||
}
|
||||
return info.changes;
|
||||
}
|
||||
return info;
|
||||
@@ -92,7 +88,7 @@ public class SubmittedTogether implements RestReadView<ChangeResource> {
|
||||
|
||||
public SubmittedTogetherInfo apply(ChangeResource resource,
|
||||
EnumSet<SubmittedTogetherOption> options)
|
||||
throws IOException, OrmException {
|
||||
throws AuthException, IOException, OrmException {
|
||||
Change c = resource.getChange();
|
||||
try {
|
||||
List<ChangeData> cds;
|
||||
@@ -112,6 +108,12 @@ public class SubmittedTogether implements RestReadView<ChangeResource> {
|
||||
hidden = 0;
|
||||
}
|
||||
|
||||
if (hidden != 0
|
||||
&& !options.contains(SubmittedTogetherOption.NON_VISIBLE_CHANGES)) {
|
||||
throw new AuthException(
|
||||
"change would be submitted with a change that you cannot see");
|
||||
}
|
||||
|
||||
if (cds.size() <= 1 && hidden == 0) {
|
||||
cds = Collections.emptyList();
|
||||
} else {
|
||||
|
||||
Reference in New Issue
Block a user