Search in sources :

Example 16 with ExchangeModelMarshallException

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

the class ExchangeEventIncomingServiceBean method receiveSalesReport.

@Override
public void receiveSalesReport(@Observes @ReceiveSalesReportEvent ExchangeMessageEvent event) {
    try {
        ReceiveSalesReportRequest request = JAXBMarshaller.unmarshallTextMessage(event.getJmsMessage(), ReceiveSalesReportRequest.class);
        log.info("Receive sales report in Exchange module:{}", request);
        String report = request.getReport();
        PluginType plugin = request.getPluginType();
        String sender = request.getSenderOrReceiver();
        String messageGuid = request.getMessageGuid();
        ExchangeLogType log = exchangeLog.log(request, LogType.RECEIVE_SALES_REPORT, ExchangeLogStatusTypeType.ISSUED, TypeRefType.SALES_REPORT, report, true);
        forwardToRules(RulesModuleRequestMapper.createReceiveSalesReportRequest(report, messageGuid, plugin.name(), log.getGuid(), sender, request.getOnValue()));
    } catch (ExchangeModelMarshallException e) {
        try {
            String errorMessage = "Couldn't map to SetSalesReportRequest when processing sales report from plugin. The event was " + event.getJmsMessage().getText();
            firePluginFault(event, errorMessage, e);
        } catch (JMSException e1) {
            firePluginFault(event, "Couldn't map to SetSalesReportRequest when processing sales report from plugin.", e);
        }
    } catch (ExchangeLogException e) {
        firePluginFault(event, "Could not log the incoming sales report.", e);
    } catch (RulesModelMarshallException e) {
        firePluginFault(event, "Could not create a request for the Rules module for an incoming sales report.", e);
    }
}
Also used : ExchangeModelMarshallException(eu.europa.ec.fisheries.uvms.exchange.model.exception.ExchangeModelMarshallException) RulesModelMarshallException(eu.europa.ec.fisheries.uvms.rules.model.exception.RulesModelMarshallException) ExchangeLogType(eu.europa.ec.fisheries.schema.exchange.v1.ExchangeLogType) ExchangeLogException(eu.europa.ec.fisheries.uvms.exchange.service.exception.ExchangeLogException) ReceiveSalesReportRequest(eu.europa.ec.fisheries.schema.exchange.module.v1.ReceiveSalesReportRequest) JMSException(javax.jms.JMSException) PluginType(eu.europa.ec.fisheries.schema.exchange.plugin.types.v1.PluginType)

Example 17 with ExchangeModelMarshallException

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

the class ExchangeEventIncomingServiceBean method handleProcessedMovement.

// Async response handler for processed movements
@Override
public void handleProcessedMovement(@Observes @HandleProcessedMovementEvent ExchangeMessageEvent message) {
    try {
        ProcessedMovementResponse request = JAXBMarshaller.unmarshallTextMessage(message.getJmsMessage(), ProcessedMovementResponse.class);
        log.debug("Received processed movement from Rules:{}", request);
        String username;
        MovementRefType movementRefType = request.getMovementRefType();
        SetReportMovementType orgRequest = request.getOrgRequest();
        if (PluginType.MANUAL.equals(orgRequest.getPluginType())) {
            username = request.getUsername();
        } else {
            username = orgRequest.getPluginName();
        }
        ExchangeLogType log = ExchangeLogMapper.getReceivedMovementExchangeLog(orgRequest, movementRefType.getMovementRefGuid(), movementRefType.getType().value(), username);
        ExchangeLogType createdLog = exchangeLog.log(log, username);
        LogRefType logTypeRef = createdLog.getTypeRef();
        if (logTypeRef != null && logTypeRef.getType() == TypeRefType.POLL) {
            String pollGuid = logTypeRef.getRefGuid();
            pollEvent.fire(new NotificationMessage("guid", pollGuid));
        }
    } catch (ExchangeLogException | ExchangeModelMarshallException e) {
        log.error(e.getMessage());
    }
}
Also used : ExchangeModelMarshallException(eu.europa.ec.fisheries.uvms.exchange.model.exception.ExchangeModelMarshallException) MovementRefType(eu.europa.ec.fisheries.schema.exchange.movement.v1.MovementRefType) NotificationMessage(eu.europa.ec.fisheries.uvms.longpolling.notifications.NotificationMessage) ExchangeLogType(eu.europa.ec.fisheries.schema.exchange.v1.ExchangeLogType) ExchangeLogException(eu.europa.ec.fisheries.uvms.exchange.service.exception.ExchangeLogException) LogRefType(eu.europa.ec.fisheries.schema.exchange.v1.LogRefType) SetReportMovementType(eu.europa.ec.fisheries.schema.exchange.movement.v1.SetReportMovementType) ProcessedMovementResponse(eu.europa.ec.fisheries.schema.exchange.module.v1.ProcessedMovementResponse)

Example 18 with ExchangeModelMarshallException

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

the class ExchangeEventIncomingServiceBean method processAcknowledge.

@Override
public void processAcknowledge(@Observes @ExchangeLogEvent ExchangeMessageEvent message) {
    log.info("Process acknowledge:{}", message);
    try {
        AcknowledgeResponse response = JAXBMarshaller.unmarshallTextMessage(message.getJmsMessage(), AcknowledgeResponse.class);
        AcknowledgeType acknowledge = response.getResponse();
        String serviceClassName = response.getServiceClassName();
        ExchangePluginMethod method = response.getMethod();
        switch(method) {
            case SET_COMMAND:
                // Only Acknowledge for poll should have a poll status set
                if (acknowledge.getPollStatus() != null && acknowledge.getPollStatus().getPollId() != null) {
                    handleSetPollStatusAcknowledge(method, serviceClassName, acknowledge);
                } else {
                    handleUpdateExchangeLogAcknowledge(method, serviceClassName, acknowledge);
                }
                break;
            case SET_REPORT:
                handleUpdateExchangeLogAcknowledge(method, serviceClassName, acknowledge);
                break;
            case START:
                handleUpdateServiceAcknowledge(serviceClassName, acknowledge, StatusType.STARTED);
                pluginStatusEvent.fire(createNotificationMessage(serviceClassName, true));
                break;
            case STOP:
                handleUpdateServiceAcknowledge(serviceClassName, acknowledge, StatusType.STOPPED);
                pluginStatusEvent.fire(createNotificationMessage(serviceClassName, false));
                break;
            case SET_CONFIG:
            default:
                handleAcknowledge(method, serviceClassName, acknowledge);
                break;
        }
    } catch (ExchangeModelMarshallException e) {
        log.error("Process acknowledge couldn't be marshalled {} {}", message, e);
    } catch (ExchangeServiceException e) {
        // TODO Audit.log() couldn't process acknowledge in exchange service
        log.error("Couldn't process acknowledge in exchange service:{} {} ", message, e.getMessage());
    }
}
Also used : ExchangeModelMarshallException(eu.europa.ec.fisheries.uvms.exchange.model.exception.ExchangeModelMarshallException) ExchangePluginMethod(eu.europa.ec.fisheries.schema.exchange.plugin.v1.ExchangePluginMethod) AcknowledgeType(eu.europa.ec.fisheries.schema.exchange.common.v1.AcknowledgeType) AcknowledgeResponse(eu.europa.ec.fisheries.schema.exchange.plugin.v1.AcknowledgeResponse) ExchangeServiceException(eu.europa.ec.fisheries.uvms.exchange.service.exception.ExchangeServiceException)

Example 19 with ExchangeModelMarshallException

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

the class ExchangeEventIncomingServiceBean method receiveSalesQuery.

@Override
public void receiveSalesQuery(@Observes @ReceiveSalesQueryEvent ExchangeMessageEvent event) {
    try {
        ReceiveSalesQueryRequest request = JAXBMarshaller.unmarshallTextMessage(event.getJmsMessage(), ReceiveSalesQueryRequest.class);
        log.info("Process sales query in Exchange module:{}", request);
        String query = request.getQuery();
        PluginType plugin = request.getPluginType();
        String sender = request.getSenderOrReceiver();
        String messageGuid = request.getMessageGuid();
        ExchangeLogType log = exchangeLog.log(request, LogType.RECEIVE_SALES_QUERY, ExchangeLogStatusTypeType.ISSUED, TypeRefType.SALES_QUERY, query, true);
        forwardToRules(RulesModuleRequestMapper.createReceiveSalesQueryRequest(query, messageGuid, plugin.name(), log.getGuid(), sender, request.getOnValue()));
    } catch (ExchangeModelMarshallException e) {
        try {
            firePluginFault(event, "Couldn't map to SalesQueryRequest when processing sales query from plugin. The message was " + event.getJmsMessage().getText(), e);
        } catch (JMSException e1) {
            firePluginFault(event, "Couldn't map to SalesQueryRequest when processing sales query from plugin.", e);
        }
    } catch (ExchangeLogException e) {
        firePluginFault(event, "Could not log the incoming sales query.", e);
    } catch (RulesModelMarshallException e) {
        firePluginFault(event, "Could not create a request for the Rules module for an incoming sales query.", e);
    }
}
Also used : ExchangeModelMarshallException(eu.europa.ec.fisheries.uvms.exchange.model.exception.ExchangeModelMarshallException) RulesModelMarshallException(eu.europa.ec.fisheries.uvms.rules.model.exception.RulesModelMarshallException) ReceiveSalesQueryRequest(eu.europa.ec.fisheries.schema.exchange.module.v1.ReceiveSalesQueryRequest) ExchangeLogType(eu.europa.ec.fisheries.schema.exchange.v1.ExchangeLogType) ExchangeLogException(eu.europa.ec.fisheries.uvms.exchange.service.exception.ExchangeLogException) JMSException(javax.jms.JMSException) PluginType(eu.europa.ec.fisheries.schema.exchange.plugin.types.v1.PluginType)

Example 20 with ExchangeModelMarshallException

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

the class ExchangeEventIncomingServiceBean method receiveSalesResponse.

@Override
public void receiveSalesResponse(@Observes @ReceiveSalesResponseEvent ExchangeMessageEvent event) {
    try {
        ReceiveSalesResponseRequest request = JAXBMarshaller.unmarshallTextMessage(event.getJmsMessage(), ReceiveSalesResponseRequest.class);
        String response = request.getResponse();
        ExchangeLogType log = exchangeLog.log(request, LogType.RECEIVE_SALES_RESPONSE, ExchangeLogStatusTypeType.ISSUED, TypeRefType.SALES_RESPONSE, response, true);
        forwardToRules(RulesModuleRequestMapper.createReceiveSalesResponseRequest(response, log.getGuid(), request.getSenderOrReceiver()));
    } catch (ExchangeModelMarshallException e) {
        firePluginFault(event, "Error when receiving a Sales response from FLUX", e);
    } catch (ExchangeLogException e) {
        firePluginFault(event, "Could not log the incoming sales response.", e);
    } catch (RulesModelMarshallException e) {
        firePluginFault(event, "Could not create a request for the Rules module for an incoming sales response.", e);
    }
}
Also used : ExchangeModelMarshallException(eu.europa.ec.fisheries.uvms.exchange.model.exception.ExchangeModelMarshallException) ReceiveSalesResponseRequest(eu.europa.ec.fisheries.schema.exchange.module.v1.ReceiveSalesResponseRequest) RulesModelMarshallException(eu.europa.ec.fisheries.uvms.rules.model.exception.RulesModelMarshallException) ExchangeLogType(eu.europa.ec.fisheries.schema.exchange.v1.ExchangeLogType) ExchangeLogException(eu.europa.ec.fisheries.uvms.exchange.service.exception.ExchangeLogException)

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