Light, fluffy, and always free - The AWS Local Emulator alternative
refactor(ses): rename SesController to SesSendController (#3837)
Kenshin Okinaka1d009b961441
diff --git a/src/main/java/io/github/hectorvent/floci/core/common/ResolvedServiceCatalog.java b/src/main/java/io/github/hectorvent/floci/core/common/ResolvedServiceCatalog.javaindex 6c4fd4aa96..60508da9cd 100644--- a/src/main/java/io/github/hectorvent/floci/core/common/ResolvedServiceCatalog.java+++ b/src/main/java/io/github/hectorvent/floci/core/common/ResolvedServiceCatalog.java@@ -36,10 +36,10 @@ import io.github.hectorvent.floci.services.route53.Route53Controller;import io.github.hectorvent.floci.services.ses.SesAccountController;import io.github.hectorvent.floci.services.ses.SesConfigurationSetController;import io.github.hectorvent.floci.services.ses.SesContactController;-import io.github.hectorvent.floci.services.ses.SesController;import io.github.hectorvent.floci.services.ses.SesCvetController;import io.github.hectorvent.floci.services.ses.SesDedicatedIpController;import io.github.hectorvent.floci.services.ses.SesIdentityController;+import io.github.hectorvent.floci.services.ses.SesSendController;import io.github.hectorvent.floci.services.ses.SesSuppressionController;import io.github.hectorvent.floci.services.ses.SesTagController;import io.github.hectorvent.floci.services.ses.SesTemplateController;@@ -296,12 +296,12 @@ public class ResolvedServiceCatalog {"ses", config.storage().mode(), 5000L, AwsNamespaces.SES, ServiceProtocol.REST_JSON,protocols(ServiceProtocol.REST_JSON, ServiceProtocol.QUERY),Set.of(), Set.of("email", "ses", "sesv2"), Set.of(),- Set.of(SesController.class, SesAccountController.class,- SesConfigurationSetController.class, SesContactController.class,- SesCvetController.class, SesDedicatedIpController.class,- SesIdentityController.class, SesSuppressionController.class,- SesTagController.class,- SesTemplateController.class, SesTenantController.class)),+ Set.of(SesAccountController.class, SesConfigurationSetController.class,+ SesContactController.class, SesCvetController.class,+ SesDedicatedIpController.class, SesIdentityController.class,+ SesSendController.class, SesSuppressionController.class,+ SesTagController.class, SesTemplateController.class,+ SesTenantController.class)),descriptor("es", "opensearch", config.services().opensearch().enabled(), true,"opensearch", storageMode(config.storage().services().opensearch().mode(), config.storage().mode()),config.storage().services().opensearch().flushIntervalMs(), null, ServiceProtocol.REST_JSON,diff --git a/src/main/java/io/github/hectorvent/floci/services/ses/SesAccountController.java b/src/main/java/io/github/hectorvent/floci/services/ses/SesAccountController.javaindex 2f98a05210..827bf50bdd 100644--- a/src/main/java/io/github/hectorvent/floci/services/ses/SesAccountController.java+++ b/src/main/java/io/github/hectorvent/floci/services/ses/SesAccountController.java@@ -33,8 +33,8 @@ import static io.github.hectorvent.floci.services.ses.SesV2Json.requireObjectOrAimport static io.github.hectorvent.floci.services.ses.SesV2Json.stringMemberOrAbsent;/**- * SES V2 account-level endpoints ({@code /v2/email/account}), split out of {@link SesController}.- * The settings live in {@link SesAccountService}; {@code GetAccount} also reads the account+ * SES V2 account-level endpoints ({@code /v2/email/account}). The settings live in+ * {@link SesAccountService}; {@code GetAccount} also reads the account* suppression attributes from {@link SesSuppressionService} and the sent-mail count from* {@link SesSentEmailService}, a read-only composition that needs no facade orchestration, so this* controller does not depend on {@link SesService}.diff --git a/src/main/java/io/github/hectorvent/floci/services/ses/SesConfigurationSetController.java b/src/main/java/io/github/hectorvent/floci/services/ses/SesConfigurationSetController.javaindex b1fad82285..2ba352efe0 100644--- a/src/main/java/io/github/hectorvent/floci/services/ses/SesConfigurationSetController.java+++ b/src/main/java/io/github/hectorvent/floci/services/ses/SesConfigurationSetController.java@@ -44,7 +44,7 @@ import static io.github.hectorvent.floci.services.ses.SesV2Json.requireJsonObjec/*** SES V2 configuration-set endpoints ({@code /v2/email/configuration-sets}), including the event- * destinations, split out of {@link SesController}. Most operations call+ * destinations. Most operations call* {@link SesConfigurationSetService} directly; create, the tracking and delivery option setters* and delete go through the {@link SesService} facade, which supplies the verified-domain and* dedicated-pool probes those validations need and guards the delete against tenant associations.diff --git a/src/main/java/io/github/hectorvent/floci/services/ses/SesContactController.java b/src/main/java/io/github/hectorvent/floci/services/ses/SesContactController.javaindex b9ccf0475d..acffcfe60b 100644--- a/src/main/java/io/github/hectorvent/floci/services/ses/SesContactController.java+++ b/src/main/java/io/github/hectorvent/floci/services/ses/SesContactController.java@@ -37,10 +37,10 @@ import static io.github.hectorvent.floci.services.ses.SesV2Json.requireJsonObjecimport static io.github.hectorvent.floci.services.ses.SesV2Json.unexpectedStartError;/**- * SES V2 contact-list and contact endpoints ({@code /v2/email/contact-lists}), split out of- * {@link SesController}. Every operation is a single-domain call on {@link SesContactService}, so- * this controller does not touch the {@link SesService} facade at all; the send-path opt-out- * collection that also reads contacts stays behind the facade.+ * SES V2 contact-list and contact endpoints ({@code /v2/email/contact-lists}). Every operation+ * is a single-domain call on {@link SesContactService}, so this controller does not touch the+ * {@link SesService} facade at all; the send-path opt-out collection that also reads contacts+ * stays behind the facade.*/@Path("/v2/email")@Produces(MediaType.APPLICATION_JSON)diff --git a/src/main/java/io/github/hectorvent/floci/services/ses/SesCvetController.java b/src/main/java/io/github/hectorvent/floci/services/ses/SesCvetController.javaindex 847b79a684..31a771569c 100644--- a/src/main/java/io/github/hectorvent/floci/services/ses/SesCvetController.java+++ b/src/main/java/io/github/hectorvent/floci/services/ses/SesCvetController.java@@ -31,7 +31,7 @@ import static io.github.hectorvent.floci.services.ses.SesV2Json.requireJsonObjec/*** SES V2 custom verification email template endpoints- * ({@code /v2/email/custom-verification-email-templates}), split out of {@link SesController}.+ * ({@code /v2/email/custom-verification-email-templates}).* Get, list and delete call {@link SesCvetService} directly; create and update go through the* {@link SesService} facade, which validates the template (including the From-address verified* check against the identity domain) before the store write. Sending one of these templates staysdiff --git a/src/main/java/io/github/hectorvent/floci/services/ses/SesDedicatedIpController.java b/src/main/java/io/github/hectorvent/floci/services/ses/SesDedicatedIpController.javaindex 9b81463f96..0bfdbb7223 100644--- a/src/main/java/io/github/hectorvent/floci/services/ses/SesDedicatedIpController.java+++ b/src/main/java/io/github/hectorvent/floci/services/ses/SesDedicatedIpController.java@@ -35,8 +35,8 @@ import static io.github.hectorvent.floci.services.ses.SesV2Json.requireJsonObjec/*** SES V2 dedicated IP pool and dedicated IP endpoints ({@code /v2/email/dedicated-ip-pools} and- * {@code /v2/email/dedicated-ips}), split out of {@link SesController}. Every operation is a- * single-domain call on {@link SesDedicatedIpService}, so this controller does not touch the+ * {@code /v2/email/dedicated-ips}). Every operation is a single-domain call on+ * {@link SesDedicatedIpService}, so this controller does not touch the* {@link SesService} facade; the account-level auto-warmup setting stays under {@code /account}.*/@Path("/v2/email")diff --git a/src/main/java/io/github/hectorvent/floci/services/ses/SesIdentityController.java b/src/main/java/io/github/hectorvent/floci/services/ses/SesIdentityController.javaindex ecd317a9fc..2baee52557 100644--- a/src/main/java/io/github/hectorvent/floci/services/ses/SesIdentityController.java+++ b/src/main/java/io/github/hectorvent/floci/services/ses/SesIdentityController.java@@ -34,8 +34,8 @@ import static io.github.hectorvent.floci.services.ses.SesV2Json.requireObjectOrA/*** SES V2 email-identity endpoints ({@code /v2/email/identities}), including the sending- * authorization policies, DKIM, MAIL FROM, feedback and default configuration set, split out of- * {@link SesController}. Reads and the single-domain attribute writes call+ * authorization policies, DKIM, MAIL FROM, feedback and default configuration set.+ * Reads and the single-domain attribute writes call* {@link SesIdentityService} directly; create, delete, the policy operations and the default* configuration set go through the {@link SesService} facade, which checks the configuration set* exists, guards the delete against tenant associations and cascades the identity's policies.diff --git a/src/main/java/io/github/hectorvent/floci/services/ses/SesController.java b/src/main/java/io/github/hectorvent/floci/services/ses/SesSendController.javasimilarity index 97%rename from src/main/java/io/github/hectorvent/floci/services/ses/SesController.javarename to src/main/java/io/github/hectorvent/floci/services/ses/SesSendController.javaindex 8d1bc257b3..0e454f3fe1 100644--- a/src/main/java/io/github/hectorvent/floci/services/ses/SesController.java+++ b/src/main/java/io/github/hectorvent/floci/services/ses/SesSendController.java@@ -39,21 +39,20 @@ import static io.github.hectorvent.floci.services.ses.SesV2Json.requireObjectOrAimport static io.github.hectorvent.floci.services.ses.SesV2Json.stringMemberOrAbsent;/**- * REST JSON controller for the AWS SES V2 API.- * Implements the AWS SES V2 wire protocol at /v2/email/* for the operations- * exposed by this controller.- * Reuses the shared {@link SesService} for business logic shared with other SES- * protocol handlers.- *- * Follows the same pattern as {@code LambdaController}: AwsExceptions are thrown- * directly and converted by the global {@code AwsExceptionMapper}.+ * REST JSON controller for the three SES V2 send endpoints:+ * {@code /v2/email/outbound-emails}, {@code /v2/email/outbound-bulk-emails} and+ * {@code /v2/email/outbound-custom-verification-emails}. Every other v2 URL group has its own+ * controller in this package; the send path stays here because it is the one group that reads+ * across several domains. It goes through the {@link SesService} facade for that reason, and+ * through {@link SesTemplateService} and {@link SesAccountService} for the stored template and+ * the account-level sending switch.*/@Path("/v2/email")@Produces(MediaType.APPLICATION_JSON)@Consumes(MediaType.APPLICATION_JSON)-public class SesController {+public class SesSendController {- private static final Logger LOG = Logger.getLogger(SesController.class);+ private static final Logger LOG = Logger.getLogger(SesSendController.class);private final SesService sesService;// The bulk send resolves a stored template's content before handing the entries to the facade.@@ -64,7 +63,7 @@ public class SesController {private final ObjectMapper objectMapper;@Inject- public SesController(SesService sesService, SesTemplateService templateService,+ public SesSendController(SesService sesService, SesTemplateService templateService,SesAccountService accountService, RegionResolver regionResolver,ObjectMapper objectMapper) {this.sesService = sesService;diff --git a/src/main/java/io/github/hectorvent/floci/services/ses/SesService.java b/src/main/java/io/github/hectorvent/floci/services/ses/SesService.javaindex eb1a417b48..e9e8d95a95 100644--- a/src/main/java/io/github/hectorvent/floci/services/ses/SesService.java+++ b/src/main/java/io/github/hectorvent/floci/services/ses/SesService.java@@ -48,6 +48,34 @@ import java.util.Map;import java.util.Set;import java.util.UUID;+/**+ * What is left of the original single SES service after the store-based domain split and the+ * per-domain controller split that followed it: the flows that no one domain service can own. A+ * method belongs here only if it touches two or more domains or the send path, which is the+ * survival rule the store split established. Everything else lives in the domain service that+ * owns its store, and this class owns no store of its own.+ *+ * <p>What that leaves, by category:+ * <ul>+ * <li>the send path, which assembles a message, applies the account, tenant and+ * configuration-set gates, filters suppressed recipients, relays and records it, then+ * publishes the send events;</li>+ * <li>delete guards, where a tenant association or a policy cascade has to run around another+ * domain's delete;</li>+ * <li>configuration-set option validation, which probes the identity and dedicated-IP domains+ * through injected callbacks;</li>+ * <li>the tenant to resource associations and the tenant delete cascade;</li>+ * <li>the ARN dispatch behind the tag operations, which routes one ARN to one of seven+ * domains;</li>+ * <li>the tenant-scoped suppression routing, which picks the tenant store or the account-wide+ * one from a {@code TenantName};</li>+ * <li>the inspection reads over recorded mail.</li>+ * </ul>+ *+ * <p>The name is historical. This is not the service for SES as a whole: SES is served by the+ * domain services in this package, with this class above them and+ * {@link SesSendController} and {@link SesQueryHandler} in front.+ */@ApplicationScopedpublic class SesService {diff --git a/src/main/java/io/github/hectorvent/floci/services/ses/SesSuppressionController.java b/src/main/java/io/github/hectorvent/floci/services/ses/SesSuppressionController.javaindex e6a313cc82..9c79c6b121 100644--- a/src/main/java/io/github/hectorvent/floci/services/ses/SesSuppressionController.java+++ b/src/main/java/io/github/hectorvent/floci/services/ses/SesSuppressionController.java@@ -31,8 +31,8 @@ import static io.github.hectorvent.floci.services.ses.SesV2Json.requireJsonObjecimport static io.github.hectorvent.floci.services.ses.SesV2Json.stringMemberOrAbsent;/**- * SES V2 suppression-list endpoints ({@code /v2/email/suppression/addresses}), split out of- * {@link SesController}. Every operation keeps going through the {@link SesService} facade,+ * SES V2 suppression-list endpoints ({@code /v2/email/suppression/addresses}). Every operation+ * keeps going through the {@link SesService} facade,* because an optional {@code TenantName} routes it to that tenant's own list, which spans the* suppression and tenant domains; the account-level suppression attributes live under* {@code /account}.diff --git a/src/main/java/io/github/hectorvent/floci/services/ses/SesTagController.java b/src/main/java/io/github/hectorvent/floci/services/ses/SesTagController.javaindex 4aa1ccc033..6661338fdb 100644--- a/src/main/java/io/github/hectorvent/floci/services/ses/SesTagController.java+++ b/src/main/java/io/github/hectorvent/floci/services/ses/SesTagController.java@@ -28,7 +28,7 @@ import static io.github.hectorvent.floci.services.ses.SesV2Json.parseTagsArray;import static io.github.hectorvent.floci.services.ses.SesV2Json.remapV1Exception;/**- * SES V2 resource-tag endpoints ({@code /v2/email/tags}), split out of {@link SesController}.+ * SES V2 resource-tag endpoints ({@code /v2/email/tags}).* Every operation keeps going through the {@link SesService} facade, which parses the resource* ARN and dispatches to whichever of the seven taggable domains owns it; that cross-domain* dispatch is the facade's job by the survival rule, so this class is a pure size split likediff --git a/src/main/java/io/github/hectorvent/floci/services/ses/SesTemplateController.java b/src/main/java/io/github/hectorvent/floci/services/ses/SesTemplateController.javaindex 0aae97c062..436bcde4cf 100644--- a/src/main/java/io/github/hectorvent/floci/services/ses/SesTemplateController.java+++ b/src/main/java/io/github/hectorvent/floci/services/ses/SesTemplateController.java@@ -31,8 +31,8 @@ import static io.github.hectorvent.floci.services.ses.SesV2Json.remapV1Exceptionimport static io.github.hectorvent.floci.services.ses.SesV2Json.requireJsonObject;/**- * SES V2 email-template endpoints ({@code /v2/email/templates}), split out of- * {@link SesController}. Talks to {@link SesTemplateService} directly; only+ * SES V2 email-template endpoints ({@code /v2/email/templates}). Talks to+ * {@link SesTemplateService} directly; only* {@code DeleteEmailTemplate} goes through the {@link SesService} facade, which wraps the delete in* the tenant-association guard.*/diff --git a/src/main/java/io/github/hectorvent/floci/services/ses/SesTenantController.java b/src/main/java/io/github/hectorvent/floci/services/ses/SesTenantController.javaindex 6cbd13363b..ab11c59eea 100644--- a/src/main/java/io/github/hectorvent/floci/services/ses/SesTenantController.java+++ b/src/main/java/io/github/hectorvent/floci/services/ses/SesTenantController.java@@ -32,8 +32,8 @@ import static io.github.hectorvent.floci.services.ses.SesV2Json.stringMemberOrAb/*** SES V2 tenant endpoints ({@code /v2/email/tenants}, {@code /v2/email/tenant} and- * {@code /v2/email/resources/tenants}), split out of {@link SesController}. Tenant create, get,- * list and suppression attributes call {@link SesTenantService} directly; the resource+ * {@code /v2/email/resources/tenants}). Tenant create, get, list and suppression attributes+ * call {@link SesTenantService} directly; the resource* associations and tenant delete go through the {@link SesService} facade, which checks the* associated identity, configuration set or template exists and cascades the tenant's* suppression entries, work that spans several domains.diff --git a/src/test/java/io/github/hectorvent/floci/services/ses/SesV2ControllerRegistrationTest.java b/src/test/java/io/github/hectorvent/floci/services/ses/SesV2ControllerRegistrationTest.javaindex 2350934e5b..982774e365 100644--- a/src/test/java/io/github/hectorvent/floci/services/ses/SesV2ControllerRegistrationTest.java+++ b/src/test/java/io/github/hectorvent/floci/services/ses/SesV2ControllerRegistrationTest.java@@ -39,8 +39,8 @@ class SesV2ControllerRegistrationTest {@Testvoid everyV2EmailResourceClassIsRegisteredOnTheSesDescriptor() throws Exception {List<Class<?>> v2Controllers = v2EmailResourceClasses();- assertTrue(v2Controllers.contains(SesController.class),- "scan must at least find SesController; found " + v2Controllers);+ assertTrue(v2Controllers.contains(SesSendController.class),+ "scan must at least find SesSendController; found " + v2Controllers);List<String> unregistered = new ArrayList<>();for (Class<?> controller : v2Controllers) {@@ -66,10 +66,10 @@ class SesV2ControllerRegistrationTest {}private List<Class<?>> v2EmailResourceClasses() throws Exception {- URI codeSource = SesController.class.getProtectionDomain().getCodeSource()+ URI codeSource = SesSendController.class.getProtectionDomain().getCodeSource().getLocation().toURI();Path classesDir = Path.of(codeSource);- String packagePrefix = SesController.class.getPackageName() + ".";+ String packagePrefix = SesSendController.class.getPackageName() + ".";List<Class<?>> found = new ArrayList<>();try (Stream<Path> paths = Files.walk(classesDir)) {List<Path> classFiles = paths.filter(p -> p.toString().endsWith(".class")).toList();