public class ExternalIdsUpdate
extends java.lang.Object
In NoteDb external IDs are stored in the All-Users repository in a Git Notes branch called refs/meta/external-ids where the sha1 of the external ID is used as note name. Each note content is a git config file that contains an external ID. It has exactly one externalId subsection with an accountId and optionally email and password:
[externalId "username:jdoe"] accountId = 1003407 email = [email protected] password = bcrypt:4:LCbmSBDivK/hhGVQMfkDpA==:XcWn0pKYSVU/UJgOvhidkEtmqCp6oKB7For NoteDb each method call results in one commit on refs/meta/external-ids branch.
On updating external IDs this class takes care to evict affected accounts from the account cache and thus triggers reindex for them.
Modifier and Type | Class and Description |
---|---|
static class |
ExternalIdsUpdate.Server
Factory to create an ExternalIdsUpdate instance for updating external IDs by the Gerrit server.
|
static class |
ExternalIdsUpdate.User
Factory to create an ExternalIdsUpdate instance for updating external IDs by the current user.
|
Constructor and Description |
---|
ExternalIdsUpdate(GitRepositoryManager repoManager,
AccountCache accountCache,
AllUsersName allUsersName,
org.eclipse.jgit.lib.PersonIdent committerIdent,
org.eclipse.jgit.lib.PersonIdent authorIdent,
java.lang.Runnable afterReadRevision,
com.github.rholder.retry.Retryer<java.lang.Void> retryer) |
Modifier and Type | Method and Description |
---|---|
static Account.Id |
checkSameAccount(java.lang.Iterable<ExternalId> extIds)
Checks that all specified external IDs belong to the same account.
|
static Account.Id |
checkSameAccount(java.lang.Iterable<ExternalId> extIds,
Account.Id accountId)
Checks that all specified external IDs belong to specified account.
|
static void |
commit(org.eclipse.jgit.lib.Repository repo,
org.eclipse.jgit.revwalk.RevWalk rw,
org.eclipse.jgit.lib.ObjectInserter ins,
org.eclipse.jgit.lib.ObjectId rev,
org.eclipse.jgit.notes.NoteMap noteMap,
java.lang.String commitMessage,
org.eclipse.jgit.lib.PersonIdent committerIdent,
org.eclipse.jgit.lib.PersonIdent authorIdent)
Commits updates to the external IDs.
|
void |
delete(ReviewDb db,
Account.Id accountId,
java.util.Collection<ExternalId.Key> extIdKeys)
Delete external IDs by external ID key.
|
void |
delete(ReviewDb db,
Account.Id accountId,
ExternalId.Key extIdKey)
Delete an external ID by key.
|
void |
delete(ReviewDb db,
java.util.Collection<ExternalId> extIds)
Deletes external IDs.
|
void |
delete(ReviewDb db,
ExternalId extId)
Deletes an external ID.
|
void |
deleteAll(ReviewDb db,
Account.Id accountId)
Deletes all external IDs of the specified account.
|
void |
insert(ReviewDb db,
java.util.Collection<ExternalId> extIds)
Inserts new external IDs.
|
void |
insert(ReviewDb db,
ExternalId extId)
Inserts a new external ID.
|
static void |
insert(org.eclipse.jgit.revwalk.RevWalk rw,
org.eclipse.jgit.lib.ObjectInserter ins,
org.eclipse.jgit.notes.NoteMap noteMap,
ExternalId extId)
Inserts a new external ID and sets it in the note map.
|
static void |
remove(org.eclipse.jgit.revwalk.RevWalk rw,
org.eclipse.jgit.notes.NoteMap noteMap,
ExternalId extId)
Removes an external ID from the note map.
|
void |
replace(ReviewDb db,
Account.Id accountId,
java.util.Collection<ExternalId.Key> toDelete,
java.util.Collection<ExternalId> toAdd)
Replaces external IDs for an account by external ID keys.
|
void |
replace(ReviewDb db,
java.util.Collection<ExternalId> toDelete,
java.util.Collection<ExternalId> toAdd)
Replaces external IDs.
|
void |
replace(ReviewDb db,
ExternalId toDelete,
ExternalId toAdd)
Replaces an external ID.
|
static com.github.rholder.retry.RetryerBuilder<java.lang.Void> |
retryerBuilder() |
void |
upsert(ReviewDb db,
java.util.Collection<ExternalId> extIds)
Inserts or updates external IDs.
|
void |
upsert(ReviewDb db,
ExternalId extId)
Inserts or updates an external ID.
|
static void |
upsert(org.eclipse.jgit.revwalk.RevWalk rw,
org.eclipse.jgit.lib.ObjectInserter ins,
org.eclipse.jgit.notes.NoteMap noteMap,
ExternalId extId)
Insert or updates an new external ID and sets it in the note map.
|
public ExternalIdsUpdate(GitRepositoryManager repoManager, AccountCache accountCache, AllUsersName allUsersName, org.eclipse.jgit.lib.PersonIdent committerIdent, org.eclipse.jgit.lib.PersonIdent authorIdent, java.lang.Runnable afterReadRevision, com.github.rholder.retry.Retryer<java.lang.Void> retryer)
public static com.github.rholder.retry.RetryerBuilder<java.lang.Void> retryerBuilder()
public void insert(ReviewDb db, ExternalId extId) throws java.io.IOException, org.eclipse.jgit.errors.ConfigInvalidException, com.google.gwtorm.server.OrmException
If the external ID already exists, the insert fails with OrmDuplicateKeyException
.
java.io.IOException
org.eclipse.jgit.errors.ConfigInvalidException
com.google.gwtorm.server.OrmException
public void insert(ReviewDb db, java.util.Collection<ExternalId> extIds) throws java.io.IOException, org.eclipse.jgit.errors.ConfigInvalidException, com.google.gwtorm.server.OrmException
If any of the external ID already exists, the insert fails with OrmDuplicateKeyException
.
java.io.IOException
org.eclipse.jgit.errors.ConfigInvalidException
com.google.gwtorm.server.OrmException
public void upsert(ReviewDb db, ExternalId extId) throws java.io.IOException, org.eclipse.jgit.errors.ConfigInvalidException, com.google.gwtorm.server.OrmException
If the external ID already exists, it is overwritten, otherwise it is inserted.
java.io.IOException
org.eclipse.jgit.errors.ConfigInvalidException
com.google.gwtorm.server.OrmException
public void upsert(ReviewDb db, java.util.Collection<ExternalId> extIds) throws java.io.IOException, org.eclipse.jgit.errors.ConfigInvalidException, com.google.gwtorm.server.OrmException
If any of the external IDs already exists, it is overwritten. New external IDs are inserted.
java.io.IOException
org.eclipse.jgit.errors.ConfigInvalidException
com.google.gwtorm.server.OrmException
public void delete(ReviewDb db, ExternalId extId) throws java.io.IOException, org.eclipse.jgit.errors.ConfigInvalidException, com.google.gwtorm.server.OrmException
The deletion fails with IllegalStateException
if there is an existing external ID
that has the same key, but otherwise doesn't match the specified external ID.
java.io.IOException
org.eclipse.jgit.errors.ConfigInvalidException
com.google.gwtorm.server.OrmException
public void delete(ReviewDb db, java.util.Collection<ExternalId> extIds) throws java.io.IOException, org.eclipse.jgit.errors.ConfigInvalidException, com.google.gwtorm.server.OrmException
The deletion fails with IllegalStateException
if there is an existing external ID
that has the same key as any of the external IDs that should be deleted, but otherwise doesn't
match the that external ID.
java.io.IOException
org.eclipse.jgit.errors.ConfigInvalidException
com.google.gwtorm.server.OrmException
public void delete(ReviewDb db, Account.Id accountId, ExternalId.Key extIdKey) throws java.io.IOException, org.eclipse.jgit.errors.ConfigInvalidException, com.google.gwtorm.server.OrmException
The external ID is only deleted if it belongs to the specified account. If it belongs to
another account the deletion fails with IllegalStateException
.
java.io.IOException
org.eclipse.jgit.errors.ConfigInvalidException
com.google.gwtorm.server.OrmException
public void delete(ReviewDb db, Account.Id accountId, java.util.Collection<ExternalId.Key> extIdKeys) throws java.io.IOException, org.eclipse.jgit.errors.ConfigInvalidException, com.google.gwtorm.server.OrmException
The external IDs are only deleted if they belongs to the specified account. If any of the
external IDs belongs to another account the deletion fails with IllegalStateException
.
java.io.IOException
org.eclipse.jgit.errors.ConfigInvalidException
com.google.gwtorm.server.OrmException
public void deleteAll(ReviewDb db, Account.Id accountId) throws java.io.IOException, org.eclipse.jgit.errors.ConfigInvalidException, com.google.gwtorm.server.OrmException
java.io.IOException
org.eclipse.jgit.errors.ConfigInvalidException
com.google.gwtorm.server.OrmException
public void replace(ReviewDb db, Account.Id accountId, java.util.Collection<ExternalId.Key> toDelete, java.util.Collection<ExternalId> toAdd) throws java.io.IOException, org.eclipse.jgit.errors.ConfigInvalidException, com.google.gwtorm.server.OrmException
Deletion of external IDs is done before adding the new external IDs. This means if an external ID key is specified for deletion and an external ID with the same key is specified to be added, the old external ID with that key is deleted first and then the new external ID is added (so the external ID for that key is replaced).
If any of the specified external IDs belongs to another account the replacement fails with
IllegalStateException
.
java.io.IOException
org.eclipse.jgit.errors.ConfigInvalidException
com.google.gwtorm.server.OrmException
public void replace(ReviewDb db, ExternalId toDelete, ExternalId toAdd) throws java.io.IOException, org.eclipse.jgit.errors.ConfigInvalidException, com.google.gwtorm.server.OrmException
If the specified external IDs belongs to different accounts the replacement fails with
IllegalStateException
.
java.io.IOException
org.eclipse.jgit.errors.ConfigInvalidException
com.google.gwtorm.server.OrmException
public void replace(ReviewDb db, java.util.Collection<ExternalId> toDelete, java.util.Collection<ExternalId> toAdd) throws java.io.IOException, org.eclipse.jgit.errors.ConfigInvalidException, com.google.gwtorm.server.OrmException
Deletion of external IDs is done before adding the new external IDs. This means if an external ID is specified for deletion and an external ID with the same key is specified to be added, the old external ID with that key is deleted first and then the new external ID is added (so the external ID for that key is replaced).
If the specified external IDs belong to different accounts the replacement fails with IllegalStateException
.
java.io.IOException
org.eclipse.jgit.errors.ConfigInvalidException
com.google.gwtorm.server.OrmException
public static Account.Id checkSameAccount(java.lang.Iterable<ExternalId> extIds)
public static Account.Id checkSameAccount(java.lang.Iterable<ExternalId> extIds, Account.Id accountId)
public static void insert(org.eclipse.jgit.revwalk.RevWalk rw, org.eclipse.jgit.lib.ObjectInserter ins, org.eclipse.jgit.notes.NoteMap noteMap, ExternalId extId) throws com.google.gwtorm.server.OrmDuplicateKeyException, org.eclipse.jgit.errors.ConfigInvalidException, java.io.IOException
If the external ID already exists, the insert fails with OrmDuplicateKeyException
.
com.google.gwtorm.server.OrmDuplicateKeyException
org.eclipse.jgit.errors.ConfigInvalidException
java.io.IOException
public static void upsert(org.eclipse.jgit.revwalk.RevWalk rw, org.eclipse.jgit.lib.ObjectInserter ins, org.eclipse.jgit.notes.NoteMap noteMap, ExternalId extId) throws java.io.IOException, org.eclipse.jgit.errors.ConfigInvalidException
If the external ID already exists it is overwritten.
java.io.IOException
org.eclipse.jgit.errors.ConfigInvalidException
public static void remove(org.eclipse.jgit.revwalk.RevWalk rw, org.eclipse.jgit.notes.NoteMap noteMap, ExternalId extId) throws java.io.IOException, org.eclipse.jgit.errors.ConfigInvalidException
The removal fails with IllegalStateException
if there is an existing external ID
that has the same key, but otherwise doesn't match the specified external ID.
java.io.IOException
org.eclipse.jgit.errors.ConfigInvalidException
public static void commit(org.eclipse.jgit.lib.Repository repo, org.eclipse.jgit.revwalk.RevWalk rw, org.eclipse.jgit.lib.ObjectInserter ins, org.eclipse.jgit.lib.ObjectId rev, org.eclipse.jgit.notes.NoteMap noteMap, java.lang.String commitMessage, org.eclipse.jgit.lib.PersonIdent committerIdent, org.eclipse.jgit.lib.PersonIdent authorIdent) throws java.io.IOException
java.io.IOException