Skip to content

MODEXPW-625 - Enable Email Delivery for EDIFACT Export Jobs#732

Open
markusweigelt wants to merge 40 commits intomasterfrom
MODEXPW-625
Open

MODEXPW-625 - Enable Email Delivery for EDIFACT Export Jobs#732
markusweigelt wants to merge 40 commits intomasterfrom
MODEXPW-625

Conversation

@markusweigelt
Copy link
Copy Markdown

MODEXPW-625
- Send the export by email

Purpose

Introduce Email as a transmission method for EDIFACT export jobs.
When an integration is configured with transmissionMethod: Email, the generated EDIFACT file (e.g., Ordering or Claiming) is automatically sent to the vendor via email.

This allows EDIFACT exports to be delivered directly through email, enabling fully automated email-based ordering and claiming workflows.

Approach

  • New SendToEmailTasklet - reads the generated EDIFACT file from the job execution context, renders subject and body via mod-template-engine (POST /template-request), then delivers the file
    as an attachment via mod-email (POST /email)
  • New SendToEmailTaskletDecider - skips the email step unless transmissionMethod is Email; wired into EdifactExportJobConfig
  • New HTTP clients - EmailClient and TemplateEngineClient
  • Schema extension - folio-export-common submodule updated in PR MODEXPW-625 - Schema changes for sending exports via email folio-export-common#106
  • Email config validation - MapToEdifactTasklet validates presence of required email fields when transmissionMethod is Email and fails the job early with a clear error if misconfigured
  • folio.okapi-url override - JobCommandsReceiverService overrides the Kafka-propagated x-okapi-url header with the worker's own sidecar URL so all HTTP clients route correctly

mod-template-engine returns 400 when outputFormat does not match
the format registered in the template. The claims template requires
text/html.
Read outputFormat from template-engine response meta and forward it
to EmailEntity so the email is sent in the same format the template
was rendered in (e.g. text/html).
Wrap templateEngineClient and emailClient calls in EdifactException,
derive attachment content type from fileFormat, extract buildAttachment
and sendEmail helper methods, and add unit/integration tests for the
tasklet and its decider.
Remove template context from TemplateProcessingRequest for now since
required template variables are not yet known; mod-template-engine
treats a missing context as an empty object. Add ORDERING + EMAIL
test coverage.
Migrate EmailClient and TemplateEngineClient from @FeignClient to Spring 6
@HttpExchange. Update Spring Batch import paths to new package structure.
Fix SendToEmailTaskletTest to use JobOperatorTestUtils and correct mock types.
…iguration

Both clients use @HttpExchange and require explicit @bean registration via
HttpServiceProxyFactory — they were missing, causing a NoSuchBeanDefinitionException
when sendToEmailStep attempted to inject EmailClient.
Spring HttpServiceProxyFactory requires @RequestBody on POST parameters
to resolve them as the request body — unlike Feign which inferred this
from unannotated arguments.
…lization

RestClient uses Jackson 3 (tools.jackson) which cannot deserialize into
the abstract com.fasterxml.jackson.databind.JsonNode (Jackson 2). Return
String instead and parse with ediObjectMapper in the tasklet.
…sponse DTO

Jackson 3 (RestClient) cannot deserialize JSON into String or the abstract
JsonNode (Jackson 2). A concrete DTO is the correct and consistent approach,
matching how all other clients in this module handle responses.
Removed the erroneous CLAIMING integration type check; email delivery
is driven exclusively by transmissionMethod == EMAIL regardless of
integration type. Also added a comment in EdifactExportJobConfig
summarising the decider conditions for all three optional steps.
The previous tests checked integrationType alone and had an incorrect
PROCESS assertion for FILE_DOWNLOAD. Tests now verify that PROCESS is
returned only when transmissionMethod is EMAIL, and SKIP for all other
transmission methods.
Introduces validateEmailFields analogous to validateFtpFields,
checking emailFrom, emailTo, and emailTemplate when transmissionMethod
is Email. Fixes NPE caused by unconditional FTP field validation for
Email transmission jobs.
markusweigelt and others added 6 commits April 8, 2026 11:19
… shared steps

Move shared step and decider dependencies from method parameters to @lazy
constructor-injected fields, reducing constructEdifactExportJob from 8 to 3
parameters. Also update folio-export-common submodule and remove unused
fileName parameter from SendToEmailTasklet.resolveTemplate.
…nMethod is not FTP

The decider previously always executed the FTP step for ORDERING integration
type regardless of transmissionMethod, causing an NPE when ediFtp config is
absent (e.g. Email-only exports).
…bean ambiguity

Spring 6.1+ no longer retains parameter names by default, so @lazy Step
injection matched all 14 Step beans instead of the intended one.
Constructor injection with @Lazy/@qualifier fails for same-class @bean
definitions due to circular dependencies and Spring 6.1 parameter name
retention changes. Revert to the original pattern of passing shared steps
as @bean method parameters.
# Conflicts:
#	folio-export-common
@sonarqubecloud
Copy link
Copy Markdown

sonarqubecloud Bot commented Apr 9, 2026

@markusweigelt
Copy link
Copy Markdown
Author

@folio-org/firebird-backend Does this PR need a review? Right now, the CI pipeline looks good, and it could be merged without an additional approval. What do you mean?

fyi We're still new to FOLIO, so any pointers on the usual process would be appreciated.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant