use of eu.europa.ec.fisheries.schema.exchange.v1.ExchangeLogType in project UVMS-ExchangeModule-APP by UnionVMS.
the class ExchangeEventIncomingServiceBean method processFLUXFAReportMessage.
@Override
public void processFLUXFAReportMessage(@Observes @SetFluxFAReportMessageEvent ExchangeMessageEvent message) {
try {
SetFLUXFAReportMessageRequest request = JAXBMarshaller.unmarshallTextMessage(message.getJmsMessage(), SetFLUXFAReportMessageRequest.class);
log.debug("Got FLUXFAReportMessage in exchange :" + request.getRequest());
ExchangeLogType exchangeLogType = exchangeLog.log(request, LogType.RCV_FLUX_FA_REPORT_MSG, ExchangeLogStatusTypeType.ISSUED, TypeRefType.FA_REPORT, request.getRequest(), true);
String msg = RulesModuleRequestMapper.createSetFLUXFAReportMessageRequest(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 SetFLUXFAReportMessageRequest when processing FLUXFAReportMessage coming from fa-plugin!", e);
} catch (ExchangeLogException e) {
log.error("Couldn't log FAReportMessage received from plugin into database", e);
}
}
use of eu.europa.ec.fisheries.schema.exchange.v1.ExchangeLogType in project UVMS-ExchangeModule-APP by UnionVMS.
the class ExchangeEventIncomingServiceBean method processFAQueryMessage.
@Override
public void processFAQueryMessage(@Observes @SetFaQueryMessageEvent ExchangeMessageEvent message) {
try {
SetFAQueryMessageRequest request = JAXBMarshaller.unmarshallTextMessage(message.getJmsMessage(), SetFAQueryMessageRequest.class);
log.debug("Got FAQueryMessage in exchange :" + request.getRequest());
ExchangeLogType exchangeLogType = exchangeLog.log(request, LogType.RECEIVE_FA_QUERY_MSG, ExchangeLogStatusTypeType.ISSUED, TypeRefType.FA_QUERY, request.getRequest(), true);
String msg = RulesModuleRequestMapper.createSetFaQueryMessageRequest(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 SetFAQueryMessageRequest when processing FAQueryMessage coming from fa-plugin!", e);
} catch (ExchangeLogException e) {
log.error("Couldn't log FAQueryMessage received from plugin into database", e);
}
}
use of eu.europa.ec.fisheries.schema.exchange.v1.ExchangeLogType in project UVMS-ExchangeModule-APP by UnionVMS.
the class ExchangeEventIncomingServiceBean method logIdByTypeExists.
@Override
public void logIdByTypeExists(@Observes @LogIdByTypeExists ExchangeMessageEvent event) {
try {
LogIdByTypeExistsRequest request = unMarshallMessage(event.getJmsMessage().getText(), LogIdByTypeExistsRequest.class);
String messageGuid = request.getMessageGuid();
TypeRefType refType = request.getRefType();
ExchangeLogType exchangeLogByGuid = exchangeLogModel.getExchangeLogByGuidAndType(messageGuid, refType);
LogIdByTypeExistsResponse response = new LogIdByTypeExistsResponse();
if (exchangeLogByGuid != null) {
response.setMessageGuid(exchangeLogByGuid.getGuid());
}
String responseAsString = JAXBUtils.marshallJaxBObjectToString(response);
producer.sendModuleResponseMessage(event.getJmsMessage(), responseAsString);
} catch (ExchangeModelException | JAXBException | JMSException e) {
fireExchangeFault(event, "Could not un-marshall " + LogRefIdByTypeExistsRequest.class, e);
}
}
use of eu.europa.ec.fisheries.schema.exchange.v1.ExchangeLogType in project UVMS-ExchangeModule-APP by UnionVMS.
the class ExchangeEventIncomingServiceBean method handleUpdateExchangeLogAcknowledge.
private void handleUpdateExchangeLogAcknowledge(ExchangePluginMethod method, String serviceClassName, AcknowledgeType ack) {
ExchangeLogStatusTypeType logStatus = ExchangeLogStatusTypeType.FAILED;
switch(ack.getType()) {
case OK:
// TODO if(poll probably transmitted)
logStatus = ExchangeLogStatusTypeType.SUCCESSFUL;
try {
exchangeLog.removeUnsentMessage(ack.getUnsentMessageGuid(), serviceClassName);
} catch (ExchangeLogException ex) {
log.error(ex.getMessage());
}
break;
case NOK:
log.debug(method + " was NOK: " + ack.getMessage());
break;
}
try {
ExchangeLogType updatedLog = exchangeLog.updateStatus(ack.getMessageId(), logStatus, serviceClassName);
// Long polling
LogRefType typeRef = updatedLog.getTypeRef();
if (typeRef != null && typeRef.getType() == TypeRefType.POLL) {
String pollGuid = typeRef.getRefGuid();
pollEvent.fire(new NotificationMessage("guid", pollGuid));
}
} catch (ExchangeLogException e) {
log.error(e.getMessage());
}
}
use of eu.europa.ec.fisheries.schema.exchange.v1.ExchangeLogType in project UVMS-ExchangeModule-APP by UnionVMS.
the class ExchangeEventOutgoingServiceBean method sendFLUXFAResponseToPlugin.
@Override
public void sendFLUXFAResponseToPlugin(@Observes @SendFLUXFAResponseToPluginEvent ExchangeMessageEvent message) {
try {
SetFLUXFAResponseMessageRequest request = JAXBMarshaller.unmarshallTextMessage(message.getJmsMessage(), SetFLUXFAResponseMessageRequest.class);
LOG.debug("[INFO] Got FLUXFAResponse in exchange :" + request.getRequest());
String text = ExchangePluginRequestMapper.createSetFLUXFAResponseRequestWithOn(request.getRequest(), request.getDestination(), request.getFluxDataFlow(), request.getSenderOrReceiver(), request.getOnValue());
final ExchangeLogType log = exchangeLog.log(request, LogType.SEND_FLUX_RESPONSE_MSG, request.getStatus(), TypeRefType.FA_RESPONSE, request.getRequest(), false);
if (!log.getStatus().equals(ExchangeLogStatusTypeType.FAILED)) {
// Send response only if it is NOT FAILED
LOG.debug("[INFO] Sending FLUXFAResponse to Flux Activity Plugin {}", text);
String pluginMessageId = producer.sendEventBusMessage(text, ((request.getPluginType() == BELGIAN_ACTIVITY) ? ExchangeServiceConstants.BELGIAN_ACTIVITY_PLUGIN_SERVICE_NAME : ExchangeServiceConstants.FLUX_ACTIVITY_PLUGIN_SERVICE_NAME));
LOG.debug("[INFO] FLUXFAResponse sent to Flux Activity Plugin {}" + pluginMessageId);
} else {
LOG.info("[WARN] FLUXFAResponse is FAILED so won't be sent to Flux Activity Plugin {}", text);
}
} catch (ExchangeModelMarshallException | ExchangeMessageException | ExchangeLogException e) {
LOG.error("Unable to send FLUX FA Report to plugin.", e);
}
}
Aggregations