use of no.difi.meldingsutveksling.nextmove.ConversationDirection in project efm-integrasjonspunkt by felleslosninger.
the class SvarInnPutMessageForwarder method forward.
private void forward(Forsendelse forsendelse, Reject reject) {
MDC.put(NextMoveConsts.CORRELATION_ID, forsendelse.getId());
SvarInnPutMessageBuilder builder = new SvarInnPutMessageBuilder(forsendelse, clock, putMessageRequestFactory);
svarInnService.getAttachments(forsendelse, reject).forEach(builder::streamedFile);
if (!Strings.isNullOrEmpty(properties.getFiks().getInn().getFallbackSenderOrgNr())) {
builder.setFallbackSenderOrgNr(properties.getFiks().getInn().getFallbackSenderOrgNr());
}
PutMessageRequestType putMessage = builder.build();
if (builder.getDokumentTypeList().isEmpty()) {
Audit.error("Zipfile is empty: skipping message", Markers.append("fiks-id", forsendelse.getId()));
return;
}
Conversation c = conversationService.registerConversation(new MessageInformable() {
@Override
public String getConversationId() {
return forsendelse.getId();
}
@Override
public String getMessageId() {
return forsendelse.getId();
}
@Override
public Organisasjonsnummer getSender() {
return Organisasjonsnummer.from(putMessage.getEnvelope().getSender().getOrgnr());
}
@Override
public Organisasjonsnummer getReceiver() {
return Organisasjonsnummer.from(putMessage.getEnvelope().getReceiver().getOrgnr());
}
@Override
public String getProcessIdentifier() {
return properties.getArkivmelding().getDefaultProcess();
}
@Override
public String getDocumentIdentifier() {
return properties.getArkivmelding().getDefaultDocumentType();
}
@Override
public ConversationDirection getDirection() {
return ConversationDirection.INCOMING;
}
@Override
public ServiceIdentifier getServiceIdentifier() {
return ServiceIdentifier.DPF;
}
@Override
public OffsetDateTime getExpiry() {
return OffsetDateTime.now(clock).plusHours(properties.getNextmove().getDefaultTtlHours());
}
});
conversationService.registerStatus(c.getMessageId(), INNKOMMENDE_MOTTATT);
String missingFields = getMissingFields(forsendelse, putMessage, builder.getDokumentTypeList());
if (!missingFields.isEmpty()) {
handleError(putMessage, forsendelse.getId(), "Validation failed - missing fields: " + missingFields);
return;
}
final PutMessageResponseType response = localNoark.sendEduMelding(putMessage);
if ("OK".equals(response.getResult().getType())) {
Audit.info("Message successfully forwarded");
conversationService.registerStatus(c.getMessageId(), INNKOMMENDE_LEVERT);
svarInnService.confirmMessage(forsendelse.getId());
} else if ("WARNING".equals(response.getResult().getType())) {
Audit.info(format("Archive system responded with warning for message with fiks-id %s", forsendelse.getId()), PutMessageResponseMarkers.markerFrom(response));
conversationService.registerStatus(c.getMessageId(), INNKOMMENDE_LEVERT);
svarInnService.confirmMessage(forsendelse.getId());
} else {
Audit.error(format("Message with fiks-id %s failed", forsendelse.getId()), PutMessageResponseMarkers.markerFrom(response));
handleError(putMessage, forsendelse.getId(), "Archive system responded with error: " + response.getResult().getMessage().get(0).getText());
}
}
Aggregations