Allow to switch read only mode on/off
In the current implementation the Gerrit server is set to read-only
simply by installing the plugin, and the read-only mode can only be
disabled by removing the plugin.
Change it so that the read-only mode can be dynamically switched on
and off by the existence of a gerrit.readonly file in the site's etc
folder. This allows to keep the plugin installed, but not have the
site always read-only, and allows to persist the read-only state
over server restarts.
The file can either be created/deleted manually, or by making a
request to a REST endpoint provided by the plugin at:
{canonicalWebUrl}/plugins/{pluginName}/readonly
Making a POST request on the endpoint enables read-only mode; making
a DELETE request disables it. The current status of read-only mode
can be queried with a GET request. When enabled, a response with HTTP
status 503 is returned. Otherwise 200 OK is returned.
Also add integration tests to verify that the read-only mode works as
expected.
Change-Id: Ib26c3cc2b899b8ce25dbfa213b80a86f4246391a
16 files changed