diff --git a/gerrit-common/src/main/java/com/google/gerrit/common/data/AccountSecurity.java b/gerrit-common/src/main/java/com/google/gerrit/common/data/AccountSecurity.java index b402f6cbe5..afd673497c 100644 --- a/gerrit-common/src/main/java/com/google/gerrit/common/data/AccountSecurity.java +++ b/gerrit-common/src/main/java/com/google/gerrit/common/data/AccountSecurity.java @@ -21,7 +21,6 @@ import com.google.gwtjsonrpc.common.AsyncCallback; import com.google.gwtjsonrpc.common.RemoteJsonService; import com.google.gwtjsonrpc.common.RpcImpl; import com.google.gwtjsonrpc.common.RpcImpl.Version; -import com.google.gwtjsonrpc.common.VoidResult; import java.util.List; import java.util.Set; @@ -35,9 +34,4 @@ public interface AccountSecurity extends RemoteJsonService { @SignInRequired void deleteExternalIds(Set keys, AsyncCallback> callback); - - @Audit - @SignInRequired - void enterAgreement(String agreementName, - AsyncCallback callback); } diff --git a/gerrit-httpd/src/main/java/com/google/gerrit/httpd/rpc/account/AccountSecurityImpl.java b/gerrit-httpd/src/main/java/com/google/gerrit/httpd/rpc/account/AccountSecurityImpl.java index 873dc0a7d9..3d0554868b 100644 --- a/gerrit-httpd/src/main/java/com/google/gerrit/httpd/rpc/account/AccountSecurityImpl.java +++ b/gerrit-httpd/src/main/java/com/google/gerrit/httpd/rpc/account/AccountSecurityImpl.java @@ -14,66 +14,31 @@ package com.google.gerrit.httpd.rpc.account; -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.httpd.rpc.BaseServiceImplementation; -import com.google.gerrit.reviewdb.client.Account; import com.google.gerrit.reviewdb.client.AccountExternalId; -import com.google.gerrit.reviewdb.client.AccountGroup; -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.AccountCache; -import com.google.gerrit.server.account.GroupCache; -import com.google.gerrit.server.extensions.events.AgreementSignup; -import com.google.gerrit.server.project.ProjectCache; import com.google.gwtjsonrpc.common.AsyncCallback; -import com.google.gwtjsonrpc.common.VoidResult; -import com.google.gwtorm.server.OrmException; import com.google.inject.Inject; import com.google.inject.Provider; -import java.io.IOException; -import java.util.Collections; import java.util.List; import java.util.Set; class AccountSecurityImpl extends BaseServiceImplementation implements AccountSecurity { - private final ProjectCache projectCache; - private final Provider user; - private final AccountCache accountCache; - private final DeleteExternalIds.Factory deleteExternalIdsFactory; private final ExternalIdDetailFactory.Factory externalIdDetailFactory; - private final GroupCache groupCache; - private final AuditService auditService; - private final AgreementSignup agreementSignup; - @Inject AccountSecurityImpl(final Provider schema, final Provider currentUser, - final Provider u, - final ProjectCache pc, - final AccountCache uac, final DeleteExternalIds.Factory deleteExternalIdsFactory, - final ExternalIdDetailFactory.Factory externalIdDetailFactory, - final GroupCache groupCache, - final AuditService auditService, - AgreementSignup agreementSignup) { + final ExternalIdDetailFactory.Factory externalIdDetailFactory) { super(schema, currentUser); - user = u; - projectCache = pc; - accountCache = uac; - this.auditService = auditService; this.deleteExternalIdsFactory = deleteExternalIdsFactory; this.externalIdDetailFactory = externalIdDetailFactory; - this.groupCache = groupCache; - this.agreementSignup = agreementSignup; } @Override @@ -86,48 +51,4 @@ class AccountSecurityImpl extends BaseServiceImplementation implements final AsyncCallback> callback) { deleteExternalIdsFactory.create(keys).to(callback); } - - @Override - public void enterAgreement(final String agreementName, - final AsyncCallback callback) { - run(callback, new Action() { - @Override - public VoidResult run(final ReviewDb db) - throws OrmException, Failure, IOException { - ContributorAgreement ca = projectCache.getAllProjects().getConfig() - .getContributorAgreement(agreementName); - if (ca == null) { - throw new Failure(new NoSuchEntityException()); - } - - if (ca.getAutoVerify() == null) { - throw new Failure(new IllegalStateException( - "cannot enter a non-autoVerify agreement")); - } else if (ca.getAutoVerify().getUUID() == null) { - throw new Failure(new NoSuchEntityException()); - } - - AccountGroup group = groupCache.get(ca.getAutoVerify().getUUID()); - if (group == null) { - throw new Failure(new NoSuchEntityException()); - } - - Account account = user.get().getAccount(); - agreementSignup.fire(account, ca.getName()); - - final AccountGroupMember.Key key = - new AccountGroupMember.Key(account.getId(), group.getId()); - AccountGroupMember m = db.accountGroupMembers().get(key); - if (m == null) { - m = new AccountGroupMember(key); - auditService.dispatchAddAccountsToGroup(account.getId(), Collections - .singleton(m)); - db.accountGroupMembers().insert(Collections.singleton(m)); - accountCache.evict(m.getAccountId()); - } - - return VoidResult.INSTANCE; - } - }); - } }