Set svID in ConfigModule instead of hard-coding it

-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=138552819
This commit is contained in:
Francis Aiello 2016-11-08 12:56:24 -08:00 committed by Ben McIlwain
parent 1abd0e1123
commit 1671508547
3 changed files with 17 additions and 3 deletions

View file

@ -863,4 +863,15 @@ public final class ConfigModule {
public static Duration provideAsyncDeleteFlowMapreduceDelay() { public static Duration provideAsyncDeleteFlowMapreduceDelay() {
return Duration.standardSeconds(90); return Duration.standardSeconds(90);
} }
/**
* The server ID used in the 'svID' element of an EPP 'greeting'.
*
* @see <a href="https://tools.ietf.org/html/rfc5730">RFC 7530</a>
*/
@Provides
@Config("greetingServerId")
public static String provideGreetingServerId() {
return "Charleston Road Registry";
}
} }

View file

@ -14,6 +14,7 @@
package google.registry.flows.session; package google.registry.flows.session;
import google.registry.config.ConfigModule.Config;
import google.registry.flows.EppException; import google.registry.flows.EppException;
import google.registry.flows.ExtensionManager; import google.registry.flows.ExtensionManager;
import google.registry.flows.Flow; import google.registry.flows.Flow;
@ -26,11 +27,12 @@ public class HelloFlow implements Flow {
@Inject ExtensionManager extensionManager; @Inject ExtensionManager extensionManager;
@Inject Clock clock; @Inject Clock clock;
@Inject @Config("greetingServerId") String greetingServerId;
@Inject HelloFlow() {} @Inject HelloFlow() {}
@Override @Override
public Greeting run() throws EppException { public Greeting run() throws EppException {
extensionManager.validate(); // There are no legal extensions for this flow. extensionManager.validate(); // There are no legal extensions for this flow.
return Greeting.create(clock.nowUtc()); return Greeting.create(clock.nowUtc(), greetingServerId);
} }
} }

View file

@ -31,7 +31,7 @@ import org.joda.time.DateTime;
*/ */
public class Greeting extends ImmutableObject implements ResponseOrGreeting { public class Greeting extends ImmutableObject implements ResponseOrGreeting {
String svID = "Charleston Road Registry"; String svID;
DateTime svDate; DateTime svDate;
/** This is never changed, so it might as well be static for efficiency. */ /** This is never changed, so it might as well be static for efficiency. */
@ -42,8 +42,9 @@ public class Greeting extends ImmutableObject implements ResponseOrGreeting {
@XmlElement @XmlElement
static Dcp dcp = new Dcp(); static Dcp dcp = new Dcp();
public static Greeting create(DateTime svDate) { public static Greeting create(DateTime svDate, String svID) {
Greeting instance = new Greeting(); Greeting instance = new Greeting();
instance.svID = svID;
instance.svDate = svDate; instance.svDate = svDate;
return instance; return instance;
} }