AccountsUpdate: Rename atomicUpdate to update
After the old update method has been renamed to replace, there is no need to keep 'atomic' in the method name. Change-Id: I465d29f567f827868928b178037e26313e2b6cec Signed-off-by: Edwin Kempin <ekempin@google.com>
This commit is contained in:
@@ -115,7 +115,7 @@ public class GerritPublicKeyCheckerTest {
|
||||
schemaCreator.create(db);
|
||||
userId = accountManager.authenticate(AuthRequest.forUser("user")).getAccountId();
|
||||
// Note: does not match any key in TestKeys.
|
||||
accountsUpdate.create().atomicUpdate(db, userId, a -> a.setPreferredEmail("user@example.com"));
|
||||
accountsUpdate.create().update(db, userId, a -> a.setPreferredEmail("user@example.com"));
|
||||
user = reloadUser();
|
||||
|
||||
requestContext.setContext(
|
||||
|
||||
@@ -186,7 +186,7 @@ public class AccountManager {
|
||||
|
||||
if (!accountUpdates.isEmpty()) {
|
||||
Account account =
|
||||
accountsUpdateFactory.create().atomicUpdate(db, user.getAccountId(), accountUpdates);
|
||||
accountsUpdateFactory.create().update(db, user.getAccountId(), accountUpdates);
|
||||
if (account == null) {
|
||||
throw new OrmException("Account " + user.getAccountId() + " has been deleted");
|
||||
}
|
||||
@@ -365,7 +365,7 @@ public class AccountManager {
|
||||
if (who.getEmailAddress() != null) {
|
||||
accountsUpdateFactory
|
||||
.create()
|
||||
.atomicUpdate(
|
||||
.update(
|
||||
db,
|
||||
to,
|
||||
a -> {
|
||||
@@ -434,7 +434,7 @@ public class AccountManager {
|
||||
if (who.getEmailAddress() != null) {
|
||||
accountsUpdateFactory
|
||||
.create()
|
||||
.atomicUpdate(
|
||||
.update(
|
||||
db,
|
||||
from,
|
||||
a -> {
|
||||
|
||||
@@ -229,9 +229,9 @@ public class AccountsUpdate {
|
||||
* @throws IOException if updating the user branch fails
|
||||
* @throws ConfigInvalidException if any of the account fields has an invalid value
|
||||
*/
|
||||
public Account atomicUpdate(ReviewDb db, Account.Id accountId, Consumer<Account> consumer)
|
||||
public Account update(ReviewDb db, Account.Id accountId, Consumer<Account> consumer)
|
||||
throws OrmException, IOException, ConfigInvalidException {
|
||||
return atomicUpdate(db, accountId, ImmutableList.of(consumer));
|
||||
return update(db, accountId, ImmutableList.of(consumer));
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -243,9 +243,11 @@ public class AccountsUpdate {
|
||||
* @param accountId ID of the account
|
||||
* @param consumers consumers to update the account, only invoked if the account exists
|
||||
* @return the updated account, {@code null} if the account doesn't exist
|
||||
* @throws OrmException if updating the account fails
|
||||
* @throws OrmException if updating the database fails
|
||||
* @throws IOException if updating the user branch fails
|
||||
* @throws ConfigInvalidException if any of the account fields has an invalid value
|
||||
*/
|
||||
public Account atomicUpdate(ReviewDb db, Account.Id accountId, List<Consumer<Account>> consumers)
|
||||
public Account update(ReviewDb db, Account.Id accountId, List<Consumer<Account>> consumers)
|
||||
throws OrmException, IOException, ConfigInvalidException {
|
||||
if (consumers.isEmpty()) {
|
||||
return null;
|
||||
@@ -275,7 +277,7 @@ public class AccountsUpdate {
|
||||
* <p>The existing account with the same account ID is overwritten by the given account. Choosing
|
||||
* to overwrite an account means that any updates that were done to the account by a racing
|
||||
* request after the account was read are lost. Updates are also lost if the account was read from
|
||||
* a stale account index. This is why using {@link #atomicUpdate(ReviewDb,
|
||||
* a stale account index. This is why using {@link #update(ReviewDb,
|
||||
* com.google.gerrit.reviewdb.client.Account.Id, Consumer)} to do an atomic update is always
|
||||
* preferred.
|
||||
*
|
||||
@@ -286,7 +288,7 @@ public class AccountsUpdate {
|
||||
* @throws OrmException if updating the database fails
|
||||
* @throws IOException if updating the user branch fails
|
||||
* @throws ConfigInvalidException if any of the account fields has an invalid value
|
||||
* @see #atomicUpdate(ReviewDb, com.google.gerrit.reviewdb.client.Account.Id, Consumer)
|
||||
* @see #update(ReviewDb, com.google.gerrit.reviewdb.client.Account.Id, Consumer)
|
||||
*/
|
||||
public void replace(ReviewDb db, Account account)
|
||||
throws OrmException, IOException, ConfigInvalidException {
|
||||
|
||||
@@ -63,7 +63,7 @@ public class DeleteActive implements RestModifyView<AccountResource, Input> {
|
||||
Account account =
|
||||
accountsUpdate
|
||||
.create()
|
||||
.atomicUpdate(
|
||||
.update(
|
||||
dbProvider.get(),
|
||||
rsrc.getUser().getAccountId(),
|
||||
a -> {
|
||||
|
||||
@@ -51,7 +51,7 @@ public class PutActive implements RestModifyView<AccountResource, Input> {
|
||||
Account account =
|
||||
accountsUpdate
|
||||
.create()
|
||||
.atomicUpdate(
|
||||
.update(
|
||||
dbProvider.get(),
|
||||
rsrc.getUser().getAccountId(),
|
||||
a -> {
|
||||
|
||||
@@ -88,7 +88,7 @@ public class PutName implements RestModifyView<AccountResource, Input> {
|
||||
Account account =
|
||||
accountsUpdate
|
||||
.create()
|
||||
.atomicUpdate(dbProvider.get(), user.getAccountId(), a -> a.setFullName(newName));
|
||||
.update(dbProvider.get(), user.getAccountId(), a -> a.setFullName(newName));
|
||||
if (account == null) {
|
||||
throw new ResourceNotFoundException("account not found");
|
||||
}
|
||||
|
||||
@@ -71,7 +71,7 @@ public class PutPreferred implements RestModifyView<AccountResource.Email, Input
|
||||
Account account =
|
||||
accountsUpdate
|
||||
.create()
|
||||
.atomicUpdate(
|
||||
.update(
|
||||
dbProvider.get(),
|
||||
user.getAccountId(),
|
||||
a -> {
|
||||
|
||||
@@ -84,7 +84,7 @@ public class PutStatus implements RestModifyView<AccountResource, Input> {
|
||||
Account account =
|
||||
accountsUpdate
|
||||
.create()
|
||||
.atomicUpdate(
|
||||
.update(
|
||||
dbProvider.get(),
|
||||
user.getAccountId(),
|
||||
a -> a.setStatus(Strings.nullToEmpty(newStatus)));
|
||||
|
||||
@@ -2788,7 +2788,7 @@ public class ReceiveCommits {
|
||||
Account account =
|
||||
accountsUpdate
|
||||
.create()
|
||||
.atomicUpdate(
|
||||
.update(
|
||||
db,
|
||||
user.getAccountId(),
|
||||
a -> {
|
||||
|
||||
@@ -498,7 +498,7 @@ public abstract class AbstractQueryAccountsTest extends GerritServerTests {
|
||||
}
|
||||
accountsUpdate
|
||||
.create()
|
||||
.atomicUpdate(
|
||||
.update(
|
||||
db,
|
||||
id,
|
||||
a -> {
|
||||
|
||||
@@ -210,7 +210,7 @@ public abstract class AbstractQueryChangesTest extends GerritServerTests {
|
||||
userId = accountManager.authenticate(AuthRequest.forUser("user")).getAccountId();
|
||||
String email = "user@example.com";
|
||||
externalIdsUpdate.create().insert(ExternalId.createEmail(userId, email));
|
||||
accountsUpdate.create().atomicUpdate(db, userId, a -> a.setPreferredEmail(email));
|
||||
accountsUpdate.create().update(db, userId, a -> a.setPreferredEmail(email));
|
||||
user = userFactory.create(userId);
|
||||
requestContext.setContext(newRequestContext(userId));
|
||||
}
|
||||
@@ -2340,7 +2340,7 @@ public abstract class AbstractQueryChangesTest extends GerritServerTests {
|
||||
}
|
||||
accountsUpdate
|
||||
.create()
|
||||
.atomicUpdate(
|
||||
.update(
|
||||
db,
|
||||
id,
|
||||
a -> {
|
||||
|
||||
@@ -321,7 +321,7 @@ public abstract class AbstractQueryGroupsTest extends GerritServerTests {
|
||||
}
|
||||
accountsUpdate
|
||||
.create()
|
||||
.atomicUpdate(
|
||||
.update(
|
||||
db,
|
||||
id,
|
||||
a -> {
|
||||
|
||||
Reference in New Issue
Block a user