Search in sources :

Example 6 with ExchangeLogException

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

the class ExchangeEventIncomingServiceBean method receiveInvalidSalesMessage.

@Override
public void receiveInvalidSalesMessage(@Observes @ReceiveInvalidSalesMessageEvent ExchangeMessageEvent event) {
    try {
        ReceiveInvalidSalesMessage request = JAXBMarshaller.unmarshallTextMessage(event.getJmsMessage(), ReceiveInvalidSalesMessage.class);
        exchangeLog.log(request, LogType.RECEIVE_SALES_REPORT, ExchangeLogStatusTypeType.FAILED, TypeRefType.SALES_REPORT, request.getRespondToInvalidMessageRequest(), true);
        producer.sendMessageOnQueue(request.getRespondToInvalidMessageRequest(), MessageQueue.SALES);
    } catch (ExchangeLogException e) {
        firePluginFault(event, "Could not log the incoming invalid sales message", e);
    } catch (ExchangeMessageException | ExchangeModelMarshallException e) {
        firePluginFault(event, "Error when receiving an invalid sales message from FLUX", e);
    }
}
Also used : ReceiveInvalidSalesMessage(eu.europa.ec.fisheries.schema.exchange.module.v1.ReceiveInvalidSalesMessage) 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)

Example 7 with ExchangeLogException

use of eu.europa.ec.fisheries.uvms.exchange.service.exception.ExchangeLogException 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 8 with ExchangeLogException

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

the class ExchangeEventOutgoingServiceBean method validate.

private boolean validate(ServiceResponseType service, SendMovementToPluginType sendReport, TextMessage origin, String username) {
    // Use first and only
    String serviceName = service.getServiceClassName();
    if (serviceName == null || serviceName.isEmpty()) {
        String faultMessage = "First plugin of type " + sendReport.getPluginType() + " is invalid. Missing serviceClassName";
        exchangeErrorEvent.fire(new ExchangeMessageEvent(origin, ExchangeModuleResponseMapper.createFaultMessage(FaultCode.EXCHANGE_PLUGIN_INVALID, faultMessage)));
        try {
            List<UnsentMessageTypeProperty> unsentMessageProperties = ExchangeLogMapper.getUnsentMessageProperties(sendReport);
            exchangeLog.createUnsentMessage(sendReport.getRecipient(), sendReport.getTimestamp(), ExchangeLogMapper.getSendMovementSenderReceiver(sendReport), origin.getText(), unsentMessageProperties, username);
        } catch (ExchangeLogException | JMSException e) {
            LOG.error("Couldn't create unsent message " + e.getMessage());
        }
        return false;
    } else if (!sendReport.getPluginType().equals(service.getPluginType())) {
        String faultMessage = "First plugin of type " + sendReport.getPluginType() + " does not match plugin type of " + serviceName + ". Current type is " + service.getPluginType();
        exchangeErrorEvent.fire(new ExchangeMessageEvent(origin, ExchangeModuleResponseMapper.createFaultMessage(FaultCode.EXCHANGE_PLUGIN_INVALID, faultMessage)));
        return false;
    } else if (sendReport.getPluginName() != null && !serviceName.equalsIgnoreCase(sendReport.getPluginName())) {
        String faultMessage = "First plugin of type " + sendReport.getPluginType() + " does not matching input of " + sendReport.getPluginName();
        exchangeErrorEvent.fire(new ExchangeMessageEvent(origin, ExchangeModuleResponseMapper.createFaultMessage(FaultCode.EXCHANGE_PLUGIN_INVALID, faultMessage)));
        return false;
    } else if (!StatusType.STARTED.equals(service.getStatus())) {
        try {
            List<UnsentMessageTypeProperty> unsentMessageProperties = ExchangeLogMapper.getUnsentMessageProperties(sendReport);
            exchangeLog.createUnsentMessage(sendReport.getRecipient(), sendReport.getTimestamp(), ExchangeLogMapper.getSendMovementSenderReceiver(sendReport), origin.getText(), unsentMessageProperties, username);
        } catch (ExchangeLogException | JMSException e) {
            LOG.error("Couldn't create unsent message " + e.getMessage());
        }
        try {
            AcknowledgeType ackType = ExchangeModuleResponseMapper.mapAcknowledgeTypeNOK(origin.getJMSMessageID(), "Plugin to send movement is not started");
            String moduleResponse = ExchangeModuleResponseMapper.mapSendMovementToPluginResponse(ackType);
            producer.sendModuleResponseMessage(origin, moduleResponse);
        } catch (JMSException | ExchangeModelMarshallException e) {
            LOG.error("Plugin not started, couldn't send module response: " + e.getMessage());
        }
        return false;
    }
    return true;
}
Also used : ExchangeLogException(eu.europa.ec.fisheries.uvms.exchange.service.exception.ExchangeLogException) AcknowledgeType(eu.europa.ec.fisheries.schema.exchange.common.v1.AcknowledgeType) JMSException(javax.jms.JMSException) List(java.util.List) ArrayList(java.util.ArrayList) UnsentMessageTypeProperty(eu.europa.ec.fisheries.schema.exchange.v1.UnsentMessageTypeProperty) ExchangeMessageEvent(eu.europa.ec.fisheries.uvms.exchange.message.event.carrier.ExchangeMessageEvent)

Example 9 with ExchangeLogException

use of eu.europa.ec.fisheries.uvms.exchange.service.exception.ExchangeLogException 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 10 with ExchangeLogException

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

Aggregations

ExchangeLogException (eu.europa.ec.fisheries.uvms.exchange.service.exception.ExchangeLogException)33 ExchangeModelMarshallException (eu.europa.ec.fisheries.uvms.exchange.model.exception.ExchangeModelMarshallException)15 ExchangeLogType (eu.europa.ec.fisheries.schema.exchange.v1.ExchangeLogType)14 NotificationMessage (eu.europa.ec.fisheries.uvms.longpolling.notifications.NotificationMessage)9 ExchangeModelException (eu.europa.ec.fisheries.uvms.exchange.model.exception.ExchangeModelException)8 ExchangeMessageException (eu.europa.ec.fisheries.uvms.exchange.message.exception.ExchangeMessageException)7 JMSException (javax.jms.JMSException)6 ExchangeLogStatusTypeType (eu.europa.ec.fisheries.schema.exchange.v1.ExchangeLogStatusTypeType)5 LogRefType (eu.europa.ec.fisheries.schema.exchange.v1.LogRefType)5 PluginType (eu.europa.ec.fisheries.schema.exchange.plugin.types.v1.PluginType)4 RulesModelMapperException (eu.europa.ec.fisheries.uvms.rules.model.exception.RulesModelMapperException)4 ServiceResponseType (eu.europa.ec.fisheries.schema.exchange.service.v1.ServiceResponseType)3 UnsentMessageTypeProperty (eu.europa.ec.fisheries.schema.exchange.v1.UnsentMessageTypeProperty)3 RulesModelMarshallException (eu.europa.ec.fisheries.uvms.rules.model.exception.RulesModelMarshallException)3 ArrayList (java.util.ArrayList)3 AcknowledgeType (eu.europa.ec.fisheries.schema.exchange.common.v1.AcknowledgeType)2 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 ExchangeLogStatusType (eu.europa.ec.fisheries.schema.exchange.v1.ExchangeLogStatusType)2