1180 Commits

Author SHA1 Message Date
Edwin Kempin
f94d06bc25 For clone commands rely on scheme URLs from the server
Do not construct clone commands on client-side, but rely on the scheme
URLs that are retrieved from the server.

Change-Id: I7077ce0dcf21941d44ec69e4aecf7adb94bbeebe
Signed-off-by: Edwin Kempin <edwin.kempin@sap.com>
2015-06-08 13:50:30 +09:00
Edwin Kempin
629f59214c Merge "Retrieve download schemes via REST" 2015-05-20 12:30:25 +00:00
Edwin Kempin
925f74a6b4 Merge "Gerrit Client: Use REST API to get server info" 2015-05-20 12:28:19 +00:00
David Pursehouse
17a6fb08d7 Remove unused constant ContainerAuthFilter.REALM_NAME
Change-Id: I58a69af9de8bddc327662d1b0d766c346dc8b3ff
2015-05-20 17:13:30 +09:00
Edwin Kempin
bf78e39abf Retrieve download schemes via REST
Change-Id: I8fee0345ca28742f215b7bdcf7a2b1ec10bf84f6
Signed-off-by: Edwin Kempin <edwin.kempin@sap.com>
2015-05-20 09:34:18 +02:00
Edwin Kempin
b1b475cb5c Gerrit Client: Use REST API to get server info
The Gerrit Client needs to know about some server configuration
parameters in order to render the UI and enable/disable certain
functionality. At the moment the information about the server
configuration is embedded into the host page, but there is a new REST
endpoint that exposes some of the configuration parameters, and it
should be used instead. Retrieving the data via REST is cleaner as
this is an API which can be also used by other clients. Also it
reduces some code duplication if the configuration parameters are only
exposed via REST and not once again via the host page.

This change is only a start to get rid of the configuration data which
is embedded in the host page. It only consumes those configuration
parameters via REST which are already exposed in the REST API. In
future changes the REST API should be extended to provide all
information that is needed by the Gerrit Client, so that no such data
must be embedded into the host page.

This change doesn't consume the download commands which are already
exposed via REST, since this requires quite some changes in the Gerrit
Client, and it is better done in an own change.

Change-Id: Id367ba82a29bfc8f84fa4bb3c2fc973355e5cc4a
Signed-off-by: Edwin Kempin <edwin.kempin@sap.com>
2015-05-20 09:34:17 +02:00
David Pursehouse
be0877d2bd Merge branch 'stable-2.11'
* stable-2.11:
  Position cursor on first column on diff chunk navigation
  Restore default Codemirror cursor style
  Update 2.11.1 release notes
  Update replication plugin
  rest-api-changes.txt: fix minor spelling mistake
  Fix various spelling mistakes
  Prolog-Cookbook: tidy up rule status descriptions
  Upgrade replication plugin
  Always add SecureStore module in WebAppInitializer
  Batch index executor: Don't fall back to interactive executor
  Fix minor typo in set-account command documentation
  ChangeJson: Don't load all approvals on closed changes
  ChangeJson: Less eager loading of patch sets
  ChangeJson: Eliminate patch set loading in search results
  Remove StoredValues.PATCH_SET
  Update 2.11.1 release notes
  JarPluginProvider: Add JarScanner on running plugin JAR file
  GitWeb config: Delete temporary config on exit
  Fix description of auth.* parameters

Change-Id: I9fc13aa3665c29e488d49a36c9b57f908a74c2f8
2015-05-19 17:50:57 +09:00
David Ostrovsky
3f5dc1683b GWT: Clean up dev mode code
GWT dev mode was removed in If541bc48. Clean up left over places.

Change-Id: I1c7bcfeca8ff828c322b6d3ed19252ceb8713628
2015-05-14 11:59:54 +02:00
Jiří Engelthaler
5e2783db1b GitWeb config: Delete temporary config on exit
GitWeb config file remains undeleted in temporary directory on Gerrit
exit.

Call deleteOnExit() for this temporary file.

Change-Id: Ib62579b36cfe73bca0fa1f44383e6a613609cb45
2015-05-10 12:53:44 +00:00
Edwin Kempin
5b1ee4bfcb Always show clone commands
The clone commands on the project info screen were only shown when a
checkout command was configured on the server. This doesn't make sense
since clone has nothing to do with checkout. Remove the check and
always show the clone commands.

Change-Id: I7f9095046004d8643fc810c61b7ca53cfed1b4a7
Signed-off-by: Edwin Kempin <edwin.kempin@sap.com>
2015-05-08 08:10:19 +02:00
David Pursehouse
78bbaad5f0 Merge "Support 'git-upload-archive'" 2015-05-07 04:37:04 +00:00
David Pletcher
231a0c9a53 Fix NPE when dispatching audit event
Certain code paths may trigger execution of the finally block before a
value is assigned to the viewData variable. This change properly
handles the case where viewData is null.

Change-Id: I41723257fa3a3a6d99aaae56f6ce9392b1a4250b
2015-05-06 13:45:31 -07:00
Saša Živkov
b03f1554b1 Merge "Add REST endpoint to get info about server configuration" 2015-05-04 14:43:01 +00:00
Edwin Kempin
60feb30666 Merge "Include REGISTER_NEW_EMAIL field as editable only if email is enabled" 2015-05-04 14:05:13 +00:00
Edwin Kempin
b8590bd990 Add REST endpoint to get info about server configuration
Some of the Gerrit configuration parameters can now be accessed by

  GET /config/server/info

This REST endpoint can also be used anonymously.

For now the REST endpoint returns only a very limited set of
configuration parameters, which are needed by the Gerrit Mylyn
Connector. The result contains information about:

- auth type, editable account fields, if contributor agreements are
  used
- contact store
- download schemes, commands and archive formats
- All-Projects and All-Users project names

At the moment the Mylyn Gerrit Connector retrieves this information by
parsing the config from the HostPageData which is sent to the client.
This is an internal data structure which is used to exchange
information between Gerrit server and Gerrit WebUI. It's not an API
and third-party tools should not rely on it. As a result the Mylyn
Gerrit Connector is currently broken for Gerrit 2.11 and newer.

Provide the Mylyn Gerrit Connector team a stable API that provides
them the information they need so that future breakages can be
avoided. See Eclipse Bugzilla issue 465132 [1] for further details.

The structure of the returned JSON correlates to the structure in the
gerrit.config file.

[1] https://bugs.eclipse.org/bugs/show_bug.cgi?id=465132

Change-Id: Iac4be762bff971403438aa84923d9f0e11883366
Signed-off-by: Edwin Kempin <edwin.kempin@sap.com>
2015-05-04 15:52:56 +02:00
David Pletcher
86535611f3 Implement a more capable servlet auditing interface.
In order to facilitate action-specific auditing, the RestResource,
RestView, and HttpServletRequest are incorporated into a new extended
audit event class, supplementing all existing fields (some redundant)
in HttpAuditEvent. Although the request is already available from the
Guice injector, adding this high-value information as a field
facilitates convenient access.

Change-Id: I3ebd629c90921237bbcfbb00d9ea990740099104
2015-04-30 17:08:01 -07:00
Edwin Kempin
ed2064f05e Include REGISTER_NEW_EMAIL field as editable only if email is enabled
The REGISTER_NEW_EMAIL is only supposed to be included into the
editable account fields that are sent to the client if it is editable
and if an email sender is available and enabled. At the moment it is
always included when it is editable, even if there is no enabled email
sender.

Change-Id: Ib64851b9e6f5853ba7e111b4ddcd22a4fffa833e
Signed-off-by: Edwin Kempin <edwin.kempin@sap.com>
2015-04-30 12:30:27 +02:00
Francois Ferrand
1e9338854c Support 'git-upload-archive'
This allows use the standard git archive command to create an archive
of the content of a repository:

  $ git archive -f tar.bz2 --prefix=foo-1.0/ \
    --remote=ssh://john@gerrit:29418/foo \
    refs/changes/73/673/1 > foo-1.0.tar.bz2

Different compression levels can be configured for zip format:

  $ git archive -f zip -9 \
    --remote=ssh://john@gerrit:29418/foo \
    refs/changes/73/673/1 > foo.zip

TEST PLAN:

  buck test --include ssh

Bug: Issue 2061
Change-Id: Ifc1a92bacef3155cf474adee883cbe587dd8759f
2015-04-23 20:45:28 +02:00
Edwin Kempin
92e9cd5d0e Merge "Insert Change-Id into access right changes" 2015-04-22 14:20:27 +00:00
David Pursehouse
409ce6a9fd Merge branch 'stable-2.11'
* stable-2.11:
  Acceptance-tests: Don't assume UTF-8 system wide encoding
  Update version to 2.10.3.1
  Release notes for 2.10.3.1
  Project Owner Guide: Mention importer plugin to rename project
  Update the cookbook plugin revision
  Acceptance tests: Always treat response encoding as UTF-8
  Fix broken formatting in 2.10.3 release notes
  Update 2.11 release notes
  Add anchors to plugin sections in plugin documentation page
  Add description of importer plugin to the plugin documentation page
  Fix rendering issues in Configuration documentation
  Document that submit should for granted on refs/heads/*
  Update version to 2.10.3
  Update 2.10.3 release notes
  Improve the version computation for the release notes
  Check reachability from R_HEADS/R_TAGS/REFS_CONFIG when creating branches
  Update 2.10.3 release notes
  Include submitter in ChangeMessage on submission
  Support hybrid OpenID and OAuth2 authentication
  Move edit ref name methods from ChangeEditUtil to RefNames
  Remove tests related to duplicate event type registration
  Events: Allow same event type to be re-registered
  InlineEdit: Clarify difference between remove and revert operation
  Documentation: clone buck from Github
  ChangeTable: Always add the title tooltip on label column entries
  Enable 'Save' button when 'Display In Review Category' pref is changed
  Add ForcePushIT to acceptance tests
  InlineEdit: Handle enter event in add file dialog box
  Update replication plugin to latest revision
  Release notes for Gerrit 2.10.3
  Fix NPE in GitWebServlet
  Update revision of the replication plugin
  Fix required index version for online reindexing in 2.11 release notes
  Update buck version to same as master
  OAuth: Respect servlet context path in URL for login token
  Invalidate OAuth session after web_sessions cache expiration
  Set version to 2.11
  Update 2.11 release notes
  Prevent wrong content type for CSS files
  Improve rebase usability with the RebaseDialog
  Update 2.11 release notes
  MergeabilityCacheImpl: Only get needed refs
  Explain online reindexing in 2.11 release
  Revert marking merged or abandoned changes in related changes

Change-Id: Id915ef7316b3e721738064bb1cce97020e04296e
2015-04-20 10:32:27 +09:00
David Pursehouse
da130f0b15 Merge branch 'stable-2.10' into stable-2.11
* stable-2.10:
  Update 2.10.3 release notes
  Improve the version computation for the release notes
  Check reachability from R_HEADS/R_TAGS/REFS_CONFIG when creating branches
  Update 2.10.3 release notes
  Include submitter in ChangeMessage on submission
  Support hybrid OpenID and OAuth2 authentication
  Release notes for Gerrit 2.10.3

Change-Id: I03e0cbb444e9ae2090f510d6f4e49c6db5ece033
2015-04-16 22:30:54 +09:00
David Ostrovsky
8b5aa48f1d Support hybrid OpenID and OAuth2 authentication
e9707d8f85 exposed OAuth authentication extension point. Using this
extension point plugins can offer OAuth2 authentications.

That is fine for new Gerrit sites, which can restrict the auth scheme
to OAuth2 only.

For the existing sites, that rely on non SSO OpenID auth scheme it
doesn't work to migrate to OAuth2 because of diverse contributors
base that use different OpenID providers. Not all OpenID providers
offer OAuth2 protocol. Particularly, widespread OpenID providers
among open source Gerrit communities are Launchpad/UbuntuOne and
FedoraProject don't offer OAuth2 protocol. To not lock out those
contributors from being able to contribute to open source Gerrit
based projects OpenID must still be supported.

With Google's shut down of their OpenID service in April 2015, big
user base is locked out from contribution to Gerrit based projects
that only support OpenID auth scheme.

The only way to still support OpenID 2.0 providers and new OAuth2
based protocol is native support for hybrid authentication scheme
in Gerrit.

This change extends OpenID auth scheme by making it aware of optional
OAuth plugin-based authentication.

When no oauth-provider plugins are deployed, OpenID auth scheme works
as usual. When OAuth provider plugins are deployed, OAuth2 providers
are offered on the OpenID login form, in addition to hard coded Yahoo!
and Launchpad OpenID providers: [1].

[1] http://imgur.com/IcCrChN

Change-Id: I6d70212f4fea5443a6322c7da683e1e943d058eb
2015-04-16 10:34:12 +00:00
Edwin Kempin
8d17f7e5e7 Insert Change-Id into access right changes
When modifications of access rights are saved for review, a new change
is created. Now this change has a Change-Id in the commit message, so
that it's easier to manually rework the change and push further patch
sets.

Bug: issue 2817
Change-Id: I0a6399d731644bdc28147cfd8527e3b692c953da
Signed-off-by: Edwin Kempin <edwin.kempin@sap.com>
2015-04-16 08:40:01 +00:00
David Pursehouse
a853f7c148 Merge branch 'stable-2.10' into stable-2.11
* stable-2.10:
  Fix NPE in GitWebServlet
  Update revision of the replication plugin

Change-Id: Ia34a94313f0b4500748a02e38b2b39c5c86afe55
2015-04-15 18:08:04 +09:00
David Pursehouse
b4c5a0e23f Fix NPE in GitWebServlet
Bug: Issue 3289
Change-Id: I6c2a9e231343c3790ec913e1bf5de37f319d616a
2015-04-15 00:32:08 +00:00
David Pursehouse
994159eab7 Fix Checkstyle warnings related to class and member modifier order
Change the order of class and member modifiers to follow the order
defined in the Java Language Specification and the Google Java
Style guide [1].

[1] https://google-styleguide.googlecode.com/svn/trunk/javaguide.html#s4.8.7-modifiers

Change-Id: Ic7f85cb4d15f49159095aa37d3c41dbffd69c805
2015-04-14 11:34:40 +09:00
Shawn Pearce
61807cc2a8 Merge "Allow to build api with Java 8" 2015-04-10 22:17:05 +00:00
David Pursehouse
3b1abd7e84 Merge branch 'stable-2.10' into stable-2.11
* stable-2.10:
  Prevent wrong content type for CSS files

Change-Id: Ica84d55e3d86c981d104253293965ff76868677f
2015-04-10 17:12:02 +09:00
Doug Kelly
5fa42e8d93 Prevent wrong content type for CSS files
The mime-util library contains two content type mappings for .css
files: application/x-pointplus and text/css.  Unfortunately, using
the wrong one will result in most browsers discarding the file as
a CSS file.  Ensure we only use the correct type for CSS files.

This happens because MimeUtilFileTypeRegistry attempts to get all
MIME types from mime-util and then sort the result based on the
specificity of each type.  Since both types have no magic string,
only the ExtensionMimeDetector matches.

Change-Id: Idfe88dc823f191d9c9e0b9c9da3b5d2ec471f9db
2015-04-10 08:08:53 +00:00
David Pursehouse
f838e8dc0b Merge branch 'stable-2.11'
* stable-2.11:
  Update 2.11 release notes
  Revert "Revert "SSH: Simplify CachingPublicKeyAuthenticator implementation""
  Update 2.11 release notes
  SshDaemon: Add implementation of InsecureBouncyCastleRandom.random()
  Fix formatting in documentation about review labels
  Remove stripping # in login redirect
  Ensure that AccountLoader sets username if requested
  Workaround Guice bug "getPathInfo not decoded"

Change-Id: I9615fe2305b47a8ff232a47982651ea00a423263
2015-04-08 11:39:46 +09:00
David Pursehouse
3d338f90ef Merge branch 'stable-2.10' into stable-2.11
* stable-2.10:
  Revert "Revert "SSH: Simplify CachingPublicKeyAuthenticator implementation""
  Remove stripping # in login redirect

Change-Id: I052e45a3220b43923e1ee414c97f1bbfe845620a
2015-04-07 19:33:36 +09:00
Edwin Kempin
a6119d3101 Merge "Workaround Guice bug "getPathInfo not decoded"" into stable-2.11 2015-04-07 10:17:50 +00:00
Doug Kelly
2e7965f9a1 Remove stripping # in login redirect
The login redirect was set up to strip '#/' when redirecting to
the login page.  In 2.10, HttpLoginServlet assumed the URL already
contained '#/', which means the redirect back to the original
page after login would fail.

Bug: Issue 3044
Change-Id: I5dc297e31d26006f52f869a63e5b9cc6f9591b21
2015-04-02 15:15:36 -05:00
Christian Aistleitner
0da441ef87 Allow to build api with Java 8
Java 8's javadoc fails hard on unknown HTML tags. Due some
documentation code snippets that contain generics and lacked a
{@code...}, the code got picked up as html, which made the target fail
like:

  [...]/extensions/registration/DynamicSet.java:64: error: unknown tag: Foo
   *   DynamicSet.setOf(binder(), new TypeLiteral<Thing<Foo>>() {});

We insert the needed {@code...} to make the build pass for Java 8.

Change-Id: I430b8eb9f2f158c2c7a2a7a8d93446eff3253529
2015-03-29 16:21:33 +02:00
Hugo Arès
4a3ab5fe52 Do not return 403 when clicking on Gitweb breadcrumb
A message "Forbidden" was displayed when clicking on any part of the
breadcrumb trail displayed at the top of Gitweb pages. That happened for
projects with parent folders because browsing parent folders is not
supported by Gerrit.

Now when the user clicks on the parent folder, redirect to Gerrit projects
list screen with the parent folder path as the filter.

Change-Id: I86dfb3f29d8da6ee02efc95470673fe70a1f2d3e
2015-03-26 12:34:18 +00:00
Dave Borowitz
7273df290a Convert to new AutoCloseable instances coming in JGit 4.0
Repository, RevWalk, and friends have been converted to AutoCloseable.
Use them in try-with-resources blocks in order to avoid warnings about
unclosed resources or calls to deprecated release() methods. Where a
larger rewrite might have been possible to reduce try/finally blocks,
err on the side of keeping the same behavior.

The proximate goal of this change was to eliminate all Eclipse
warnings about deprecated method calls (namely release()) and leaked
resources. Some of these warnings were in fact potential leaks;
Eclipse finding such cases is a side benefit of having these classes
implement AutoCloseable. However, this change certainly does not cover
all cases where try-with-resources could have been used, where it was
not causing a leak.

Fixes all such warnings in plugin submodules as well.

Change-Id: I5d151996ae012d0e8fdfa27cce8cf5e2bfc856a2
2015-03-25 20:33:53 +00:00
Saša Živkov
304130b067 Workaround Guice bug "getPathInfo not decoded"
Due to the Guice issue [1] cloning of a repository with a space in its
name was impossible. If the space wasn't encoded:

  $ git clone 'http://gerrit/My Project'

then such a request failed already in Jetty code.
If the space was encoded:

  $ git clone 'http://gerrit/My+Project'

or:

  $ git clone 'http://gerrit/My%20Project'

then the HttpServletRequest.getPathInfo in the GitOverHttpServlet would
return a non-decoded string i.e. "My%20Project' and the project wouldn't
be found. The HttpServletRequest.getPathInfo is expected to return a
decoded string [2].

Unfortunately, there is no Guice release which contains the bugfix for
the issue [1].

Workaround: decode the projectName in the GitOverHttpServlet.Resolver
explicitly.

[1] https://github.com/google/guice/issues/745
[2] http://docs.oracle.com/javaee/7/api/javax/servlet/http/HttpServletRequest.html#getPathInfo()

Change-Id: I8872cd2d1bab3f8e454d0d7399b35eb850068042
2015-03-24 16:18:29 +01:00
David Pursehouse
65dad0493b Make inner classes static where appropriate
There are several classes that have inner classes not declared with the
'static' modifier.  For these classes Findbugs reports:

  This class is an inner class, but does not use its embedded reference
  to the object which created it.  This reference makes the instances of
  the class larger, and may keep the reference to the creator object alive
  longer than necessary.  If possible, the class should be made static.

Add a 'static' modifier on these classes.

Change-Id: I0244bb1cd5662398f79c61d442df815e3811bf12
2015-03-20 14:27:59 +00:00
David Pursehouse
01ace62303 ReviewProjectAccess: Be specific about caught exceptions
Change-Id: I9c22993aa0be827521039fe9f18a516f8b5fe65d
2015-03-20 14:27:49 +00:00
David Pursehouse
410a066be7 Fix line length warnings
Update the Checkstyle configuration to only warn on lines that exceed
150 characters.

In code reviews we usually ask people to wrap lines at around 80 columns,
but there are too many existing long lines (between 80 and 150) to bother
fixing them all now.

Only wrap the ones that are egregiously long (i.e. more than 150) and add
suppressions for the ones that cannot be wrapped, for example containing
long URLs.

Change-Id: I09625efa7a0509f1d88c27ebc83dda67b6afd026
2015-03-19 18:35:04 +09:00
David Pursehouse
d3dcb36cde Merge branch 'stable-2.11'
* stable-2.11:
  Align parent links with parents in CommitBox
  Allow scrollable cover messages
  Update Review UI documentation to include new rebase functionality
  ChangeData: check patch set visibility in change mergeability check
  Prevent recursive rebase attempts
  RebaseDialog can now be closed with ESC
  Make use of true as default for copyAllScoresIfNoChange consistent
  Set version to 2.10.1
  Release notes for Gerrit 2.10.1
  Expose extension point for generic OAuth providers

Change-Id: I93af48ce7a600dffc9f73afb9cc8131da26b2a59
2015-03-19 15:45:27 +09:00
David Pursehouse
ad5e634302 Do not declare multiple variables on a single line
Change-Id: I6ce1cf9e542beda96222b5fbc7c891f086890586
2015-03-19 12:15:42 +09:00
David Pursehouse
5ddffa0060 Add missing braces around if- for- and while-statements
Change-Id: Ib7d455426fa78ac803f9d5162466f52b973cf998
2015-03-19 12:15:42 +09:00
David Pursehouse
1abfd35d76 Replace multiple 'if (x) return;' statements with single conditional
Change-Id: I9487687586ca4694fd0bca87a13b813e5d1ff188
2015-03-19 12:15:42 +09:00
Dave Borowitz
5bcf15cc1e Presize TemporaryBuffer.Heap to a reasonable size
JGit's TemporaryBuffer.Heap recently gained an estimatedSize argument
used for presizing the backing block pointer list. Without this
argument, it assumes callers are going to use the entire maximum size,
and allocates an array large enough to hold enough pointers to
8192-byte blocks to fill the maximum size.

This is pathologically wasteful in RestApiServlet, where we might
allocate one or more buffers with size Integer.MAX_VALUE just to store
JSON serialization results. This allocates an array with over 250k
elements, taking about 2M of memory which is immediately made garbage.
On *every* request.

Most JSON responses are small. We can even be pretty liberal and guess
that they are under 10 blocks (80 KiB) in size, costing us only 10
object pointers (<100 bytes) worth of memory.

Change-Id: I9e1806737706ab2a24693455d64caa7d1067af35
2015-03-18 15:00:42 -07:00
Dave Borowitz
2e5c337d24 Organize imports
Change-Id: I1aeb962e937090416b37a4852d8267946b7fdd75
2015-03-16 09:25:46 -07:00
David Pursehouse
21b83da225 Merge branch 'stable-2.10' into stable-2.11
* stable-2.10:
  Set version to 2.10.1
  Release notes for Gerrit 2.10.1
  Expose extension point for generic OAuth providers

Change-Id: I33006b0ea12611590979f376816d066883177d4f
2015-03-16 14:10:54 +09:00
Edwin Kempin
768a6bd07f Fix formatting of license headers
Change-Id: Ifb21c0f03546ebe0ae3d47493b6d9e3e25045d99
Signed-off-by: Edwin Kempin <edwin.kempin@sap.com>
2015-03-16 04:19:34 +00:00
Shawn Pearce
0c50f4fcfc Merge "Add plugins.jsLoadTimeout configuration option" 2015-03-12 14:39:00 +00:00
Dariusz Luksza
98f2352a09 Add plugins.jsLoadTimeout configuration option
JavaScript plugin load time depends highly on the network performance.
In some cases default value of 5s would be not enough to load all
plugins. This will result in standard Gerrit error page saying that
plugin failed to load.

New configuration option plugins.jsLoadTimeout allows administrators to
configure the plugin load timeout value, giving them possibility to
increase this value when 'plugin load failed' message is showing too
often.

Change-Id: I5979bc16e218db514a7eadefb2b41eacd935897d
Signed-off-by: Dariusz Luksza <dariusz@luksza.org>
2015-03-12 09:39:20 +01:00