use of eu.europa.ec.fisheries.schema.exchange.v1.ExchangeLogType in project UVMS-ExchangeModule-APP by UnionVMS.
the class ExchangeLogMapper method getSendEmailExchangeLog.
private static ExchangeLogType getSendEmailExchangeLog(CommandType command) throws ExchangeLogException {
if (command.getEmail() == null) {
throw new ExchangeLogException("No email");
}
SendEmailType log = new SendEmailType();
log.setType(LogType.SEND_EMAIL);
log.setDateRecieved(command.getTimestamp());
log.setSenderReceiver("SYSTEM");
log.setRecipient(command.getEmail().getTo());
log.setFwdRule(command.getFwdRule());
log.setFwdDate(command.getTimestamp());
return log;
}
use of eu.europa.ec.fisheries.schema.exchange.v1.ExchangeLogType in project UVMS-ExchangeModule-APP by UnionVMS.
the class ExchangeLogServiceBeanTest method updateStatusByLogGuidWhenSuccess.
@Test
public void updateStatusByLogGuidWhenSuccess() throws Exception {
// data set
ArgumentCaptor<ExchangeLogStatusType> captorForExchangeLogStatusType = ArgumentCaptor.forClass(ExchangeLogStatusType.class);
ExchangeLogType expectedUpdatedLog = new ExchangeLogType();
String logGuid = "123456";
ExchangeLogStatusTypeType status = ExchangeLogStatusTypeType.SUCCESSFUL;
// mock
doReturn(expectedUpdatedLog).when(exchangeLogModel).updateExchangeLogStatus(isA(ExchangeLogStatusType.class), eq("SYSTEM"));
// execute
ExchangeLogType actualUpdatedLog = exchangeLogService.updateStatus(logGuid, status);
// verify and assert
verify(exchangeLogModel).updateExchangeLogStatus(captorForExchangeLogStatusType.capture(), eq("SYSTEM"));
assertSame(expectedUpdatedLog, actualUpdatedLog);
ExchangeLogStatusType capturedExchangeLogStatusType = captorForExchangeLogStatusType.getValue();
assertEquals(logGuid, capturedExchangeLogStatusType.getGuid());
assertEquals(1, capturedExchangeLogStatusType.getHistory().size());
assertEquals(status, capturedExchangeLogStatusType.getHistory().get(0).getStatus());
}
use of eu.europa.ec.fisheries.schema.exchange.v1.ExchangeLogType 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);
}
}
use of eu.europa.ec.fisheries.schema.exchange.v1.ExchangeLogType in project UVMS-ExchangeModule-APP by UnionVMS.
the class ExchangeEventIncomingServiceBean method receiveSalesReport.
@Override
public void receiveSalesReport(@Observes @ReceiveSalesReportEvent ExchangeMessageEvent event) {
try {
ReceiveSalesReportRequest request = JAXBMarshaller.unmarshallTextMessage(event.getJmsMessage(), ReceiveSalesReportRequest.class);
log.info("Receive sales report in Exchange module:{}", request);
String report = request.getReport();
PluginType plugin = request.getPluginType();
String sender = request.getSenderOrReceiver();
String messageGuid = request.getMessageGuid();
ExchangeLogType log = exchangeLog.log(request, LogType.RECEIVE_SALES_REPORT, ExchangeLogStatusTypeType.ISSUED, TypeRefType.SALES_REPORT, report, true);
forwardToRules(RulesModuleRequestMapper.createReceiveSalesReportRequest(report, messageGuid, plugin.name(), log.getGuid(), sender, request.getOnValue()));
} catch (ExchangeModelMarshallException e) {
try {
String errorMessage = "Couldn't map to SetSalesReportRequest when processing sales report from plugin. The event was " + event.getJmsMessage().getText();
firePluginFault(event, errorMessage, e);
} catch (JMSException e1) {
firePluginFault(event, "Couldn't map to SetSalesReportRequest when processing sales report from plugin.", e);
}
} catch (ExchangeLogException e) {
firePluginFault(event, "Could not log the incoming sales report.", e);
} catch (RulesModelMarshallException e) {
firePluginFault(event, "Could not create a request for the Rules module for an incoming sales report.", e);
}
}
use of eu.europa.ec.fisheries.schema.exchange.v1.ExchangeLogType in project UVMS-ExchangeModule-APP by UnionVMS.
the class ExchangeEventIncomingServiceBean method handleProcessedMovement.
// Async response handler for processed movements
@Override
public void handleProcessedMovement(@Observes @HandleProcessedMovementEvent ExchangeMessageEvent message) {
try {
ProcessedMovementResponse request = JAXBMarshaller.unmarshallTextMessage(message.getJmsMessage(), ProcessedMovementResponse.class);
log.debug("Received processed movement from Rules:{}", request);
String username;
MovementRefType movementRefType = request.getMovementRefType();
SetReportMovementType orgRequest = request.getOrgRequest();
if (PluginType.MANUAL.equals(orgRequest.getPluginType())) {
username = request.getUsername();
} else {
username = orgRequest.getPluginName();
}
ExchangeLogType log = ExchangeLogMapper.getReceivedMovementExchangeLog(orgRequest, movementRefType.getMovementRefGuid(), movementRefType.getType().value(), username);
ExchangeLogType createdLog = exchangeLog.log(log, username);
LogRefType logTypeRef = createdLog.getTypeRef();
if (logTypeRef != null && logTypeRef.getType() == TypeRefType.POLL) {
String pollGuid = logTypeRef.getRefGuid();
pollEvent.fire(new NotificationMessage("guid", pollGuid));
}
} catch (ExchangeLogException | ExchangeModelMarshallException e) {
log.error(e.getMessage());
}
}
Aggregations