Search in sources :

Example 11 with ExchangeModelMarshallException

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

the class PluginServiceBean method start.

@Override
public boolean start(String serviceClassName) throws ExchangeServiceException {
    if (serviceClassName == null) {
        throw new InputArgumentException("No service to start");
    }
    try {
        if (isServiceRegistered(serviceClassName)) {
            String text = ExchangePluginRequestMapper.createStartRequest();
            producer.sendEventBusMessage(text, serviceClassName);
            return true;
        } else {
            throw new ExchangeServiceException("Service with service class name: " + serviceClassName + " does not exist");
        }
    } catch (ExchangeModelMarshallException e) {
        throw new ExchangeServiceException("[ Couldn't map start request for " + serviceClassName + " ]");
    } catch (ExchangeMessageException e) {
        throw new ExchangeServiceException("[ Couldn't send start request for " + serviceClassName + " ]");
    }
}
Also used : ExchangeModelMarshallException(eu.europa.ec.fisheries.uvms.exchange.model.exception.ExchangeModelMarshallException) InputArgumentException(eu.europa.ec.fisheries.uvms.exchange.service.exception.InputArgumentException) ExchangeMessageException(eu.europa.ec.fisheries.uvms.exchange.message.exception.ExchangeMessageException) ExchangeServiceException(eu.europa.ec.fisheries.uvms.exchange.service.exception.ExchangeServiceException)

Example 12 with ExchangeModelMarshallException

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

the class PluginServiceBean method updatePluginSetting.

@Override
public void updatePluginSetting(@Observes @UpdatePluginSettingEvent ExchangeMessageEvent settingEvent) {
    LOG.info("update plugin setting from module queue:{}", settingEvent);
    try {
        TextMessage jmsMessage = settingEvent.getJmsMessage();
        UpdatePluginSettingRequest request = JAXBMarshaller.unmarshallTextMessage(jmsMessage, UpdatePluginSettingRequest.class);
        updatePluginSetting(request.getServiceClassName(), request.getSetting(), request.getUsername());
        String text = ExchangeModuleResponseMapper.mapUpdateSettingResponse(ExchangeModuleResponseMapper.mapAcknowledgeTypeOK());
        producer.sendModuleResponseMessage(settingEvent.getJmsMessage(), text);
    } catch (ExchangeModelMarshallException | ExchangeServiceException | ExchangeMessageException e) {
        LOG.error("Couldn't unmarshall update setting request");
        settingEvent.setErrorFault(ExchangeModuleResponseMapper.createFaultMessage(FaultCode.EXCHANGE_EVENT_SERVICE, "Couldn't update plugin setting"));
        producer.sendModuleErrorResponseMessage(settingEvent);
    }
}
Also used : ExchangeModelMarshallException(eu.europa.ec.fisheries.uvms.exchange.model.exception.ExchangeModelMarshallException) UpdatePluginSettingRequest(eu.europa.ec.fisheries.schema.exchange.module.v1.UpdatePluginSettingRequest) ExchangeMessageException(eu.europa.ec.fisheries.uvms.exchange.message.exception.ExchangeMessageException) TextMessage(javax.jms.TextMessage) ExchangeServiceException(eu.europa.ec.fisheries.uvms.exchange.service.exception.ExchangeServiceException)

Example 13 with ExchangeModelMarshallException

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

the class PluginServiceBean method stop.

@Override
public boolean stop(String serviceClassName) throws ExchangeServiceException {
    if (serviceClassName == null) {
        throw new InputArgumentException("No service to stop");
    }
    try {
        if (isServiceRegistered(serviceClassName)) {
            String text = ExchangePluginRequestMapper.createStopRequest();
            producer.sendEventBusMessage(text, serviceClassName);
            return true;
        } else {
            throw new ExchangeServiceException("Service with service class name: " + serviceClassName + " does not exist");
        }
    } catch (ExchangeModelMarshallException e) {
        throw new ExchangeServiceException("[ Couldn't map stop request for " + serviceClassName + " ]");
    } catch (ExchangeMessageException e) {
        throw new ExchangeServiceException("[ Couldn't send stop request for " + serviceClassName + " ]");
    }
}
Also used : ExchangeModelMarshallException(eu.europa.ec.fisheries.uvms.exchange.model.exception.ExchangeModelMarshallException) InputArgumentException(eu.europa.ec.fisheries.uvms.exchange.service.exception.InputArgumentException) ExchangeMessageException(eu.europa.ec.fisheries.uvms.exchange.message.exception.ExchangeMessageException) ExchangeServiceException(eu.europa.ec.fisheries.uvms.exchange.service.exception.ExchangeServiceException)

Example 14 with ExchangeModelMarshallException

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

the class RegistryBusEventListener method onMessage.

@Override
public void onMessage(Message message) {
    TextMessage textMessage = (TextMessage) message;
    ServiceType settings = null;
    try {
        ExchangeRegistryBaseRequest request = JAXBMarshaller.unmarshallTextMessage(textMessage, ExchangeRegistryBaseRequest.class);
        LOG.info("Eventbus listener for Exchange Registry (ExchangeModelConstants.EXCHANGE_REGISTER_SERVICE): {} {}", ExchangeModelConstants.EXCHANGE_REGISTER_SERVICE, request);
        switch(request.getMethod()) {
            case REGISTER_SERVICE:
                RegisterServiceRequest regReq = JAXBMarshaller.unmarshallTextMessage(textMessage, RegisterServiceRequest.class);
                settings = regReq.getService();
                registerServiceEvent.fire(new PluginMessageEvent(textMessage));
                break;
            case UNREGISTER_SERVICE:
                UnregisterServiceRequest unRegReq = JAXBMarshaller.unmarshallTextMessage(textMessage, UnregisterServiceRequest.class);
                settings = unRegReq.getService();
                unregisterServiceEvent.fire(new PluginMessageEvent(textMessage));
                break;
            default:
                LOG.error("[ Not implemented method consumed: {} ]", request.getMethod());
                throw new ExchangeMessageException("[ Not implemented method consumed: " + request.getMethod() + " ]");
        }
    } catch (ExchangeMessageException | ExchangeModelMarshallException | NullPointerException e) {
        LOG.error("[ Error when receiving message on topic in exchange: {}] {}", message, e);
        errorEvent.fire(new PluginMessageEvent(textMessage, settings, ExchangePluginResponseMapper.mapToPluginFaultResponse(FaultCode.EXCHANGE_TOPIC_MESSAGE.getCode(), "Error when receiving message in exchange " + e.getMessage())));
    }
}
Also used : ExchangeModelMarshallException(eu.europa.ec.fisheries.uvms.exchange.model.exception.ExchangeModelMarshallException) ServiceType(eu.europa.ec.fisheries.schema.exchange.service.v1.ServiceType) UnregisterServiceRequest(eu.europa.ec.fisheries.schema.exchange.registry.v1.UnregisterServiceRequest) RegisterServiceRequest(eu.europa.ec.fisheries.schema.exchange.registry.v1.RegisterServiceRequest) ExchangeMessageException(eu.europa.ec.fisheries.uvms.exchange.message.exception.ExchangeMessageException) PluginMessageEvent(eu.europa.ec.fisheries.uvms.exchange.message.event.carrier.PluginMessageEvent) TextMessage(javax.jms.TextMessage) ExchangeRegistryBaseRequest(eu.europa.ec.fisheries.schema.exchange.registry.v1.ExchangeRegistryBaseRequest)

Example 15 with ExchangeModelMarshallException

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

the class ExchangeEventIncomingServiceBean method processFluxFAResponseMessage.

@Override
public void processFluxFAResponseMessage(@Observes @ReceivedFluxFaResponseMessageEvent ExchangeMessageEvent message) {
    try {
        RcvFLUXFaResponseMessageRequest request = JAXBMarshaller.unmarshallTextMessage(message.getJmsMessage(), RcvFLUXFaResponseMessageRequest.class);
        log.debug("Got FLUXResponseMessage in exchange :" + request.getRequest());
        ExchangeLogType exchangeLogType = exchangeLog.log(request, LogType.RECEIVE_FLUX_RESPONSE_MSG, ExchangeLogStatusTypeType.ISSUED, TypeRefType.FA_RESPONSE, request.getRequest(), true);
        String msg = RulesModuleRequestMapper.createRcvFluxFaResponseMessageRequest(extractPluginType(request), request.getRequest(), request.getUsername(), extractLogId(message, exchangeLogType), request.getFluxDataFlow(), request.getSenderOrReceiver(), request.getOnValue());
        forwardToRules(msg, message, null);
    } catch (RulesModelMapperException | ExchangeModelMarshallException e) {
        log.error("Couldn't map to RcvFLUXFaResponseMessageRequest when processing FLUXResponseMessage coming from fa-plugin!", e);
    } catch (ExchangeLogException e) {
        log.error("Couldn't log FLUXResponseMessage received from plugin into database", e);
    }
}
Also used : ExchangeModelMarshallException(eu.europa.ec.fisheries.uvms.exchange.model.exception.ExchangeModelMarshallException) ExchangeLogType(eu.europa.ec.fisheries.schema.exchange.v1.ExchangeLogType) ExchangeLogException(eu.europa.ec.fisheries.uvms.exchange.service.exception.ExchangeLogException) RulesModelMapperException(eu.europa.ec.fisheries.uvms.rules.model.exception.RulesModelMapperException) RcvFLUXFaResponseMessageRequest(eu.europa.ec.fisheries.schema.exchange.module.v1.RcvFLUXFaResponseMessageRequest)

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