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.RefsMetaExternalIdsUpdate |
static class |
ExternalIdsUpdate.Server
Factory to create an ExternalIdsUpdate instance for updating external IDs by the Gerrit server.
|
static class |
ExternalIdsUpdate.ServerNoReindex
Factory to create an ExternalIdsUpdate instance for updating external IDs by the Gerrit server.
|
static class |
ExternalIdsUpdate.UpdatedExternalIds |
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,
com.google.gerrit.metrics.MetricMaker metricMaker,
ExternalIds externalIds,
com.google.gerrit.server.account.externalids.ExternalIdCache externalIdCache,
org.eclipse.jgit.lib.PersonIdent committerIdent,
org.eclipse.jgit.lib.PersonIdent authorIdent,
IdentifiedUser currentUser,
GitReferenceUpdated gitRefUpdated,
java.lang.Runnable afterReadRevision,
com.github.rholder.retry.Retryer<ExternalIdsUpdate.RefsMetaExternalIdsUpdate> 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 org.eclipse.jgit.lib.ObjectId |
commit(Project.NameKey project,
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,
IdentifiedUser user,
GitReferenceUpdated gitRefUpdated)
Commits updates to the external IDs.
|
void |
delete(Account.Id accountId,
java.util.Collection<ExternalId.Key> extIdKeys)
Delete external IDs by external ID key.
|
void |
delete(Account.Id accountId,
ExternalId.Key extIdKey)
Delete an external ID by key.
|
void |
delete(java.util.Collection<ExternalId> extIds)
Deletes external IDs.
|
void |
delete(ExternalId extId)
Deletes an external ID.
|
void |
deleteAll(Account.Id accountId)
Deletes all external IDs of the specified account.
|
void |
deleteByKeys(java.util.Collection<ExternalId.Key> extIdKeys)
Delete external IDs by external ID key.
|
void |
insert(java.util.Collection<ExternalId> extIds)
Inserts new external IDs.
|
void |
insert(ExternalId extId)
Inserts a new external ID.
|
static ExternalId |
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 ExternalId |
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(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(java.util.Collection<ExternalId> toDelete,
java.util.Collection<ExternalId> toAdd)
Replaces external IDs.
|
void |
replace(ExternalId toDelete,
ExternalId toAdd)
Replaces an external ID.
|
void |
replaceByKeys(java.util.Collection<ExternalId.Key> toDelete,
java.util.Collection<ExternalId> toAdd)
Replaces external IDs for an account by external ID keys.
|
static com.github.rholder.retry.RetryerBuilder<ExternalIdsUpdate.RefsMetaExternalIdsUpdate> |
retryerBuilder() |
void |
upsert(java.util.Collection<ExternalId> extIds)
Inserts or updates external IDs.
|
void |
upsert(ExternalId extId)
Inserts or updates an external ID.
|
static ExternalId |
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, com.google.gerrit.metrics.MetricMaker metricMaker, ExternalIds externalIds, com.google.gerrit.server.account.externalids.ExternalIdCache externalIdCache, org.eclipse.jgit.lib.PersonIdent committerIdent, org.eclipse.jgit.lib.PersonIdent authorIdent, IdentifiedUser currentUser, GitReferenceUpdated gitRefUpdated, java.lang.Runnable afterReadRevision, com.github.rholder.retry.Retryer<ExternalIdsUpdate.RefsMetaExternalIdsUpdate> retryer)
public static com.github.rholder.retry.RetryerBuilder<ExternalIdsUpdate.RefsMetaExternalIdsUpdate> retryerBuilder()
public void insert(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(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(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(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(ExternalId extId) throws java.io.IOException, org.eclipse.jgit.errors.ConfigInvalidException, com.google.gwtorm.server.OrmException
java.lang.IllegalStateException
- is thrown 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(java.util.Collection<ExternalId> extIds) throws java.io.IOException, org.eclipse.jgit.errors.ConfigInvalidException, com.google.gwtorm.server.OrmException
java.lang.IllegalStateException
- is thrown 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(Account.Id accountId, ExternalId.Key extIdKey) throws java.io.IOException, org.eclipse.jgit.errors.ConfigInvalidException, com.google.gwtorm.server.OrmException
java.lang.IllegalStateException
- is thrown if the external ID does not belong to the specified
account.java.io.IOException
org.eclipse.jgit.errors.ConfigInvalidException
com.google.gwtorm.server.OrmException
public void delete(Account.Id accountId, java.util.Collection<ExternalId.Key> extIdKeys) throws java.io.IOException, org.eclipse.jgit.errors.ConfigInvalidException, com.google.gwtorm.server.OrmException
java.lang.IllegalStateException
- is thrown if any of the external IDs does not belong to the
specified account.java.io.IOException
org.eclipse.jgit.errors.ConfigInvalidException
com.google.gwtorm.server.OrmException
public void deleteByKeys(java.util.Collection<ExternalId.Key> extIdKeys) throws java.io.IOException, org.eclipse.jgit.errors.ConfigInvalidException, com.google.gwtorm.server.OrmException
The external IDs are deleted regardless of which account they belong to.
java.io.IOException
org.eclipse.jgit.errors.ConfigInvalidException
com.google.gwtorm.server.OrmException
public void deleteAll(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(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).
java.lang.IllegalStateException
- is thrown if any of the specified external IDs does not belong to
the specified account.java.io.IOException
org.eclipse.jgit.errors.ConfigInvalidException
com.google.gwtorm.server.OrmException
public void replaceByKeys(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).
The external IDs are replaced regardless of which account they belong to.
java.io.IOException
org.eclipse.jgit.errors.ConfigInvalidException
com.google.gwtorm.server.OrmException
public void replace(ExternalId toDelete, ExternalId toAdd) throws java.io.IOException, org.eclipse.jgit.errors.ConfigInvalidException, com.google.gwtorm.server.OrmException
java.lang.IllegalStateException
- is thrown if the specified external IDs belong to different
accounts.java.io.IOException
org.eclipse.jgit.errors.ConfigInvalidException
com.google.gwtorm.server.OrmException
public void replace(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).
java.lang.IllegalStateException
- is thrown if the specified external IDs belong to different
accounts.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 ExternalId 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 ExternalId 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 ExternalId remove(org.eclipse.jgit.revwalk.RevWalk rw, org.eclipse.jgit.notes.NoteMap noteMap, ExternalId extId) throws java.io.IOException, org.eclipse.jgit.errors.ConfigInvalidException
java.lang.IllegalStateException
- is thrown 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 org.eclipse.jgit.lib.ObjectId commit(Project.NameKey project, 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, IdentifiedUser user, GitReferenceUpdated gitRefUpdated) throws java.io.IOException
java.io.IOException