package at.gv.egiz.moazs; import at.gv.zustellung.app2mzs.xsd.ConfigType; import at.gv.zustellung.app2mzs.xsd.DeliveryRequestType; import at.gv.zustellung.app2mzs.xsd.DeliveryRequestType.DeliveryRequestTypeBuilder; import at.gv.zustellung.app2mzs.xsd.persondata.CorporateBodyType; import at.gv.zustellung.msg.xsd.SenderProfile; import org.springframework.stereotype.Component; import org.springframework.util.Assert; import static at.gv.egiz.moazs.util.NullCoalesce.coalesce; import static at.gv.zustellung.app2mzs.xsd.ConfigType.configTypeBuilder; import static org.springframework.util.Assert.isTrue; import static org.springframework.util.Assert.notNull; @Component public class DeliveryPreprocessor { /** * Validates and augments an incoming {@code request} * * Validates a {@code request} to ensure the availability of all mandatory fields. Where possible, the method * augments the request with values taken from the app's configuration. * @param request * @return validated and augmented request */ public DeliveryRequestType preProcess(DeliveryRequestType request) { //validate(request); return new DeliveryRequestTypeBuilder(request) .withConfig(coalesce(request.getConfig(), initDefaultConfig()).get()) .build(); } private ConfigType initDefaultConfig() { return configTypeBuilder() .withPerformQueryPersonRequest(false) .build(); } }