Search in sources :

Example 1 with MailClient

use of no.difi.meldingsutveksling.mail.MailClient in project efm-integrasjonspunkt by felleslosninger.

the class IntegrajonspunktReceiveImpl method forwardToNoarkSystemAndSendReceipts.

private void forwardToNoarkSystemAndSendReceipts(StandardBusinessDocument sbd, PutMessageRequestType putMessage) {
    PutMessageResponseType response = localNoark.sendEduMelding(putMessage);
    if (response == null || response.getResult() == null) {
        Audit.info(String.format("Empty response from archive for message [id=%s]", sbd.getMessageId()), markerFrom(sbd));
    } else {
        AppReceiptType result = response.getResult();
        if (result.getType().equals(OK_TYPE)) {
            Audit.info(String.format("Message [id=%s] delivered archive", sbd.getMessageId()), markerFrom(response));
            conversationService.registerStatus(sbd.getDocumentId(), ReceiptStatus.INNKOMMENDE_LEVERT);
            sendLevertStatus(sbd);
            if (localNoark instanceof MailClient && !sbdUtil.isReceipt(sbd)) {
                // Need to send AppReceipt manually in case receiver is mail
                putMessage.setPayload(BestEduConverter.appReceiptAsString(result));
                PutMessageRequestWrapper putMessageWrapper = new PutMessageRequestWrapper(putMessage);
                putMessageWrapper.swapSenderAndReceiver();
                nextMoveAdapter.convertAndSend(putMessageWrapper);
            }
            try {
                messagePersister.delete(sbd.getDocumentId());
            } catch (IOException e) {
                log.error(String.format("Unable to delete files for message with id=%s", sbd.getMessageId()), e);
            }
        } else {
            Audit.error(String.format("Unexpected response from archive for message [id=%s]", sbd.getMessageId()), markerFrom(response));
            if (!response.getResult().getMessage().isEmpty()) {
                log.error(">>> archivesystem: " + response.getResult().getMessage().get(0).getText());
            }
        }
    }
}
Also used : PutMessageResponseType(no.difi.meldingsutveksling.noarkexchange.schema.PutMessageResponseType) AppReceiptType(no.difi.meldingsutveksling.noarkexchange.schema.AppReceiptType) MailClient(no.difi.meldingsutveksling.mail.MailClient) IOException(java.io.IOException)

Aggregations

IOException (java.io.IOException)1 MailClient (no.difi.meldingsutveksling.mail.MailClient)1 AppReceiptType (no.difi.meldingsutveksling.noarkexchange.schema.AppReceiptType)1 PutMessageResponseType (no.difi.meldingsutveksling.noarkexchange.schema.PutMessageResponseType)1