use of eu.europa.ec.fisheries.uvms.exchange.message.exception.ExchangeMessageException 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.exception.ExchangeMessageException in project UVMS-ExchangeModule-APP by UnionVMS.
the class ExchangeAssetServiceBean method getAsset.
@Override
public Asset getAsset(String assetGuid) throws ExchangeServiceException {
try {
String request = AssetModuleRequestMapper.createGetAssetModuleRequest(assetGuid, AssetIdType.GUID);
String messageId = producer.sendMessageOnQueue(request, MessageQueue.VESSEL);
TextMessage response = consumer.getMessage(messageId, TextMessage.class);
return AssetModuleResponseMapper.mapToAssetFromResponse(response, messageId);
} catch (ExchangeMessageException | MessageException e) {
LOG.error("Couldn't send message to vessel module");
throw new ExchangeServiceException("Couldn't send message to vessel module");
} catch (AssetModelMapperException e) {
LOG.error("Couldn't map asset object by guid: {}", assetGuid);
throw new ExchangeServiceException("Couldn't map asset object by guid: " + assetGuid);
}
}
use of eu.europa.ec.fisheries.uvms.exchange.message.exception.ExchangeMessageException in project UVMS-ExchangeModule-APP by UnionVMS.
the class ExchangeEventIncomingServiceBean method sendSalesReport.
@Override
public void sendSalesReport(@Observes @SendSalesReportEvent ExchangeMessageEvent message) {
try {
SendSalesReportRequest request = JAXBMarshaller.unmarshallTextMessage(message.getJmsMessage(), SendSalesReportRequest.class);
ExchangeLogStatusTypeType validationStatus = request.getValidationStatus();
exchangeLog.log(request, LogType.SEND_SALES_REPORT, validationStatus, TypeRefType.SALES_REPORT, request.getReport(), false);
if (validationStatus == ExchangeLogStatusTypeType.SUCCESSFUL || validationStatus == ExchangeLogStatusTypeType.SUCCESSFUL_WITH_WARNINGS) {
eu.europa.ec.fisheries.schema.exchange.plugin.v1.SendSalesReportRequest pluginRequest = new eu.europa.ec.fisheries.schema.exchange.plugin.v1.SendSalesReportRequest();
pluginRequest.setRecipient(request.getSenderOrReceiver());
pluginRequest.setReport(request.getReport());
if (request.getSenderOrReceiver() != null) {
pluginRequest.setSenderOrReceiver(request.getSenderOrReceiver());
}
pluginRequest.setMethod(ExchangePluginMethod.SEND_SALES_RESPONSE);
exchangeEventOutgoingService.sendSalesReportToFLUX(pluginRequest);
} else {
log.error("Received invalid report from the Sales module: " + request.getReport());
}
} catch (ExchangeModelMarshallException | ExchangeMessageException e) {
fireExchangeFault(message, "Error when sending a Sales response to FLUX", e);
} catch (ExchangeLogException e) {
fireExchangeFault(message, "Could not log the outgoing sales report.", e);
}
}
use of eu.europa.ec.fisheries.uvms.exchange.message.exception.ExchangeMessageException in project UVMS-ExchangeModule-APP by UnionVMS.
the class PluginServiceBean method setConfig.
@Override
public void setConfig(@Observes @ConfigSettingUpdatedEvent ConfigSettingEvent settingEvent) {
switch(settingEvent.getType()) {
case STORE:
// ConfigModule and/or Exchange module deployed
break;
case UPDATE:
LOG.info("ConfigModule updated parameter table with settings of plugins");
try {
String key = settingEvent.getKey();
String value = parameterService.getStringValue(key);
String settingKey;
String[] splittedKey = key.split(PARAMETER_DELIMETER);
if (splittedKey.length > 2) {
settingKey = key;
String serviceClassName = "";
for (int i = 0; i < splittedKey.length - 2; i++) {
serviceClassName += splittedKey[i] + ".";
}
serviceClassName += splittedKey[splittedKey.length - 2];
SettingType settingType = new SettingType();
settingType.setKey(key);
settingType.setValue(value);
updatePluginSetting(serviceClassName, settingType, "UVMS");
} else {
LOG.error("No key or malformed key sent in settingEvent: key: {}, value: {}", key, value);
}
} catch (ConfigServiceException e) {
LOG.error("Couldn't get updated parameter table value");
} catch (ExchangeServiceException e) {
LOG.error("Couldn't upsert settings in exchange");
} catch (ExchangeModelMarshallException e) {
LOG.error("Couldn't create plugin set config request");
} catch (ExchangeMessageException e) {
LOG.error("Couldn't send message to plugin");
}
break;
case DELETE:
LOG.info("ConfigModule removed parameter setting");
break;
}
}
use of eu.europa.ec.fisheries.uvms.exchange.message.exception.ExchangeMessageException in project UVMS-ExchangeModule-APP by UnionVMS.
the class PluginServiceBean method ping.
@Override
public boolean ping(String serviceClassName) throws ExchangeServiceException {
if (serviceClassName == null) {
throw new InputArgumentException("No service to ping");
}
try {
String text = ExchangePluginRequestMapper.createPingRequest();
producer.sendEventBusMessage(text, serviceClassName);
return true;
} catch (ExchangeModelMarshallException e) {
throw new ExchangeServiceException("[ Couldn't map ping request for " + serviceClassName + " ]");
} catch (ExchangeMessageException e) {
throw new ExchangeServiceException("[ Couldn't send ping request for " + serviceClassName + " ]");
}
}
Aggregations