mirror of
https://github.com/google/nomulus.git
synced 2025-05-13 07:57:13 +02:00
Get rid of @Nullable on the injected client id
This allows us to inject an optional once, in FlowRunner, and inject a non-null value in the flows (not done yet, after this goes in). ------------- Created by MOE: https://github.com/google/moe MOE_MIGRATED_REVID=133130485
This commit is contained in:
parent
99af33328d
commit
3978b4f169
3 changed files with 8 additions and 9 deletions
|
@ -16,6 +16,7 @@ package google.registry.flows;
|
||||||
|
|
||||||
import static com.google.common.base.Preconditions.checkState;
|
import static com.google.common.base.Preconditions.checkState;
|
||||||
|
|
||||||
|
import com.google.common.base.Strings;
|
||||||
import dagger.Module;
|
import dagger.Module;
|
||||||
import dagger.Provides;
|
import dagger.Provides;
|
||||||
import google.registry.flows.exceptions.OnlyToolCanPassMetadataException;
|
import google.registry.flows.exceptions.OnlyToolCanPassMetadataException;
|
||||||
|
@ -27,7 +28,6 @@ import google.registry.model.eppinput.EppInput.ResourceCommandWrapper;
|
||||||
import google.registry.model.eppinput.ResourceCommand;
|
import google.registry.model.eppinput.ResourceCommand;
|
||||||
import google.registry.model.reporting.HistoryEntry;
|
import google.registry.model.reporting.HistoryEntry;
|
||||||
import java.lang.annotation.Documented;
|
import java.lang.annotation.Documented;
|
||||||
import javax.annotation.Nullable;
|
|
||||||
import javax.inject.Qualifier;
|
import javax.inject.Qualifier;
|
||||||
|
|
||||||
/** Module to choose and instantiate an EPP flow. */
|
/** Module to choose and instantiate an EPP flow. */
|
||||||
|
@ -147,10 +147,11 @@ public class FlowModule {
|
||||||
|
|
||||||
@Provides
|
@Provides
|
||||||
@FlowScope
|
@FlowScope
|
||||||
@Nullable
|
|
||||||
@ClientId
|
@ClientId
|
||||||
static String provideClientId(SessionMetadata sessionMetadata) {
|
static String provideClientId(SessionMetadata sessionMetadata) {
|
||||||
return sessionMetadata.getClientId();
|
// Treat a missing clientId as null so we can always inject a non-null value. All we do with the
|
||||||
|
// clientId is log it (as "") or detect its absence, both of which work fine with empty.
|
||||||
|
return Strings.nullToEmpty(sessionMetadata.getClientId());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Provides
|
@Provides
|
||||||
|
@ -187,7 +188,7 @@ public class FlowModule {
|
||||||
Trid trid,
|
Trid trid,
|
||||||
@InputXml byte[] inputXmlBytes,
|
@InputXml byte[] inputXmlBytes,
|
||||||
@Superuser boolean isSuperuser,
|
@Superuser boolean isSuperuser,
|
||||||
@ClientId @Nullable String clientId,
|
@ClientId String clientId,
|
||||||
EppRequestSource eppRequestSource,
|
EppRequestSource eppRequestSource,
|
||||||
EppInput eppInput) {
|
EppInput eppInput) {
|
||||||
HistoryEntry.Builder historyBuilder = new HistoryEntry.Builder()
|
HistoryEntry.Builder historyBuilder = new HistoryEntry.Builder()
|
||||||
|
|
|
@ -14,7 +14,6 @@
|
||||||
|
|
||||||
package google.registry.flows;
|
package google.registry.flows;
|
||||||
|
|
||||||
import static com.google.common.base.Strings.nullToEmpty;
|
|
||||||
import static com.google.common.base.Throwables.getStackTraceAsString;
|
import static com.google.common.base.Throwables.getStackTraceAsString;
|
||||||
import static com.google.common.io.BaseEncoding.base64;
|
import static com.google.common.io.BaseEncoding.base64;
|
||||||
import static google.registry.model.ofy.ObjectifyService.ofy;
|
import static google.registry.model.ofy.ObjectifyService.ofy;
|
||||||
|
@ -34,7 +33,6 @@ import google.registry.model.eppoutput.EppOutput;
|
||||||
import google.registry.monitoring.whitebox.EppMetric;
|
import google.registry.monitoring.whitebox.EppMetric;
|
||||||
import google.registry.util.Clock;
|
import google.registry.util.Clock;
|
||||||
import google.registry.util.FormattingLogger;
|
import google.registry.util.FormattingLogger;
|
||||||
import javax.annotation.Nullable;
|
|
||||||
import javax.inject.Inject;
|
import javax.inject.Inject;
|
||||||
import javax.inject.Provider;
|
import javax.inject.Provider;
|
||||||
import org.joda.time.DateTime;
|
import org.joda.time.DateTime;
|
||||||
|
@ -57,7 +55,7 @@ public class FlowRunner {
|
||||||
|
|
||||||
private static final FormattingLogger logger = FormattingLogger.getLoggerForCallerClass();
|
private static final FormattingLogger logger = FormattingLogger.getLoggerForCallerClass();
|
||||||
|
|
||||||
@Inject @Nullable @ClientId String clientId;
|
@Inject @ClientId String clientId;
|
||||||
@Inject Clock clock;
|
@Inject Clock clock;
|
||||||
@Inject TransportCredentials credentials;
|
@Inject TransportCredentials credentials;
|
||||||
@Inject EppInput eppInput;
|
@Inject EppInput eppInput;
|
||||||
|
@ -96,7 +94,7 @@ public class FlowRunner {
|
||||||
REPORTING_LOG_SIGNATURE,
|
REPORTING_LOG_SIGNATURE,
|
||||||
JSONValue.toJSONString(ImmutableMap.<String, Object>of(
|
JSONValue.toJSONString(ImmutableMap.<String, Object>of(
|
||||||
"trid", trid.getServerTransactionId(),
|
"trid", trid.getServerTransactionId(),
|
||||||
"clientId", nullToEmpty(clientId),
|
"clientId", clientId,
|
||||||
"xml", prettyXml,
|
"xml", prettyXml,
|
||||||
"xmlBytes", xmlBase64)));
|
"xmlBytes", xmlBase64)));
|
||||||
if (!isTransactional) {
|
if (!isTransactional) {
|
||||||
|
|
|
@ -123,7 +123,7 @@ public class FlowRunnerTest extends ShardableTestCase {
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testRun_reportingLogStatement_noClientId() throws Exception {
|
public void testRun_reportingLogStatement_noClientId() throws Exception {
|
||||||
flowRunner.clientId = null;
|
flowRunner.clientId = "";
|
||||||
flowRunner.run();
|
flowRunner.run();
|
||||||
assertThat(parseJsonMap(findLogMessageByPrefix(handler, "EPP-REPORTING-LOG-SIGNATURE: ")))
|
assertThat(parseJsonMap(findLogMessageByPrefix(handler, "EPP-REPORTING-LOG-SIGNATURE: ")))
|
||||||
.containsExactly(
|
.containsExactly(
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue