use of eu.europa.ec.fisheries.uvms.exchange.model.exception.ExchangeModelMarshallException 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.model.exception.ExchangeModelMarshallException in project UVMS-ExchangeModule-APP by UnionVMS.
the class ExchangeEventIncomingServiceBean method ping.
@Override
public void ping(@Observes @PingEvent ExchangeMessageEvent message) {
try {
PingResponse response = new PingResponse();
response.setResponse("pong");
producer.sendModuleResponseMessage(message.getJmsMessage(), JAXBMarshaller.marshallJaxBObjectToString(response));
} catch (ExchangeModelMarshallException e) {
log.error("[ Error when marshalling ping response ]");
}
}
use of eu.europa.ec.fisheries.uvms.exchange.model.exception.ExchangeModelMarshallException in project UVMS-ExchangeModule-APP by UnionVMS.
the class ExchangeToRulesSyncMsgBean method getValidationFromRules.
public ExchangeLogWithValidationResults getValidationFromRules(String guid, TypeRefType type) {
if (StringUtils.isEmpty(guid)) {
return new ExchangeLogWithValidationResults();
}
ExchangeLogWithValidationResults resp = new ExchangeLogWithValidationResults();
try {
String getValidationsByGuidRequest = RulesModuleRequestMapper.createGetValidationsByGuidRequest(guid, type == null ? null : type.name());
String correlationId = exchangeProducerBean.sendRulesMessage(getValidationsByGuidRequest);
TextMessage validationRespMsg = exchangeConsumerBean.getMessage(correlationId, TextMessage.class);
ValidationMessageTypeResponse validTypeRespFromRules = JAXBMarshaller.unmarshallTextMessage(validationRespMsg, ValidationMessageTypeResponse.class);
List<ValidationMessageType> validationsListResponse = validTypeRespFromRules.getValidationsListResponse();
if (CollectionUtils.isNotEmpty(validationsListResponse)) {
for (ValidationMessageType validMsgFromRules : validationsListResponse) {
resp.getValidationList().add(mapToLogValidationResult(validMsgFromRules));
}
}
} catch (ConfigMessageException | MessageException | RulesModelMarshallException | ExchangeModelMarshallException e) {
log.error("Error while trying to get Validation Results for RawMessage GUID from Rules!", e);
}
return resp;
}
use of eu.europa.ec.fisheries.uvms.exchange.model.exception.ExchangeModelMarshallException 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.model.exception.ExchangeModelMarshallException 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