Construct ChangeDatas with ChangeControls in REST handlers

This is strictly less work than constructing them with Changes, as
ChangeControls never need to be lazily loaded.

Unfortunately there are still many more callers where it was not
obvious whether a ChangeControl could be passed in, so I just got the
easy ones.

Change-Id: Ic1c8c2f6aedb25df6c64595f3aecc0e9d2c96817
Refactor SubmitRuleEvaluator to reduce confusing arguments

The multitude of string and optional boolean constructor arguments was
a smell. Use a builder pattern for the optional ones, and add
multiple methods for the 2 valid combinations of 4 string arguments,
rather than requiring callers to know these magic values.

Most other constructor arguments could be inferred directly
from the ChangeData, so eliminate those as well.

Change-Id: I2554e8574722dc022956d3ca8db4ad0dc36f8c0d
SubmitRuleEvaluator: Check state in getSubmitRule()

Change-Id: I849fe43db2619a2c503c24705f2479947b8ad058
Move conversion to SubmitRecords into SubmitRuleEvaluator

Much of this logic is shared between TestSubmitRule and
ChangeControl.canSubmit(), which both depend on this output format.
Move the logic into SubmitRuleEvaluator to lessen the leakage of Term
objects.

The main difference in behavior between these two classes is how
errors are treated. canSubmit() is called by non-admin end users who
get bland error messages telling them to check the server logs;
TestSubmitRule is for admins who need to debug submit rules, and
errors are expected to happen. So we need to distinguish the case when
detailed error messages should go to the user vs. in the logs. Do this
explicitly with a setLogErrors() method on SubmitRuleEvaluator.

Change-Id: Ia61310e4fb6dea255ab721893eea070ca95d216c
Move conversion to SubmitTypeRecords into SubmitRuleEvaluator

Similar to TestSubmitRule/canSubmit, much logic was shared between
TestSubmitType and getSubmitType.

Change-Id: I212a4f225a741932474659bcf0133f086240fb7d
Move boolean args from canSubmit to SubmitRuleEvaluator

Remove the check for the current patch set, since this is not a
requirement of SubmitRuleEvaluator. It is also redundant for
canSubmit; all existing callers either pass in the current patch set
explicitly (e.g. QueryProcessor) or, in the case of Submit, have their
own check that the patch set is current.

The result of this is that canSubmit is now a thin wrapper around
SubmitRuleEvaluator and can be removed in a later change.

Change-Id: Ice4fd5f0af089f098eed9feadd43263189959995
Avoid throwing OrmException from SubmitRuleEvaluator methods

Instead of lazily looking up the patch set (possibly throwing)
wherever it is used, initialize it once at the beginning of each
public method (other than the trivial setters). and convert any
OrmExceptions to error records of the appropriate type.

Change-Id: I303c4d90d7b1aeaeb5cf33b1a4031a6bef8fa1a3
Remove ChangeControl.canSubmit(...) methods

All callers but one already had a ChangeData available, so they can
just create their own SubmitRuleEvaluators, and we can get rid of this
ugly method signature.

Change-Id: I21c64f26de10de096f469982e5cf5d10b704e473
ChangeJson: Remove unused ChangeControl arg from submitRecords

Change-Id: Ib72adc2a95116b44b79daf5181a0ff60d558fdab
Remove ChangeControl.getSubmitTypeRecord methods

The only benefit provided by these methods was in checking for draft
visibility, and there is no strong reason not to just do this check
within SubmitRuleEvaluator. (It does mean we may slightly double-check
these conditions in TestSubmitType, but that is acceptable.)

Change-Id: I88c1cf41b4b691d048f2429cb85a64c9441701a5
Use SubmitRuleEvaluator to get submit type from Mergeable

TestSubmitType no longer has logic of its own, so we can use
SubmitRuleEvaluator directly.

Change-Id: I0f5cf7f2e1a9c96634ce3df9704693a2c29af9e8
Disallow current_user/1 predicate in submit type rules

Submit type is used as part of the mergeability bit computation, which
is persistent and so needs a consistent view of submit type. An
informal poll of repo-discuss[1] indicated that current_user/1 is
pretty much only useful for submit rules, not submit type rules.

[1] https://groups.google.com/d/topic/repo-discuss/vW6XhUOkqik/discussion

Change-Id: Ia938a685409025b36e16979fcafd92afbed2d91f
Project screen: Use consistent style for core and plugin buttons

"Save Changes" button uses different (default) style as plugin owned
project specific UiActions and core UiActions, like "GC" and
"Create Change" button. Remove default style from the only button that
is using it.

Change-Id: Ia441102a47dbf393966f3b729ba3bc2a8e96c997
Merge changes from topic 'submit-rule-evaluator'

* changes:
  Disallow current_user/1 predicate in submit type rules
  Use SubmitRuleEvaluator to get submit type from Mergeable
  Remove ChangeControl.getSubmitTypeRecord methods
  ChangeJson: Remove unused ChangeControl arg from submitRecords
  Remove ChangeControl.canSubmit(...) methods
  Avoid throwing OrmException from SubmitRuleEvaluator methods
  Move boolean args from canSubmit to SubmitRuleEvaluator
  Move conversion to SubmitTypeRecords into SubmitRuleEvaluator
  Move conversion to SubmitRecords into SubmitRuleEvaluator
  SubmitRuleEvaluator: Check state in getSubmitRule()
  Refactor SubmitRuleEvaluator to reduce confusing arguments
  Construct ChangeDatas with ChangeControls in REST handlers
Suppress change edit icon for closed changes on SBS2

Change-Id: I4f9638e8e84ea6b470f73da6dede0322d12daea4
Merge "Suppress change edit icon for closed changes on SBS2"