AccountSecurity: Remove unused updateContact method
All UI screens now use the REST API. Change-Id: Ia5934d58e1173e3e47f595fc2a468832f3960099 Signed-off-by: Edwin Kempin <ekempin@google.com>
This commit is contained in:
committed by
Edwin Kempin
parent
576df448d7
commit
8539921636
@@ -16,7 +16,6 @@ package com.google.gerrit.common.data;
|
||||
|
||||
import com.google.gerrit.common.audit.Audit;
|
||||
import com.google.gerrit.common.auth.SignInRequired;
|
||||
import com.google.gerrit.reviewdb.client.Account;
|
||||
import com.google.gerrit.reviewdb.client.AccountExternalId;
|
||||
import com.google.gwtjsonrpc.common.AsyncCallback;
|
||||
import com.google.gwtjsonrpc.common.RemoteJsonService;
|
||||
@@ -37,11 +36,6 @@ public interface AccountSecurity extends RemoteJsonService {
|
||||
void deleteExternalIds(Set<AccountExternalId.Key> keys,
|
||||
AsyncCallback<Set<AccountExternalId.Key>> callback);
|
||||
|
||||
@Audit
|
||||
@SignInRequired
|
||||
void updateContact(String fullName, String emailAddr,
|
||||
AsyncCallback<Account> callback);
|
||||
|
||||
@Audit
|
||||
@SignInRequired
|
||||
void enterAgreement(String agreementName,
|
||||
|
||||
@@ -14,12 +14,10 @@
|
||||
|
||||
package com.google.gerrit.httpd.rpc.account;
|
||||
|
||||
import com.google.common.base.Strings;
|
||||
import com.google.gerrit.audit.AuditService;
|
||||
import com.google.gerrit.common.data.AccountSecurity;
|
||||
import com.google.gerrit.common.data.ContributorAgreement;
|
||||
import com.google.gerrit.common.errors.NoSuchEntityException;
|
||||
import com.google.gerrit.common.errors.PermissionDeniedException;
|
||||
import com.google.gerrit.httpd.rpc.BaseServiceImplementation;
|
||||
import com.google.gerrit.reviewdb.client.Account;
|
||||
import com.google.gerrit.reviewdb.client.AccountExternalId;
|
||||
@@ -28,10 +26,8 @@ import com.google.gerrit.reviewdb.client.AccountGroupMember;
|
||||
import com.google.gerrit.reviewdb.server.ReviewDb;
|
||||
import com.google.gerrit.server.CurrentUser;
|
||||
import com.google.gerrit.server.IdentifiedUser;
|
||||
import com.google.gerrit.server.account.AccountByEmailCache;
|
||||
import com.google.gerrit.server.account.AccountCache;
|
||||
import com.google.gerrit.server.account.GroupCache;
|
||||
import com.google.gerrit.server.account.Realm;
|
||||
import com.google.gerrit.server.extensions.events.AgreementSignup;
|
||||
import com.google.gerrit.server.project.ProjectCache;
|
||||
import com.google.gwtjsonrpc.common.AsyncCallback;
|
||||
@@ -47,10 +43,8 @@ import java.util.Set;
|
||||
|
||||
class AccountSecurityImpl extends BaseServiceImplementation implements
|
||||
AccountSecurity {
|
||||
private final Realm realm;
|
||||
private final ProjectCache projectCache;
|
||||
private final Provider<IdentifiedUser> user;
|
||||
private final AccountByEmailCache byEmailCache;
|
||||
private final AccountCache accountCache;
|
||||
|
||||
private final DeleteExternalIds.Factory deleteExternalIdsFactory;
|
||||
@@ -63,19 +57,17 @@ class AccountSecurityImpl extends BaseServiceImplementation implements
|
||||
@Inject
|
||||
AccountSecurityImpl(final Provider<ReviewDb> schema,
|
||||
final Provider<CurrentUser> currentUser,
|
||||
final Realm r, final Provider<IdentifiedUser> u,
|
||||
final Provider<IdentifiedUser> u,
|
||||
final ProjectCache pc,
|
||||
final AccountByEmailCache abec, final AccountCache uac,
|
||||
final AccountCache uac,
|
||||
final DeleteExternalIds.Factory deleteExternalIdsFactory,
|
||||
final ExternalIdDetailFactory.Factory externalIdDetailFactory,
|
||||
final GroupCache groupCache,
|
||||
final AuditService auditService,
|
||||
AgreementSignup agreementSignup) {
|
||||
super(schema, currentUser);
|
||||
realm = r;
|
||||
user = u;
|
||||
projectCache = pc;
|
||||
byEmailCache = abec;
|
||||
accountCache = uac;
|
||||
this.auditService = auditService;
|
||||
this.deleteExternalIdsFactory = deleteExternalIdsFactory;
|
||||
@@ -95,42 +87,6 @@ class AccountSecurityImpl extends BaseServiceImplementation implements
|
||||
deleteExternalIdsFactory.create(keys).to(callback);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void updateContact(final String name, final String emailAddr,
|
||||
final AsyncCallback<Account> callback) {
|
||||
run(callback, new Action<Account>() {
|
||||
@Override
|
||||
public Account run(ReviewDb db)
|
||||
throws OrmException, Failure, IOException {
|
||||
IdentifiedUser self = user.get();
|
||||
final Account me = db.accounts().get(self.getAccountId());
|
||||
final String oldEmail = me.getPreferredEmail();
|
||||
if (realm.allowsEdit(Account.FieldName.FULL_NAME)) {
|
||||
me.setFullName(Strings.emptyToNull(name));
|
||||
}
|
||||
if (!Strings.isNullOrEmpty(emailAddr)
|
||||
&& !self.hasEmailAddress(emailAddr)) {
|
||||
throw new Failure(new PermissionDeniedException("Email address must be verified"));
|
||||
}
|
||||
me.setPreferredEmail(Strings.emptyToNull(emailAddr));
|
||||
db.accounts().update(Collections.singleton(me));
|
||||
if (!eq(oldEmail, me.getPreferredEmail())) {
|
||||
byEmailCache.evict(oldEmail);
|
||||
byEmailCache.evict(me.getPreferredEmail());
|
||||
}
|
||||
accountCache.evict(me.getId());
|
||||
return me;
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
private static boolean eq(final String a, final String b) {
|
||||
if (a == null && b == null) {
|
||||
return true;
|
||||
}
|
||||
return a != null && a.equals(b);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void enterAgreement(final String agreementName,
|
||||
final AsyncCallback<VoidResult> callback) {
|
||||
|
||||
Reference in New Issue
Block a user