mirror of
https://github.com/google/nomulus
synced 2026-02-05 12:31:15 +00:00
Remove Registrar caching from all console actions
Caching turns out to be an anti-pattern for the console. If we use it, changes from the user just get obliterated by the older, cached version the next time the console refreshes (and it happens to refresh after every update). Caching is also not very useful here, as the amount of database access driven by the console is very small. ------------- Created by MOE: https://github.com/google/moe MOE_MIGRATED_REVID=190650931
This commit is contained in:
@@ -157,7 +157,7 @@ public final class RegistrarPaymentAction implements Runnable, JsonAction {
|
||||
|
||||
@Override
|
||||
public Map<String, Object> handleJsonRequest(Map<String, ?> json) {
|
||||
Registrar registrar = sessionUtils.getRegistrarForAuthResult(request, authResult, false);
|
||||
Registrar registrar = sessionUtils.getRegistrarForAuthResult(request, authResult);
|
||||
logger.infofmt("Processing payment: %s", json);
|
||||
String paymentMethodNonce;
|
||||
Money amount;
|
||||
|
||||
@@ -91,7 +91,7 @@ public final class RegistrarPaymentSetupAction implements Runnable, JsonAction {
|
||||
|
||||
@Override
|
||||
public Map<String, Object> handleJsonRequest(Map<String, ?> json) {
|
||||
Registrar registrar = sessionUtils.getRegistrarForAuthResult(request, authResult, false);
|
||||
Registrar registrar = sessionUtils.getRegistrarForAuthResult(request, authResult);
|
||||
|
||||
if (!json.isEmpty()) {
|
||||
return JsonResponseHelper.create(ERROR, "JSON request object must be empty");
|
||||
|
||||
@@ -81,7 +81,7 @@ public class RegistrarPremiumPriceAckAction implements Runnable, JsonActionRunne
|
||||
}
|
||||
|
||||
// Get the registrar
|
||||
Registrar initialRegistrar = sessionUtils.getRegistrarForAuthResult(request, authResult, true);
|
||||
Registrar initialRegistrar = sessionUtils.getRegistrarForAuthResult(request, authResult);
|
||||
|
||||
// Process the operation. Though originally derived from a CRUD handler, registrar-settings
|
||||
// and registrar-premium-price-action really only support read and update.
|
||||
|
||||
@@ -93,7 +93,7 @@ public class RegistrarSettingsAction implements Runnable, JsonActionRunner.JsonA
|
||||
throw new BadRequestException("Malformed JSON");
|
||||
}
|
||||
|
||||
Registrar initialRegistrar = sessionUtils.getRegistrarForAuthResult(request, authResult, false);
|
||||
Registrar initialRegistrar = sessionUtils.getRegistrarForAuthResult(request, authResult);
|
||||
// Process the operation. Though originally derived from a CRUD
|
||||
// handler, registrar-settings really only supports read and update.
|
||||
String op = Optional.ofNullable((String) input.get(OP_PARAM)).orElse("read");
|
||||
|
||||
@@ -59,8 +59,7 @@ public class SessionUtils {
|
||||
* the registrar console.
|
||||
*/
|
||||
@CheckReturnValue
|
||||
Registrar getRegistrarForAuthResult(
|
||||
HttpServletRequest request, AuthResult authResult, boolean bypassCache) {
|
||||
Registrar getRegistrarForAuthResult(HttpServletRequest request, AuthResult authResult) {
|
||||
if (!authResult.userAuthInfo().isPresent()) {
|
||||
throw new ForbiddenException("Not logged in");
|
||||
}
|
||||
@@ -69,9 +68,7 @@ public class SessionUtils {
|
||||
}
|
||||
String clientId = getRegistrarClientId(request);
|
||||
return checkArgumentPresent(
|
||||
bypassCache
|
||||
? Registrar.loadByClientId(clientId)
|
||||
: Registrar.loadByClientIdCached(clientId),
|
||||
Registrar.loadByClientId(clientId),
|
||||
"Registrar %s not found",
|
||||
clientId);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user