1203 Commits

Author SHA1 Message Date
David Pursehouse
2e420c1621 CatServlet: Instantiate Repository in try-with-resources
Change-Id: Ic3d40e30ad0e37158de63e8c3c7aeb73ac031c8a
2015-06-25 16:45:00 +09:00
Urs Wolfer
64cfaf242d Use try/multi-catch
Change-Id: Icf5042cccb0662d6bd53302800e03211af94c16d
2015-06-25 16:37:27 +09:00
David Ostrovsky
213a7d365f RestApiServlet: Remove superfluous semicolon in try-with-resources
Change-Id: I87e6cc1fb6198fd9254e950d0811a0a585b97b21
2015-06-24 08:11:53 +02:00
David Pursehouse
787090d9bb GitwebServlet: Remove invalid SuppressWarnings annotation
Change-Id: I4cdfe6a681b0e50331436aa379b990fca1598669
2015-06-24 09:47:47 +09:00
David Pursehouse
0b03d4c1c0 RestApiServlet: Instantiate JsonReader in try-with-resources
To prevent warning about it not being closed.

Change-Id: I54c76bae1e81967620287e40ec065a06f3002490
2015-06-24 09:45:48 +09:00
Urs Wolfer
5e90c63dea Use try-with-resources statements
- instead of finally blocks
- in cases of missing try-finally

Change-Id: I94f481a33d8e6a3180c436245d6e95e4d525280c
2015-06-23 21:11:57 +02:00
Shawn Pearce
792b2c4e59 Update out of date hyperlinks
Change-Id: Ie800b970cd3bf5824ff7504372f79896179e4134
2015-06-17 22:38:13 +00:00
Dave Borowitz
450b7d5cde Enable Eclipse Javadoc warnings about malformed syntax
Fix warnings about unmatched {} in inline tags.

Enabling any more than this set of warnings introduces hundreds of
warnings about things like missing @throws tags, which we may want to
fix, but is a lot more work.

Change-Id: Ic671fb600d2e1ba49b7e855158811c6c98b6cda1
2015-06-13 12:52:20 +00:00
Dave Borowitz
b3f83e2ec6 Merge changes from topic 'gitweb-cleanup'
* changes:
  Use consistent lowercase for "gitweb"
  GitWebConfig: Minor cleanup
  Move logic from GitWebType to GitWebConfig
  Extract CGI configuration from GitWebConfig
  GitWebConfig: Fix check for set-to-empty-string
2015-06-12 18:46:57 +00:00
Dave Borowitz
a3d6788212 Use consistent lowercase for "gitweb"
We had inconsistent class and variable naming in Gerrit to the point
that (prior to I640e645f6) there were two completely different classes
named "GitwebConfig" and "GitWebConfig".

In the official upstream Git documentation, this command line tool is
most often referred to as "gitweb". Standardize on this
capitalization in text. It may still be capitalized at the beginning
of sentences, or where required by programming language style (e.g.
Java class names).

The only exceptions are:
 - MSysGit's wiki page is entitled GitWeb, so use that when referring
   specifically to that page.
 - Old release notes were not touched.

Change-Id: I497477c264e9cc1380c520618f8edf13e7226c9d
2015-06-12 13:24:46 -04:00
Dave Borowitz
1b2d47e7a2 Extract CGI configuration from GitWebConfig
GitWebConfig was used for two separate things:
1. Encapsulating the (type, GitWebConfig) pair that gets passed
   through the GerritConfig to the host page.
2. Describing the configuration for the built-in CGI servlet in the
   gitweb package.

Separate these concerns, creating GitWebCgiConfig in the same config
package as GitWebConfig. (Although it contains configuration for the
httpd functionality, it needs to live in the server package so other
server classes can check the configuration status.)

Change-Id: I002beb892d415eb41a15829e6c5d540be253e390
2015-06-12 13:24:28 -04:00
Dave Borowitz
44ceaa9fe6 RestApiServlet: Support Rest{Read,Modify}View on the same class
Change-Id: Ib339c92f1b066c2a25947f1b3cd651f3b194e259
2015-06-12 11:22:28 -04:00
David Pursehouse
6b9a230a50 Merge "Don't log stacktrace if git over HTTP fails due to wrong password" 2015-06-10 11:52:49 +00:00
David Pursehouse
f842745065 Merge changes from topic 'remove-gerrit-config-from-client'
* changes:
  Check with HEAD request if docs are available and remove GerritConfig
  Remove usage of GerritConfig from GitWebServlet
  Add acceptance test for /config/server/info REST endpoint
  Return info about SSHD with /config/server/info REST endpoint
  Retrieve clone commands from /config/server/info REST endpoint
  Add new extension point for clone commands
  Make *Info classes in GetServerInfo movable to extension package
  Expose more config parameters via REST
  Expose GitWeb config via /config/server/info REST endpoint
  Gerrit Client: Retrieve archives formats via REST
  Expose all auth config params that are needed by client over REST
  For clone commands rely on scheme URLs from the server
2015-06-10 00:14:30 +00:00
Edwin Kempin
2b753cc777 Check with HEAD request if docs are available and remove GerritConfig
The Gerrit client needs to know if documentation is available on the
server so that it can add the Documentation menu bar. The
/config/server/info REST endpoint cannot easily provide this
information since the ServletContext which can be used to check this
is not available in the REST API layer. Instead let the Gerrit client
do a HEAD request to "Documentation/index.html" to check if
documentation is available on the server.

GerritConfig is now no longer used and can be removed.

Change-Id: I759c262a6789193d14bcfdf702f9907854230c01
Signed-off-by: Edwin Kempin <edwin.kempin@sap.com>
2015-06-09 15:48:08 +02:00
Edwin Kempin
9480fb45b9 Remove usage of GerritConfig from GitWebServlet
Instead of injecting GerritConfig into GitWebServlet inject what is
needed to get the SSHD listen address and the canonical git URL, since
this is everything GitWebServlet needs. Removing the injection of
GerritConfig allows us to remove the SSHD listen address and the
canonical git URL from GerritConfig and in a later step to get rid of
GerritConfig.

Change-Id: I74c134edb34a26a49424c4ee1337dab642c249f3
Signed-off-by: Edwin Kempin <edwin.kempin@sap.com>
2015-06-09 15:48:07 +02:00
Edwin Kempin
5057054a9b Expose more config parameters via REST
The /config/server/info REST endpoint now provides almost all
configuration parameters which are needed by the Gerrit Client.

GerritConfig still contains 3 values. 2 cannot easily be exposed via
REST due to missing Guice bindings in the REST API layer (sshdAddress,
documentationAvailable), 1 is not used on client-side (gitDaemonUrl).

Further cleanups will be done in follow-up changes.

Change-Id: I660db7aa63253cb6a448079228301461dd1aa06f
Signed-off-by: Edwin Kempin <edwin.kempin@sap.com>
2015-06-09 13:38:19 +00:00
Edwin Kempin
7200bc649a Merge "ContainerAuthFilter: honor username provided by container" 2015-06-08 09:01:04 +00:00
Edwin Kempin
7023f47c4b Expose GitWeb config via /config/server/info REST endpoint
In the Gerrit Client retrieve the GitWeb configuration via REST and
remove the GitWeb configuration from the config that is embedded in
the host page data.

In order to provide the GitWeb configuration from the REST endpoint
the GitWeb configuration must be bound in the sysinjector (the binding
of the GitWebModule stays in the webinjector).

Change-Id: I640e645f6c9a72d5539f33e28721f0cff93e732d
Signed-off-by: Edwin Kempin <edwin.kempin@sap.com>
2015-06-08 13:50:30 +09:00
Edwin Kempin
e55a72f504 Gerrit Client: Retrieve archives formats via REST
Use the /config/server/info REST endpoint to retrieve the supported
archive formats and remove this information from the config that is
embedded in the host page data.

The way how archives formats are included into the ServerInfo JSON was
adapted to the changes done with commit 1e933885.

Change-Id: Iaf0a3817c5f239e87a0f9c2b29d198e410e4f49e
Signed-off-by: Edwin Kempin <edwin.kempin@sap.com>
2015-06-08 13:50:30 +09:00
Edwin Kempin
5a8c9e9649 Expose all auth config params that are needed by client over REST
The Gerrit Client needs to know about some authentication
configuration parameters of the server in order to render the UI and
enable/disable certain functionality. Some of them are already
provided via the /config/server/info REST endpoint. Add the other auth
parameters to this REST endpoint and adapt the Gerrit Client to
retrieve these parameters via REST. Remove these parameters from the
config that is embedded in the host page data as they are no longer
read from this data structure.

Change-Id: Ia7dc5ea8654b6e63eb577dc3d9ada07ce8d90113
Signed-off-by: Edwin Kempin <edwin.kempin@sap.com>
2015-06-08 13:50:30 +09:00
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
3acdb3a837 Don't log stacktrace if git over HTTP fails due to wrong password
It's a user error if a wrong password is provided and the Gerrit
administrator doesn't need a stacktrace for this.

Change-Id: Ie370440d8be52b4be4ea4f7d052c843a1e414708
Signed-off-by: Edwin Kempin <edwin.kempin@sap.com>
2015-06-05 11:15:47 +02: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
Urs Wolfer
7c000e31bb ContainerAuthFilter: honor username provided by container
When 'trustContainerAuth' is enabled and proxy does authentication
on root (instead of '/login/'), ServletRequest#getRemoteUser is
null. In this case we need to pull the username from 'Authorization'
header. It is done the same way in HttpAuthFilter already.

Move username extraction logic from HttpAuthFilter to
RemoteUserUtil and add some tests.

Update javadoc to reflect current situation:
ContainerAuthFilter is also used for the REST API; see:
GitOverHttpModule#configureServlets: filter("/a/*").through(authFilter)

Change-Id: I0cf21fb7ecd8a958fad270704c11ebfffd9fea93
Bug: Issue 2209
2015-05-20 17:15:54 +09: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