return Optional.ofNullable(outMessage.getAdditionalProperties())
.map(OutMessageAdditionalProperties::getStatusCallbackInfo)
.filter(statusCallbackInfo -> CallbackFormat.DEVINO.name().equalsIgnoreCase(statusCallbackInfo.getFormat()))
.map(statusCallbackInfo -> {
if (StringUtils.isNotBlank(statusCallbackInfo.getUrl())) {
return Mono.just(context.withCallback(
Callback.builder()
.url(statusCallbackInfo.getUrl())
.format(CallbackFormat.DEVINO)
.type(CallbackType.STATUS)
.build()));
} else {
log.warn("'callbackFormat' has value DEVINO but 'callbackUrl' is null [outMessageId:{};tenantId:{};subjectId:{}]",
outMessage.getId(), outMessage.getTenantId(), outMessage.getSubjectId());
return Mono.<CallbackContext>empty();
}
})
.orElseGet(() -> {
log.info("Not found 'format' and 'url' of outMessage's callback [outMessageId:{};tenantId:{};subjectId:{}]",
outMessage.getId(), outMessage.getTenantId(), outMessage.getSubjectId());
return Mono.<CallbackContext>empty();
});