Search in sources :

Example 1 with ExchangePluginMethod

use of eu.europa.ec.fisheries.schema.exchange.plugin.v1.ExchangePluginMethod 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)

Aggregations

AcknowledgeType (eu.europa.ec.fisheries.schema.exchange.common.v1.AcknowledgeType)1 AcknowledgeResponse (eu.europa.ec.fisheries.schema.exchange.plugin.v1.AcknowledgeResponse)1 ExchangePluginMethod (eu.europa.ec.fisheries.schema.exchange.plugin.v1.ExchangePluginMethod)1 ExchangeModelMarshallException (eu.europa.ec.fisheries.uvms.exchange.model.exception.ExchangeModelMarshallException)1 ExchangeServiceException (eu.europa.ec.fisheries.uvms.exchange.service.exception.ExchangeServiceException)1