Search in sources :

Example 6 with ExchangeModelMarshallException

use of eu.europa.ec.fisheries.uvms.exchange.model.exception.ExchangeModelMarshallException 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)

Example 7 with ExchangeModelMarshallException

use of eu.europa.ec.fisheries.uvms.exchange.model.exception.ExchangeModelMarshallException in project UVMS-ExchangeModule-APP by UnionVMS.

the class ExchangeEventOutgoingServiceBean method sendFLUXFAQueryToPlugin.

@Override
public void sendFLUXFAQueryToPlugin(@Observes @SendFaQueryToPluginEvent ExchangeMessageEvent message) {
    try {
        SetFAQueryMessageRequest request = JAXBMarshaller.unmarshallTextMessage(message.getJmsMessage(), SetFAQueryMessageRequest.class);
        LOG.debug("Got SetFAQueryMessageRequest in exchange : " + request.getRequest());
        String text = ExchangePluginRequestMapper.createSendFLUXFAQueryRequest(request.getRequest(), request.getDestination(), request.getFluxDataFlow(), request.getSenderOrReceiver());
        LOG.debug("Message to plugin {}", text);
        String pluginMessageId = producer.sendEventBusMessage(text, ((request.getPluginType() == BELGIAN_ACTIVITY) ? ExchangeServiceConstants.BELGIAN_ACTIVITY_PLUGIN_SERVICE_NAME : ExchangeServiceConstants.FLUX_ACTIVITY_PLUGIN_SERVICE_NAME));
        LOG.info("Message sent to Flux ERS Plugin :" + pluginMessageId);
        exchangeLog.log(request, LogType.SEND_FA_QUERY_MSG, ExchangeLogStatusTypeType.SENT, TypeRefType.FA_QUERY, request.getRequest(), false);
    } catch (ExchangeModelMarshallException | ExchangeMessageException | ExchangeLogException e) {
        LOG.error("Unable to send FLUX FA Report to plugin.", e);
    }
}
Also used : ExchangeModelMarshallException(eu.europa.ec.fisheries.uvms.exchange.model.exception.ExchangeModelMarshallException) SetFAQueryMessageRequest(eu.europa.ec.fisheries.schema.exchange.module.v1.SetFAQueryMessageRequest) ExchangeLogException(eu.europa.ec.fisheries.uvms.exchange.service.exception.ExchangeLogException) ExchangeMessageException(eu.europa.ec.fisheries.uvms.exchange.message.exception.ExchangeMessageException)

Example 8 with ExchangeModelMarshallException

use of eu.europa.ec.fisheries.uvms.exchange.model.exception.ExchangeModelMarshallException in project UVMS-ExchangeModule-APP by UnionVMS.

the class ExchangeEventOutgoingServiceBean method sendFLUXFAReportToPlugin.

@Override
public void sendFLUXFAReportToPlugin(@Observes @SendFaReportToPluginEvent ExchangeMessageEvent message) {
    try {
        SetFLUXFAReportMessageRequest request = JAXBMarshaller.unmarshallTextMessage(message.getJmsMessage(), SetFLUXFAReportMessageRequest.class);
        LOG.debug("Got SetFAQueryMessageRequest in exchange : " + request.getRequest());
        String text = ExchangePluginRequestMapper.createSendFLUXFAReportRequest(request.getRequest(), request.getDestination(), request.getFluxDataFlow(), request.getSenderOrReceiver());
        LOG.debug("Message to plugin {}", text);
        String pluginMessageId = producer.sendEventBusMessage(text, ((request.getPluginType() == BELGIAN_ACTIVITY) ? ExchangeServiceConstants.BELGIAN_ACTIVITY_PLUGIN_SERVICE_NAME : ExchangeServiceConstants.FLUX_ACTIVITY_PLUGIN_SERVICE_NAME));
        LOG.info("Message sent to Flux ERS Plugin :" + pluginMessageId);
        exchangeLog.log(request, LogType.SEND_FLUX_FA_REPORT_MSG, ExchangeLogStatusTypeType.SENT, TypeRefType.FA_REPORT, request.getRequest(), false);
    } catch (ExchangeModelMarshallException | ExchangeMessageException | ExchangeLogException e) {
        LOG.error("Unable to send FLUX FA Report to plugin.", e);
    }
}
Also used : ExchangeModelMarshallException(eu.europa.ec.fisheries.uvms.exchange.model.exception.ExchangeModelMarshallException) ExchangeLogException(eu.europa.ec.fisheries.uvms.exchange.service.exception.ExchangeLogException) ExchangeMessageException(eu.europa.ec.fisheries.uvms.exchange.message.exception.ExchangeMessageException) SetFLUXFAReportMessageRequest(eu.europa.ec.fisheries.schema.exchange.module.v1.SetFLUXFAReportMessageRequest)

Example 9 with ExchangeModelMarshallException

use of eu.europa.ec.fisheries.uvms.exchange.model.exception.ExchangeModelMarshallException in project UVMS-ExchangeModule-APP by UnionVMS.

the class ExchangeEventOutgoingServiceBean method sendFLUXFAResponseToPlugin.

@Override
public void sendFLUXFAResponseToPlugin(@Observes @SendFLUXFAResponseToPluginEvent ExchangeMessageEvent message) {
    try {
        SetFLUXFAResponseMessageRequest request = JAXBMarshaller.unmarshallTextMessage(message.getJmsMessage(), SetFLUXFAResponseMessageRequest.class);
        LOG.debug("[INFO] Got FLUXFAResponse in exchange :" + request.getRequest());
        String text = ExchangePluginRequestMapper.createSetFLUXFAResponseRequestWithOn(request.getRequest(), request.getDestination(), request.getFluxDataFlow(), request.getSenderOrReceiver(), request.getOnValue());
        final ExchangeLogType log = exchangeLog.log(request, LogType.SEND_FLUX_RESPONSE_MSG, request.getStatus(), TypeRefType.FA_RESPONSE, request.getRequest(), false);
        if (!log.getStatus().equals(ExchangeLogStatusTypeType.FAILED)) {
            // Send response only if it is NOT FAILED
            LOG.debug("[INFO] Sending FLUXFAResponse to Flux Activity Plugin {}", text);
            String pluginMessageId = producer.sendEventBusMessage(text, ((request.getPluginType() == BELGIAN_ACTIVITY) ? ExchangeServiceConstants.BELGIAN_ACTIVITY_PLUGIN_SERVICE_NAME : ExchangeServiceConstants.FLUX_ACTIVITY_PLUGIN_SERVICE_NAME));
            LOG.debug("[INFO] FLUXFAResponse sent to Flux Activity Plugin {}" + pluginMessageId);
        } else {
            LOG.info("[WARN] FLUXFAResponse is FAILED so won't be sent to Flux Activity Plugin {}", text);
        }
    } catch (ExchangeModelMarshallException | ExchangeMessageException | ExchangeLogException e) {
        LOG.error("Unable to send FLUX FA Report to plugin.", e);
    }
}
Also used : ExchangeModelMarshallException(eu.europa.ec.fisheries.uvms.exchange.model.exception.ExchangeModelMarshallException) SetFLUXFAResponseMessageRequest(eu.europa.ec.fisheries.schema.exchange.module.v1.SetFLUXFAResponseMessageRequest) ExchangeLogType(eu.europa.ec.fisheries.schema.exchange.v1.ExchangeLogType) ExchangeLogException(eu.europa.ec.fisheries.uvms.exchange.service.exception.ExchangeLogException) ExchangeMessageException(eu.europa.ec.fisheries.uvms.exchange.message.exception.ExchangeMessageException)

Example 10 with ExchangeModelMarshallException

use of eu.europa.ec.fisheries.uvms.exchange.model.exception.ExchangeModelMarshallException in project UVMS-ExchangeModule-APP by UnionVMS.

the class PluginServiceBean method registerService.

@Override
public void registerService(@Observes @RegisterServiceEvent PluginMessageEvent event) {
    LOG.info("register service:{}", event);
    TextMessage textMessage = event.getJmsMessage();
    RegisterServiceRequest register = null;
    try {
        register = JAXBMarshaller.unmarshallTextMessage(textMessage, RegisterServiceRequest.class);
        String messageId = textMessage.getJMSMessageID();
        boolean sendMessage = true;
        if (register.getService() != null) {
            sendMessage = checkPluginType(register.getService().getPluginType(), register.getService().getServiceResponseMessageName(), messageId);
            if (sendMessage) {
                registerService(register, messageId);
            }
        }
    } catch (ExchangeModelMarshallException | ExchangeMessageException | JMSException e) {
        LOG.error("Register service exception {} {}", event, e.getMessage());
        errorEvent.fire(new PluginMessageEvent(textMessage, register.getService(), ExchangePluginResponseMapper.mapToPluginFaultResponse(FaultCode.EXCHANGE_PLUGIN_EVENT.getCode(), "Exception when register service")));
    }
}
Also used : ExchangeModelMarshallException(eu.europa.ec.fisheries.uvms.exchange.model.exception.ExchangeModelMarshallException) RegisterServiceRequest(eu.europa.ec.fisheries.schema.exchange.registry.v1.RegisterServiceRequest) ExchangeMessageException(eu.europa.ec.fisheries.uvms.exchange.message.exception.ExchangeMessageException) JMSException(javax.jms.JMSException) PluginMessageEvent(eu.europa.ec.fisheries.uvms.exchange.message.event.carrier.PluginMessageEvent) TextMessage(javax.jms.TextMessage)

Aggregations

ExchangeModelMarshallException (eu.europa.ec.fisheries.uvms.exchange.model.exception.ExchangeModelMarshallException)27 ExchangeLogException (eu.europa.ec.fisheries.uvms.exchange.service.exception.ExchangeLogException)15 ExchangeMessageException (eu.europa.ec.fisheries.uvms.exchange.message.exception.ExchangeMessageException)13 ExchangeLogType (eu.europa.ec.fisheries.schema.exchange.v1.ExchangeLogType)8 ExchangeServiceException (eu.europa.ec.fisheries.uvms.exchange.service.exception.ExchangeServiceException)8 TextMessage (javax.jms.TextMessage)7 RulesModelMapperException (eu.europa.ec.fisheries.uvms.rules.model.exception.RulesModelMapperException)4 RulesModelMarshallException (eu.europa.ec.fisheries.uvms.rules.model.exception.RulesModelMarshallException)4 JMSException (javax.jms.JMSException)4 PluginType (eu.europa.ec.fisheries.schema.exchange.plugin.types.v1.PluginType)3 ExchangeLogStatusTypeType (eu.europa.ec.fisheries.schema.exchange.v1.ExchangeLogStatusTypeType)3 PluginMessageEvent (eu.europa.ec.fisheries.uvms.exchange.message.event.carrier.PluginMessageEvent)3 InputArgumentException (eu.europa.ec.fisheries.uvms.exchange.service.exception.InputArgumentException)3 SetFAQueryMessageRequest (eu.europa.ec.fisheries.schema.exchange.module.v1.SetFAQueryMessageRequest)2 SetFLUXFAReportMessageRequest (eu.europa.ec.fisheries.schema.exchange.module.v1.SetFLUXFAReportMessageRequest)2 SetReportMovementType (eu.europa.ec.fisheries.schema.exchange.movement.v1.SetReportMovementType)2 AcknowledgeResponse (eu.europa.ec.fisheries.schema.exchange.plugin.v1.AcknowledgeResponse)2 RegisterServiceRequest (eu.europa.ec.fisheries.schema.exchange.registry.v1.RegisterServiceRequest)2 UnregisterServiceRequest (eu.europa.ec.fisheries.schema.exchange.registry.v1.UnregisterServiceRequest)2 ServiceResponseType (eu.europa.ec.fisheries.schema.exchange.service.v1.ServiceResponseType)2