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 + " ]");
}
}
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);
}
}
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 + " ]");
}
}
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())));
}
}
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);
}
}
Aggregations