Search in sources :

Example 21 with ExchangeLogException

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

the class ExchangeEventIncomingServiceBean method handleSetPollStatusAcknowledge.

private void handleSetPollStatusAcknowledge(ExchangePluginMethod method, String serviceClassName, AcknowledgeType ack) {
    log.debug(method + " was acknowledged in " + serviceClassName);
    try {
        PollStatus updatedLog = exchangeLog.setPollStatus(ack.getMessageId(), ack.getPollStatus().getPollId(), ack.getPollStatus().getStatus(), serviceClassName);
        // Long polling
        pollEvent.fire(new NotificationMessage("guid", updatedLog.getPollGuid()));
    } catch (ExchangeLogException e) {
        log.error(e.getMessage());
    }
}
Also used : PollStatus(eu.europa.ec.fisheries.schema.exchange.v1.PollStatus) NotificationMessage(eu.europa.ec.fisheries.uvms.longpolling.notifications.NotificationMessage) ExchangeLogException(eu.europa.ec.fisheries.uvms.exchange.service.exception.ExchangeLogException)

Example 22 with ExchangeLogException

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

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

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

Example 25 with ExchangeLogException

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

the class ExchangeEventIncomingServiceBean method sendSalesReport.

@Override
public void sendSalesReport(@Observes @SendSalesReportEvent ExchangeMessageEvent message) {
    try {
        SendSalesReportRequest request = JAXBMarshaller.unmarshallTextMessage(message.getJmsMessage(), SendSalesReportRequest.class);
        ExchangeLogStatusTypeType validationStatus = request.getValidationStatus();
        exchangeLog.log(request, LogType.SEND_SALES_REPORT, validationStatus, TypeRefType.SALES_REPORT, request.getReport(), false);
        if (validationStatus == ExchangeLogStatusTypeType.SUCCESSFUL || validationStatus == ExchangeLogStatusTypeType.SUCCESSFUL_WITH_WARNINGS) {
            eu.europa.ec.fisheries.schema.exchange.plugin.v1.SendSalesReportRequest pluginRequest = new eu.europa.ec.fisheries.schema.exchange.plugin.v1.SendSalesReportRequest();
            pluginRequest.setRecipient(request.getSenderOrReceiver());
            pluginRequest.setReport(request.getReport());
            if (request.getSenderOrReceiver() != null) {
                pluginRequest.setSenderOrReceiver(request.getSenderOrReceiver());
            }
            pluginRequest.setMethod(ExchangePluginMethod.SEND_SALES_RESPONSE);
            exchangeEventOutgoingService.sendSalesReportToFLUX(pluginRequest);
        } else {
            log.error("Received invalid report from the Sales module: " + request.getReport());
        }
    } 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 report.", e);
    }
}
Also used : ExchangeLogStatusTypeType(eu.europa.ec.fisheries.schema.exchange.v1.ExchangeLogStatusTypeType) SendSalesReportRequest(eu.europa.ec.fisheries.schema.exchange.module.v1.SendSalesReportRequest) ExchangeMessageException(eu.europa.ec.fisheries.uvms.exchange.message.exception.ExchangeMessageException) ExchangeModelMarshallException(eu.europa.ec.fisheries.uvms.exchange.model.exception.ExchangeModelMarshallException) ExchangeLogException(eu.europa.ec.fisheries.uvms.exchange.service.exception.ExchangeLogException)

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