Search in sources :

Example 1 with SendSalesResponseRequest

use of eu.europa.ec.fisheries.schema.exchange.module.v1.SendSalesResponseRequest in project UVMS-ExchangeModule-APP by UnionVMS.

the class ExchangeEventIncomingServiceBean method sendSalesResponse.

@Override
public void sendSalesResponse(@Observes @SendSalesResponseEvent ExchangeMessageEvent message) {
    try {
        SendSalesResponseRequest request = JAXBMarshaller.unmarshallTextMessage(message.getJmsMessage(), SendSalesResponseRequest.class);
        ExchangeLogStatusTypeType validationStatus = request.getValidationStatus();
        exchangeLog.log(request, LogType.SEND_SALES_RESPONSE, validationStatus, TypeRefType.SALES_RESPONSE, request.getResponse(), false);
        if (validationStatus == ExchangeLogStatusTypeType.SUCCESSFUL || validationStatus == ExchangeLogStatusTypeType.SUCCESSFUL_WITH_WARNINGS) {
            eu.europa.ec.fisheries.schema.exchange.plugin.v1.SendSalesResponseRequest pluginRequest = new eu.europa.ec.fisheries.schema.exchange.plugin.v1.SendSalesResponseRequest();
            pluginRequest.setRecipient(request.getSenderOrReceiver());
            pluginRequest.setResponse(request.getResponse());
            pluginRequest.setMethod(ExchangePluginMethod.SEND_SALES_RESPONSE);
            exchangeEventOutgoingService.sendSalesResponseToPlugin(pluginRequest, request.getPluginType());
        } else {
            log.error("Received invalid response from the Sales module: " + request.getResponse());
        }
    } catch (ExchangeModelMarshallException | ExchangeMessageException e) {
        fireExchangeFault(message, "Error when sending a Sales response to FLUX", e);
    } catch (ExchangeLogException e) {
        fireExchangeFault(message, "Could not log the outgoing sales response.", e);
    }
}
Also used : ExchangeLogStatusTypeType(eu.europa.ec.fisheries.schema.exchange.v1.ExchangeLogStatusTypeType) ExchangeMessageException(eu.europa.ec.fisheries.uvms.exchange.message.exception.ExchangeMessageException) ExchangeModelMarshallException(eu.europa.ec.fisheries.uvms.exchange.model.exception.ExchangeModelMarshallException) SendSalesResponseRequest(eu.europa.ec.fisheries.schema.exchange.module.v1.SendSalesResponseRequest) ExchangeLogException(eu.europa.ec.fisheries.uvms.exchange.service.exception.ExchangeLogException)

Aggregations

SendSalesResponseRequest (eu.europa.ec.fisheries.schema.exchange.module.v1.SendSalesResponseRequest)1 ExchangeLogStatusTypeType (eu.europa.ec.fisheries.schema.exchange.v1.ExchangeLogStatusTypeType)1 ExchangeMessageException (eu.europa.ec.fisheries.uvms.exchange.message.exception.ExchangeMessageException)1 ExchangeModelMarshallException (eu.europa.ec.fisheries.uvms.exchange.model.exception.ExchangeModelMarshallException)1 ExchangeLogException (eu.europa.ec.fisheries.uvms.exchange.service.exception.ExchangeLogException)1