Search in sources :

Example 1 with MapToSubscriptionRequest

use of eu.europa.ec.fisheries.uvms.activity.model.schemas.MapToSubscriptionRequest in project UVMS-ActivityModule-APP by UnionVMS.

the class ActivityEventServiceBean method getMapToSubscriptionMessage.

@Override
public void getMapToSubscriptionMessage(@Observes @MapToSubscriptionRequestEvent EventMessage message) {
    log.info(GOT_JMS_INSIDE_ACTIVITY_TO_GET + "MapToSubscriptionRequestEvent");
    try {
        TextMessage jmsMessage = message.getJmsMessage();
        String jmsCorrelationID = jmsMessage.getJMSMessageID();
        String messageReceived = jmsMessage.getText();
        SubscriptionDataRequest subscriptionDataRequest = null;
        MapToSubscriptionRequest baseRequest = JAXBUtils.unMarshallMessage(messageReceived, MapToSubscriptionRequest.class);
        switch(baseRequest.getMessageType()) {
            case FLUX_FA_QUERY_MESSAGE:
                FLUXFAQueryMessage fluxfaQueryMessage = JAXBUtils.unMarshallMessage(baseRequest.getRequest(), FLUXFAQueryMessage.class);
                subscriptionDataRequest = SubscriptionMapper.mapToSubscriptionDataRequest(fluxfaQueryMessage.getFAQuery());
                break;
            case FLUX_FA_REPORT_MESSAGE:
                FLUXFAReportMessage fluxFAReportMessage = JAXBUtils.unMarshallMessage(baseRequest.getRequest(), FLUXFAReportMessage.class);
                subscriptionDataRequest = SubscriptionMapper.mapToSubscriptionDataRequest(fluxFAReportMessage);
                break;
            default:
                sendError(message, new IllegalArgumentException("VERBODEN VRUCHT"));
        }
        subscriptionProducer.sendMessageWithSpecificIds(JAXBUtils.marshallJaxBObjectToString(subscriptionDataRequest), subscriptionProducer.getDestination(), JMSUtils.lookupQueue(MessageConstants.QUEUE_RULES), null, jmsCorrelationID);
    } catch (JAXBException | MessageException | JMSException e) {
        sendError(message, e);
    }
}
Also used : FLUXFAQueryMessage(un.unece.uncefact.data.standard.fluxfaquerymessage._3.FLUXFAQueryMessage) FLUXFAReportMessage(un.unece.uncefact.data.standard.fluxfareportmessage._3.FLUXFAReportMessage) MessageException(eu.europa.ec.fisheries.uvms.commons.message.api.MessageException) JAXBException(javax.xml.bind.JAXBException) MapToSubscriptionRequest(eu.europa.ec.fisheries.uvms.activity.model.schemas.MapToSubscriptionRequest) JMSException(javax.jms.JMSException) SubscriptionDataRequest(eu.europa.ec.fisheries.wsdl.subscription.module.SubscriptionDataRequest) TextMessage(javax.jms.TextMessage)

Aggregations

MapToSubscriptionRequest (eu.europa.ec.fisheries.uvms.activity.model.schemas.MapToSubscriptionRequest)1 MessageException (eu.europa.ec.fisheries.uvms.commons.message.api.MessageException)1 SubscriptionDataRequest (eu.europa.ec.fisheries.wsdl.subscription.module.SubscriptionDataRequest)1 JMSException (javax.jms.JMSException)1 TextMessage (javax.jms.TextMessage)1 JAXBException (javax.xml.bind.JAXBException)1 FLUXFAQueryMessage (un.unece.uncefact.data.standard.fluxfaquerymessage._3.FLUXFAQueryMessage)1 FLUXFAReportMessage (un.unece.uncefact.data.standard.fluxfareportmessage._3.FLUXFAReportMessage)1