1012 Commits

Author SHA1 Message Date
Changcheng Xiao
a2ece68f1a DefaultRefFilter: log error for PermissionBackendException
This commit changes this class so that every PBE will be logged
out as an error. But another option is throwing out this
exception since it stands for an error on the server side.

Change-Id: I231ab13ebeb9e5b37788875355d675c17f68745b
2018-03-27 08:16:30 +02:00
Patrick Hiesel
059e7e7a33 Merge changes from topic "remove-project-ctl-isHidden"
* changes:
  ProjectControl: remove "isHidden" when checking "READ" permission
  UploadArchive: check ProjectState readable before checking "READ" permission
  ListProjects: check ProjectState readable before checking "READ" permission
  ProjectIsVisibleToPredicate: check ProjectState readable before checking "READ" permission
  DefaultRefFilter: check ProjectState readable before checking "READ" permission
  AsyncReceiveCommits: check ProjectState readable before checking "READ" permission
  GitWebServlet: check ProjectState readable before checking "READ" permission
2018-03-26 15:40:25 +00:00
Changcheng Xiao
3d002433fc ProjectControl: remove "isHidden" when checking "READ" permission
Change-Id: I687f2957135bfba3c3a66617828980ddc5b14c85
2018-03-26 13:12:45 +00:00
Changcheng Xiao
581dbf9f32 UploadArchive: check ProjectState readable before checking "READ" permission
Change-Id: I77756f59e60dba33fc6f3b659bebb0c1bbac2ea6
2018-03-26 13:12:39 +00:00
Changcheng Xiao
80e5273562 ListProjects: check ProjectState readable before checking "READ" permission
Change-Id: I7c3724927afe7427434e6ae84b33310491c3e098
2018-03-26 13:12:29 +00:00
Changcheng Xiao
0c4a378264 ProjectIsVisibleToPredicate: check ProjectState readable before checking "READ" permission
Change-Id: Ie6602e373f98d8bdf8c13cd4213145da88709afa
2018-03-26 15:11:53 +02:00
Changcheng Xiao
179ce3726b DefaultRefFilter: check ProjectState readable before checking "READ" permission
Change-Id: I0a5f3dd5fb0bb2ddf47abc72a840c68ef088c60c
2018-03-26 11:21:29 +00:00
Changcheng Xiao
8d99576d47 AsyncReceiveCommits: check ProjectState readable before checking "READ" permission
Change-Id: I2958b75916886b047f778f38dac2fe6cdab9712e
2018-03-26 11:21:07 +00:00
Changcheng Xiao
a39176467a GitWebServlet: check ProjectState readable before checking "READ" permission
Change-Id: I20921ffaa5a9e49d80365a40dbd506957ea8cadf
2018-03-26 13:19:42 +02:00
Edwin Kempin
009ac5341e Merge "CreateProject: throw RuntimeException when creation failed" 2018-03-26 08:38:16 +00:00
Changcheng Xiao
8003295e22 CreateProject: throw RuntimeException when creation failed
Create project could fail when there are concurrent requests.
For example, in the test
CreateProjectIT#createSameProjectFromTwoConcurrentRequests.

Like other places, it's good to check whether ProjectState is
null before use.

Change-Id: I9dc590912f6ffa1878a3974991f78ccf51ca9ad1
2018-03-26 07:35:16 +00:00
xchangcheng
1f70c63694 Merge "Move AccessResource to "restapi.access" package" 2018-03-26 07:23:07 +00:00
Changcheng Xiao
5f8ce550bf Move AccessResource to "restapi.access" package
Change-Id: Iafbec48e2cf45fd0729296d2bacf6da1c09a6e0b
2018-03-26 06:40:00 +00:00
David Pursehouse
5c329be1b7 Merge "Remove unused class "ProjectRef"" 2018-03-25 08:52:38 +00:00
Changcheng Xiao
e31fc7d169 Remove unused class "ProjectRef"
Change-Id: I381fb854952a7354535e326fd64882603ff136a5
2018-03-23 15:08:02 +01:00
Hugo Arès
0894a276ae Merge "Allow admins to toggle the WIP flag on all changes" 2018-03-23 13:49:49 +00:00
Edwin Kempin
812bacc7b3 Allow admins to toggle the WIP flag on all changes
Sometimes this can be useful, e.g. if one developers starts a WIP
change, goes to vacation and another developer makes the change ready.
At the moment the WIP flag cannot be removed by anyone else than the
change owner.

Change-Id: I4878f066b633b349dbfe927480ebb143539bf4d3
Signed-off-by: Edwin Kempin <ekempin@google.com>
2018-03-23 07:41:14 +01:00
Maxime Guerreiro
8d129d41f5 Add Gerrit's instance name and reference it in notification emails
Gerrit users active on several Gerrit servers may find it hard to
determine the gerrit instance related to an email.
This commit fixes it by adding a Gerrit instance name to the email
titles, right before the project's short name.
For instance, for a Gerrit instance called "Pear" and the project
"website/forum", the notification email titles will contain "Pear/forum".

Also add configuration to disable this behavior.
Change-Id: I6c842f33ce605125ec64ca7d09643f59aa96a02d
2018-03-22 16:30:08 +01:00
Edwin Kempin
44cb0fd77a Move GroupRebuilder and GroupBundle into schema package
GroupRebuilder and GroupBundle are supposed to be only used by schema
migrations. Make sure that they are not used otherwise by moving them
into the schema package.

Change-Id: I094043259720edec9b60309f0ec0535bf0505d9e
Signed-off-by: Edwin Kempin <ekempin@google.com>
2018-03-22 08:27:09 +01:00
Edwin Kempin
e41ac7a198 AbstractGroupTest: Include UUID into group names
This is better than checking a constant group name that is the same for
all groups.

Change-Id: Ie92327bb1d5f285f3ef65fa229f1b3ee863cd8f6
Signed-off-by: Edwin Kempin <ekempin@google.com>
2018-03-22 08:27:09 +01:00
Edwin Kempin
1d31982d06 Make GroupRebuilder useable from schema migration
We want to use GroupRebuilder from a schema migration to migrate Gerrit
groups to NoteDb. For this GroupRebuilder must not depend on classes
which are not available during init:

- Don't use MetaDataUpdate.InternalFactory but instead instantiate
  MetaDataUpdate directly (it's okay to use GitReferenceUpdated.DISABLED
  since we don't fire events during init and init is the only place
  where GroupRebuilder is used).
- Don't create an AuditLogFormatter from account cache, group cache and
  server ID but instead require that the AuditLogFormatter is created
  and passed in by the caller.

Change-Id: Ib43e3121ec99c38ef4c1a1879c48d879118fb4c4
Signed-off-by: Edwin Kempin <ekempin@google.com>
2018-03-22 08:27:09 +01:00
Edwin Kempin
0ae2c32c17 GroupBundle.Factory#fromReviewDb: Require UUID as input instead of ID
This will make it easier to use this method from the schema migration
that implements the migration of Gerrit groups to NoteDb.

Change-Id: Ic15d54c240998796bb5e8ad91a8b8144674c8af0
Signed-off-by: Edwin Kempin <ekempin@google.com>
2018-03-22 08:27:09 +01:00
Edwin Kempin
53f55312bf GroupBundle.Factory: Make fromReviewDb method static
This will allow us to use this method from the schema migration that
implements the migration of Gerrit groups to NoteDb.

Change-Id: I12ba4a0217ae9479f32c6c5f3fc0a834fd127e30
Signed-off-by: Edwin Kempin <ekempin@google.com>
2018-03-22 08:27:09 +01:00
Edwin Kempin
0b992cc55e GroupBundle: Use SQL to read group data from ReviewDb
The Gerrit groups will be migrated to NoteDb. Once this is done reading
groups from ReviewDb will be no longer supported and the
AccountGroup*Access classes will be removed.

The GroupBundle class will be used by the schema migration that migrates
the Gerrit groups from ReviewDb to NoteDb and we need to keep this
migration running for some longer time to support Gerrit upgrades.

This means GroupBundle will still exist when the AccountGroup*Access
classes are already gone. Hence to read group data it cannot rely on the
AccountGroup*Access classes, but must use plain SQL to retrieve this
data from ReviewDb.

Change-Id: If4bc99191bc7cd0e713c9666c2d52b278fe3a246
Signed-off-by: Edwin Kempin <ekempin@google.com>
2018-03-22 08:27:09 +01:00
David Pursehouse
58e7335c59 CanSeeChangePredicate: Add missing license/copyright header
Change-Id: I942d3a06a1ef9f701427318a75a893c471e95305
2018-03-22 14:28:46 +09:00
Edwin Kempin
26e3c95c89 Merge "Revert "Add config option to prevent group updates while migrating groups"" 2018-03-21 09:20:01 +00:00
Edwin Kempin
6b458c6cd6 Merge "Remove REST endpoint to rebuild individual groups in NoteDb" 2018-03-21 09:19:20 +00:00
Dave Borowitz
af83e8cb57 Merge changes I53434efc,I21a889f2
* changes:
  SubmoduleOp: Don't require ProjectState.Factory
  Move ProjectLevelConfig to project package
2018-03-20 14:56:26 +00:00
Alice Kober-Sotzek
033b48c396 Revert "Add config option to prevent group updates while migrating groups"
This reverts commit 809de7e70c9a974df0a4c467ab731938c8b81d85.

Reason for revert: Groups are migrated offline with change I530116c8c5a.
Hence, we don't need to prevent any intermediate group updates.

Change-Id: I28113f8dbca7698a2335ae315405e7893636a745
2018-03-20 09:36:21 +01:00
Alice Kober-Sotzek
3afca9eb0d Remove REST endpoint to rebuild individual groups in NoteDb
This change partially reverts I84201c0c9d.

A follow-up change will migrate all groups from ReviewDb to NoteDb.
Further follow-up changes will remove all ReviewDb code for groups.
Hence, we don't need this REST endpoint anymore, which only existed
temporarily while implementing groups in NoteDb.

Change-Id: Ia2cf0c75a80e34ef9a8d8c8063b08388fa5fae9c
2018-03-20 08:58:16 +01:00
Edwin Kempin
191aaa7e24 Limit assignee suggestions to users that can see the change
Bug: Issue 5181
Change-Id: Ib64248a285e8feca1fd8f18e825f302d09d252ed
Signed-off-by: Edwin Kempin <ekempin@google.com>
2018-03-20 07:55:58 +00:00
Edwin Kempin
f4f0f8a222 Merge "Add account predicate that checks if user can see a certain change" 2018-03-20 07:17:21 +00:00
Dave Borowitz
87df97aa95 SubmoduleOp: Don't require ProjectState.Factory
The only usage of this class is to create a ProjectState from a
ProjectConfig acquired from a ProjectState returned by the ProjectCache.
No need for this indirection; just use the original ProjectState.

Change-Id: I53434efc3c59bb2992f54ef262076030db55badd
2018-03-19 17:09:56 -04:00
Dave Borowitz
7928861637 Move ProjectLevelConfig to project package
This class is tightly related to ProjectState, which lives in this
package.

Change-Id: I21a889f23d95eaf4af40f47b2569550d7d53ea8d
2018-03-19 14:57:13 -04:00
Dave Borowitz
abafb7c1ae Move non-Gerrit-specific project index code to new package
This is similar to the split between index and server.index: these
pieces of the index code do not depend on Gerrit internals and may be
used to implement a project index in non-Gerrit servers. In other words,
this is the logical continuation of the work started in I07beec95.

Change-Id: Ic56eb46a5386cdd72f62117ad36b24ca85659809
2018-03-19 16:26:22 +00:00
David Pursehouse
e9dac39d6b Merge branch 'stable-2.15'
* stable-2.15:
  Fix formatting in MergeInput documentation
  Fix assertions on iterable size in tests
  Fix example ref in 'Create Merge Patch Set For Change' documentation
  Fix documentation for CreateMergePatchSetForChange REST API endpoint.
  LightweightPluginDaemonTest: Expose plugin guice injectors

Change-Id: Ief9930217e4769aac629b076316cdb3b47edfd11
2018-03-19 08:45:01 +09:00
David Pursehouse
5a459ca62a Merge branch 'stable-2.15'
* stable-2.15:
  Fix logic in NoteDbMigrator#canSkipPrimaryStorageMigration

Change-Id: Ib6642b8b38556ab2f5d906bac25d2160dedd2522
2018-03-18 12:34:53 +09:00
David Pursehouse
3c62aa0d0b Merge branch 'stable-2.15'
* stable-2.15:
  Skip migrating inline comments on missing patch set parents
  Temporarily increase heap size of NoteDb migration tests
  Log the reason why a project cannot be found
  Change kind cache: short-circuit on root commits
  Document that gitweb.type must be set
  Tidy up config-gitweb
  Change kind cache: short-circuit on root commits
  Do not abort indexing if < 50% projects failed
  Improve documentation of `index.maxLimit` for Elasticsearch
  InitIndex: Set Elasticsearch index config under elasticsearch section
  Link to hashtag intro docs from more places
  user-upload.txt: Document setting hashtags on push
  intro-user.txt: Document hashtags
  user-search.txt: Document hashtag operator
  intro-user.txt: Mention that topics may affect submission
  Add NoteDb migration test for change with no patch set refs
  NoteDbMigrator: Totally skip changes with no patch sets
  Add more tests for rebuilding changes missing some entities
  Fix Change-Id in revert email
  Widen set of My Drafts menus that are automatically removed
  Migrate old My Drafts menus in refs/users/default

This partially reverts commit e518d9dacc9d4cc547cb5935101859e36072ccb0
because Schema_159_to_160_Test references PREFERENCES which was made
private, and uses the forDefault method which was removed. This commit
makes PREFERENCES package visible and re-adds the forDefault method as
a package visible method.

Change-Id: Ifba662a47197b3a5f17988fc69896cdca1ff853b
2018-03-17 10:08:39 +09:00
Alice Kober-Sotzek
02c1c05b28 Merge changes I43df0fa0,I8eba8b0c
* changes:
  AccountIndexer: Remove reindex if stale after original index update
  Make sure to never use cached values when indexing accounts
2018-03-16 15:24:41 +00:00
Alice Kober-Sotzek
fab8cf255f AccountIndexer: Remove reindex if stale after original index update
This change does the same for accounts what was done for groups by
change I1965b20c3.

The race condition which exists for the change index (see I04ac36ea55a)
doesn't exist for the account index. Contrary to the change index, the
account index always uses the current value from the primary storage
when updating the index.

Let's assume that we have two concurrent updates of an account.
1. Updater A writes account in state A to primary storage.
2. Updater B writes account in state B to primary storage.
3. Updater B updates the index with state B from primary storage.
4. Updater A updates the index with state B from primary storage.

So, even when the writes to the storage and the updates of the index are
executed in an arbitrary order, the index still contains the correct
value in the end.

Change-Id: I43df0fa08ce88360cd4e2eb6f94de23ca2d464a8
2018-03-16 14:14:14 +00:00
Edwin Kempin
06c328d5a2 Make sure to never use cached values when indexing accounts
This change does the same for accounts what was done for groups by
change I0b281d7b72.

Indexed accounts are retrieved from the account cache. As the account
cache may possibly have stale entries, we have to be careful not to use
outdated values. All code paths which referred to the AccountIndexer
correctly invalidated the account cache. Requiring the cache evictions
in other classes is a bit dangerous, though.

This situation becomes even worse with the recently added
AccountIndexer#reindexIfStale method (see change I66d5bb09e4). Whether
the account index is stale is determined by comparing the account stored
in the index with the one stored in NoteDb. For updating a stale index
entry, we didn't ensure that the account was freshly read from NoteDb.
This means that users of AccountIndexer#reindexIfStale which care about
up-to-date values would need to manually invalidate the cache, which
would trigger an indexing without the stale check, and hence make the
call to AccountIndexer#reindexIfStale obsolete. Alternatively, they
would need to accept outdated values without any guarantee when they are
updated.

To prevent future errors due to missing cache invalidations and to allow
calling AccountIndexer#index and AccountIndexer#reindexIfStale even with
stale caches, we explicitly use a non-cached value for indexing now.

As the necessity for manual cache evictions is removed, it makes sense
in other parts of the code to not indirectly trigger an indexing for an
account by evicting it from the cache but to explicitly call the
indexer.

As a result, evicting an element from the cache doesn't need to trigger
an indexing anymore. It would also have created an infinite loop for the
new eviction in the indexer.

Since the AccountCache is no longer doing any reindex on eviction, we
can now rename AccountCache#evictAllNoReindex() to
AccountCache#evictAll().

For AllAccountsIndexer, there was even a possibly unintended
side-effect: The cache invalidation triggered an indirect indexing for
the account before the account was retrieved from the cache and
explicitly put in the index. The adjusted code should avoid this
situation by doing all interaction with the index in AllAccountsIndexer.

We also use the opportunity to add some tests for the AccountIndexer and
the adjusted behavior.

Change-Id: I8eba8b0c5e1d65ad63c15970275b2a597d475c9d
Signed-off-by: Edwin Kempin <ekempin@google.com>
2018-03-16 15:13:41 +01:00
Edwin Kempin
a7287838c6 Merge "JavaStyle: move overload methods together" 2018-03-16 14:07:58 +00:00
Alice Kober-Sotzek
ab0a296d25 Merge "GetAuditLog: Fix NPE when setting the name of a subgroup" 2018-03-16 12:08:41 +00:00
Changcheng Xiao
219e3c5f67 GetAuditLog: Fix NPE when setting the name of a subgroup
When a subgroup is not available any more, we couldn't load the
group from GroupBackend. Thus in this case, we should not try
to set the name of the subgroup.

Change-Id: I2be5e620fba847cb3fd8d0e364926141e4c33300
2018-03-16 10:49:55 +01:00
Alice Kober-Sotzek
af4da95232 Merge "GetGroups: Extract variable to allow easier debugging" 2018-03-16 09:07:15 +00:00
David Ostrovsky
2ac252c3b2 Merge changes from topic "jgit-4.11"
* changes:
  Use ObjectIdSerializer from JGit [redux]
  Upgrade JGit to 4.11.0.201803080745-r.2-g61e4f1665
2018-03-16 07:43:38 +00:00
Edwin Kempin
d366ef73c8 Merge "AccountsUpdate: Clarify how eviction and reindex is done, and how it can be disabled" 2018-03-16 07:01:59 +00:00
David Pursehouse
50d91ac639 Merge "Allow admins to see all groups (including external ones) of a user" 2018-03-15 23:01:37 +00:00
xchangcheng
e5d1f02fba Merge "NoteDbUpdateManager: fix checks for potential ref update conflicts" 2018-03-15 15:20:34 +00:00
hanwen
a4e8934b30 Merge "Surface LockFailureException as 503 Service Unavailable" 2018-03-15 14:23:05 +00:00