Refactor the way of binding ssh commands

If a command should only be used on a server in master mode, but not
slave mode, it should be bound in both MasterCommandModule and
SlaveCommandModule, we have to remember to add it separately on each
of the commands list, the maintenance work is tedious.

Refactor the way of binding ssh commands. Add a field 'runsWith' to
CommandMetaData to mark a given ssh command to run on MASTER mode or
MASTER_OR_SLAVE mode. Remove SlaveCommandModule and MasterCommandModule,
and use only DefaultCommandModule.

This reverts commit 84bcead690240e07e0314b165fb8d6dc95d2c5e7.

Change-Id: Ia4908267b135be04ff9c8a9470a243a6c8d665a8
Improve information message about rebuilding the index

When initialising Gerrit into an existing workspace, the index
should be "rebuilt", not "built".  Change the message accordingly.

Also add a new line at the beginning of the message to make it
stand out from the other information that is being output.  This
is consistent with other warnings such as the warning about
bouncycastle not being bundled.

Change-Id: I2ef5b9e141097da70fafd9dcf266988e9d6aaa27
Solr index URL should be configured under the main "index" section

Configuration of the Solr index URL must currently be done in a
subsection, as follows:

  [index]
    type = SOLR
  [index "solr"]
    url = 127.0.0.1

Subsections are also being used for configuration of specific indexes
like the "changes_open" and "changes_closed" subsections that are used
for Lucene indexes, and are documented as "index.name.xyz".

Having the Solr URL configration under a similar subsection may cause
confusion, and it would be more intuitive to configure the URL under
the main index section, like:

  [index]
    type = SOLR
    url = 127.0.0.1

Subsections are being used for configuration of specific indexes like
the "changes_open" and "changes_closed" settings that can be specified
for Lucene indexes which are documented as "index.name.xyz"

Also add missing documentation of the URL parameter.

Change-Id: I0bd9eabbdbfa29241688c738aa5d213e726c90b0
InitIndex: Allow user to configure the Solr index URL

If the index URL is not configured, running the `reindex`
program fails with:

  java.lang.IllegalStateException: index.url must be supplied

Add a step in the initialisation to allow the user to provide
the URL.  Set the default value to "localhost:9983".

Change-Id: Iae52ade99dd5e17a0688f090cd3f3aea3b676682
Handle exceptions during reindexing

If an exception is thrown from within the change indexer, the reindex
program shows a stack trace.  In the case of an error when using the
Solr index, it does not exit and continues running, while showing debug
messages "Got ping response for sessionid", but not doing anything
else.

Catch exceptions in the indexer and exit with a fatal error message.

Change-Id: Ief41eccc0d3fe9c5592782b51afa66c0c3150886
Solr index requires SolrCloud rather than plain Solr

Update the link in the config documentation to point to the
SolrCloud page rather than the Solr page.

Change-Id: Iac79af54086049b97a734259515bcf8023bd4f2a
Extend ChangeScreen2 horizontal bars to full width.

This allows the title of the change message to have some padding within
the bar. Also, removed the implicit 1px padding from the th element in
the infoTable, so it lines up correctly with the 'Files' text.

Change-Id: Id16963bd5828f6a28869657a1d76285b54f8c778
SideBySide2: Fix tab alignment to be correct width

CSS :before selector inserting a string shifts the rest of the
element text right by the width of the string, as the string is
part of the page layout. Use "position: absolute" to take this
inserted character out of the layout, drawing it on top of the
space/tab instead of before it.

This fixes the tab width to be the user's preference, rather than
1 + user's preference when show tabs is enabled.

Change-Id: I1a9ffdcf0eafac7037dfb52b3e792e5ca9fd5e56
SideBySide2: Fill the browser width

Filling the browser available space with the CM3 instances each at
50% size allows the user to more easily view long lines if they
have a wide display, and better fit on more narrow displays by
splitting the available width at 50%.

Change-Id: Iddeb0b6b43406ddb9f72d8dd369cedab2907e297
Split auth check in account REST endpoints from implementation

This allows to reuse the code with a different permission check
(e.g. in a plugin).

Change-Id: I51a22a933e69387b991ccd8a0f783a0838a7ba1b
Signed-off-by: Edwin Kempin <edwin.kempin@sap.com>
Buck: Decouple plugin-api installation from deployment

Currently the same pom_fake.xml controls both installing the plugin-api
in local Maven repository (typical use case for a contributor) and
deploying it on Google bucket (typical use case for a maintainer). To fit
the both use cases that file contains stuff needed for uploading to Google
bucket only: 'gs-maven-wagon' artifact and the repository to fetch it from.

Because the "best" build tool in the world randomly and unreproducible
fails to fetch that artifact [1], frustrating the potential contributors,
for reasons that nobody knows and understands, separate these use cases
from each other, and strip the stuff from pom_fake.xml needed for deployment
of plugin-api. The cost is code duplication. The advantage of doing it:

  buck build api_install

just works. Always.

[1] https://gist.github.com/mulby/092fee5f5962aafbbb25#file-gerrit-build-error-txt

Change-Id: I842335907ef8721f4126bcd90e395f7748aefc74
Merge "Split auth check in account REST endpoints from implementation"
Move bindings now required by ChangeData into Reindex

Broken by I1bd2c931, but fortunately already available in the
MergeabilityModule so just a matter of moving them around.

Change-Id: I68c43d861b3d6d49c4e5e2d933c64dfa0a182be2
Fix retrieving value from NativeString in plugin

Trying to get the value by 'this.get()' fails with 'get is not a
function'.

Change-Id: I9468383bb4b63bc0ede4cdb33a1695db2e6f68e9
Signed-off-by: Edwin Kempin <edwin.kempin@sap.com>
Add configuration for checking of Received Objects

Adds ability to configure the checking of Received Objects that is
performed by jgit on a per project basis based on the project.config

See jgit setCheckReceivedObjects() function

Currently this is set to true in all cases so that all objects are
checked for validity. Unfortunetly some pre-existing repositories
have known issues within their git history with Invalid Trees written
by other(non jgit) implementations. These issues can be seen in
repositories when git fsck --full is run.

While doing this check is correct in most cases it causes issues when
repositories are being sync'd from upstream servers or transfered from
other git servers to gerrit.

This changes adds a git-checks section to the project.config that allows
the checkReceivedObjects key to be used to control this check.

The default is always true unless overridden in the project.config file.

Test Procedure:
In order to test this you need to create a projects with the ability
to directy upload changes/branches including merge commits. You will also
need the ability to forge author/commiter identity. This project should
have no initial commit.

Locate a repository with the following formatted issue:
warning in tree <SHA SUM>: contains zero-padded file modes

Firstly attempt to push the effected tree to the created project, this
should fail.

Clone the test project and checkout refs/meta/config modify the
project.config file to include:

[receive]
	checkReceivedObjects = true

Upload this new config and attempt to push the effected tree again, this
should still fail.

Modify the config to be:

[receive]
	checkReceivedObjects = false

Upload this config and then push the effected tree again, this should succeed.

More info regarding this issues is located here:

https://groups.google.com/forum/#!topic/repo-discuss/O_TaspFfY7s
https://groups.google.com/forum/#!topic/repo-discuss/b_jX_7pal3U

---------------------

Change-Id: I9f566557dfdc0a33c7c88d76fc7c247dd838dea4
Update change to invalidate cache after deletion of draft revision

When draft revision is deleted the change is updated only when the
current draft patch set was deleted. That's because new current patch
set field must be updated in the database.  However when non current draft
patch set was deleted no update of the change happen.  That breaks
CS2 as it relies on browser side cached ETag and computation of ETag on
the server side. Because nothing is changed, the ETags are the same and
HTTP status 304 is returned.

Update the change also if non current draft patch set was deleted.

The only alternative to this approach is to decouple draft revision
retrieval from /changes/<id>/detail endpoint.

Bug: issue 2405
Change-Id: I80f2331362ba61306c9436921ebf153b23c3c4bc
(cherry picked from commit a50fa6761f306aa774e34dd5dc356180743dcbbd)
Replace Guava Longs.compare with Java 7 Long.compare

As compare is now available as part of the runtime, just use the
standard function.

Change-Id: I7b2eb2587800a6549263ede90339adeab8c946a5
Docs: Clarify Gerrit contribution process

The existing links in the documentation take you to CLA
forms that cannot directly be filled out.  This patch
adds instructions and a link to the actual CLA form that
can be completed online, and get contributors up and running
faster.

Change-Id: Id450cb1f05c29e5877a84a3758df3dc20fa06203
Merge "Fix retrieving value from NativeString in plugin"
Prevent draft changes from being abandoned

When a draft change is abandoned it is currently published to all
users by setting the status to ABANDONED.  Restoring the change will
effectively publish the change as /restore sets the status to NEW.

To not complicate the workflow, prevent draft changes from being
abandoned.

Change-Id: If747264fa66a2139e0d8f13987125d853ec3bed9