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);
}
}
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);
}
}
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);
}
}
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);
}
}
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")));
}
}
Aggregations