Reindex account whenever account is evicted from cache

Change-Id: I025cabc9be98628777066cda7aa97186f5a0da15
Signed-off-by: Edwin Kempin <ekempin@google.com>
This commit is contained in:
Edwin Kempin
2016-06-20 16:06:54 +02:00
parent ebbf81470a
commit 94732bfa19
29 changed files with 115 additions and 55 deletions

View File

@@ -219,7 +219,7 @@ class BecomeAnyAccountLoginServlet extends HttpServlet {
}
}
private AuthResult create() {
private AuthResult create() throws IOException {
String fakeId = AccountExternalId.SCHEME_UUID + UUID.randomUUID();
try {
return accountManager.authenticate(new AuthRequest(fakeId));

View File

@@ -153,7 +153,7 @@ class HttpLoginServlet extends HttpServlet {
}
private void updateRemoteExternalId(AuthResult arsp, String remoteAuthToken)
throws AccountException, OrmException {
throws AccountException, OrmException, IOException {
AccountExternalId remoteAuthExtId =
new AccountExternalId(arsp.getAccountId(), new AccountExternalId.Key(
SCHEME_EXTERNAL, remoteAuthToken));

View File

@@ -27,6 +27,8 @@ import com.google.gwtorm.server.OrmException;
import com.google.gwtorm.server.OrmRuntimeException;
import com.google.inject.Provider;
import java.io.IOException;
/** Support for services which require a {@link ReviewDb} instance. */
public class BaseServiceImplementation {
private final Provider<ReviewDb> schema;
@@ -86,6 +88,8 @@ public class BaseServiceImplementation {
handleOrmException(callback, ex);
} catch (OrmException e) {
handleOrmException(callback, e);
} catch (IOException e) {
callback.onFailure(e);
} catch (Failure e) {
if (e.getCause() instanceof NoSuchProjectException
|| e.getCause() instanceof NoSuchChangeException) {
@@ -132,6 +136,6 @@ public class BaseServiceImplementation {
* @throws InvalidQueryException
*/
T run(ReviewDb db) throws OrmException, Failure, NoSuchProjectException,
NoSuchGroupException, InvalidQueryException;
NoSuchGroupException, InvalidQueryException, IOException;
}
}

View File

@@ -40,6 +40,7 @@ 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;
@@ -98,7 +99,8 @@ class AccountSecurityImpl extends BaseServiceImplementation implements
final AsyncCallback<Account> callback) {
run(callback, new Action<Account>() {
@Override
public Account run(ReviewDb db) throws OrmException, Failure {
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();
@@ -133,7 +135,8 @@ class AccountSecurityImpl extends BaseServiceImplementation implements
final AsyncCallback<VoidResult> callback) {
run(callback, new Action<VoidResult>() {
@Override
public VoidResult run(final ReviewDb db) throws OrmException, Failure {
public VoidResult run(final ReviewDb db)
throws OrmException, Failure, IOException {
ContributorAgreement ca = projectCache.getAllProjects().getConfig()
.getContributorAgreement(agreementName);
if (ca == null) {

View File

@@ -24,6 +24,7 @@ import com.google.gwtorm.server.OrmException;
import com.google.inject.Inject;
import com.google.inject.assistedinject.Assisted;
import java.io.IOException;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.HashSet;
@@ -60,7 +61,7 @@ class DeleteExternalIds extends Handler<Set<AccountExternalId.Key>> {
}
@Override
public Set<AccountExternalId.Key> call() throws OrmException {
public Set<AccountExternalId.Key> call() throws OrmException, IOException {
final Map<AccountExternalId.Key, AccountExternalId> have = have();
List<AccountExternalId> toDelete = new ArrayList<>();