use of eu.europa.ec.fisheries.uvms.exchange.message.event.carrier.PluginMessageEvent in project UVMS-ExchangeModule-APP by UnionVMS.
the class ExchangeEventIncomingServiceBean method validate.
private boolean validate(SetReportMovementType setReport, ServiceResponseType service, TextMessage origin) {
if (setReport == null) {
String faultMessage = "No setReport request";
pluginErrorEvent.fire(new PluginMessageEvent(origin, service, ExchangePluginResponseMapper.mapToPluginFaultResponse(FaultCode.PLUGIN_VALIDATION.getCode(), faultMessage)));
return false;
} else if (setReport.getMovement() == null) {
String faultMessage = "No movement in setReport request";
pluginErrorEvent.fire(new PluginMessageEvent(origin, service, ExchangePluginResponseMapper.mapToPluginFaultResponse(FaultCode.PLUGIN_VALIDATION.getCode(), faultMessage)));
return false;
} else if (setReport.getPluginType() == null) {
String faultMessage = "No pluginType in setReport request";
pluginErrorEvent.fire(new PluginMessageEvent(origin, service, ExchangePluginResponseMapper.mapToPluginFaultResponse(FaultCode.PLUGIN_VALIDATION.getCode(), faultMessage)));
return false;
} else if (setReport.getPluginName() == null || setReport.getPluginName().isEmpty()) {
String faultMessage = "No pluginName in setReport request";
pluginErrorEvent.fire(new PluginMessageEvent(origin, service, ExchangePluginResponseMapper.mapToPluginFaultResponse(FaultCode.PLUGIN_VALIDATION.getCode(), faultMessage)));
return false;
} else if (setReport.getTimestamp() == null) {
String faultMessage = "No timestamp in setReport request";
pluginErrorEvent.fire(new PluginMessageEvent(origin, service, ExchangePluginResponseMapper.mapToPluginFaultResponse(FaultCode.PLUGIN_VALIDATION.getCode(), faultMessage)));
return false;
}
return true;
}
use of eu.europa.ec.fisheries.uvms.exchange.message.event.carrier.PluginMessageEvent in project UVMS-ExchangeModule-APP by UnionVMS.
the class ExchangeEventIncomingServiceBean method firePluginFault.
private void firePluginFault(ExchangeMessageEvent messageEvent, String errorMessage, Throwable exception) {
log.error(errorMessage, exception);
PluginFault fault = ExchangePluginResponseMapper.mapToPluginFaultResponse(FaultCode.EXCHANGE_PLUGIN_EVENT.getCode(), errorMessage);
pluginErrorEvent.fire(new PluginMessageEvent(messageEvent.getJmsMessage(), null, fault));
}
use of eu.europa.ec.fisheries.uvms.exchange.message.event.carrier.PluginMessageEvent in project UVMS-ExchangeModule-APP by UnionVMS.
the class PluginServiceBean method registerService.
@Override
public void registerService(@Observes @RegisterServiceEvent PluginMessageEvent event) {
LOG.info("register service:{}", event);
TextMessage textMessage = event.getJmsMessage();
RegisterServiceRequest register = null;
try {
register = JAXBMarshaller.unmarshallTextMessage(textMessage, RegisterServiceRequest.class);
String messageId = textMessage.getJMSMessageID();
boolean sendMessage = true;
if (register.getService() != null) {
sendMessage = checkPluginType(register.getService().getPluginType(), register.getService().getServiceResponseMessageName(), messageId);
if (sendMessage) {
registerService(register, messageId);
}
}
} catch (ExchangeModelMarshallException | ExchangeMessageException | JMSException e) {
LOG.error("Register service exception {} {}", event, e.getMessage());
errorEvent.fire(new PluginMessageEvent(textMessage, register.getService(), ExchangePluginResponseMapper.mapToPluginFaultResponse(FaultCode.EXCHANGE_PLUGIN_EVENT.getCode(), "Exception when register service")));
}
}
use of eu.europa.ec.fisheries.uvms.exchange.message.event.carrier.PluginMessageEvent 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.message.event.carrier.PluginMessageEvent in project UVMS-ExchangeModule-APP by UnionVMS.
the class PluginServiceBean method unregisterService.
@Override
public void unregisterService(@Observes @UnRegisterServiceEvent PluginMessageEvent event) {
LOG.info("unregister service:{}", event);
TextMessage textMessage = event.getJmsMessage();
ServiceResponseType service = null;
try {
UnregisterServiceRequest unregister = JAXBMarshaller.unmarshallTextMessage(textMessage, UnregisterServiceRequest.class);
service = exchangeService.unregisterService(unregister.getService(), unregister.getService().getName());
String serviceClassName = service.getServiceClassName();
// NO ack back to plugin
// TODO log to exchange log
} catch (ExchangeModelMarshallException | ExchangeServiceException e) {
LOG.error("Unregister service exception " + e.getMessage());
errorEvent.fire(new PluginMessageEvent(textMessage, service, ExchangePluginResponseMapper.mapToPluginFaultResponse(FaultCode.EXCHANGE_PLUGIN_EVENT.getCode(), "Exception when unregister service")));
}
}
Aggregations