use of eu.europa.ec.fisheries.uvms.exchange.service.exception.ExchangeLogException in project UVMS-ExchangeModule-APP by UnionVMS.
the class ExchangeLogMapper method getReceivedMovementExchangeLog.
public static ExchangeLogType getReceivedMovementExchangeLog(SetReportMovementType request, String typeRefGuid, String typeRefType, String username) throws ExchangeLogException {
if (request == null) {
throw new ExchangeLogException("No request");
}
ReceiveMovementType log = new ReceiveMovementType();
log.setDateRecieved(request.getTimestamp());
log.setType(LogType.RECEIVE_MOVEMENT);
LogRefType logRefType = new LogRefType();
logRefType.setRefGuid(typeRefGuid);
TypeRefType refType = TypeRefType.UNKNOWN;
try {
refType = TypeRefType.fromValue(typeRefType);
} catch (IllegalArgumentException e) {
LOG.error("Non existing typeRefType: " + typeRefType);
}
logRefType.setType(refType);
log.setTypeRef(logRefType);
log.setStatus(ExchangeLogStatusTypeType.SUCCESSFUL);
log.setSenderReceiver(getSenderReceiver(request.getMovement(), request.getPluginType(), request.getPluginName(), username));
if (request.getMovement().getSource() != null) {
log.setSource(request.getMovement().getSource().name());
} else {
log.setSource(request.getPluginType().name());
}
log.setRecipient(getRecipient(request.getMovement(), request.getPluginType()));
return log;
}
use of eu.europa.ec.fisheries.uvms.exchange.service.exception.ExchangeLogException in project UVMS-ExchangeModule-APP by UnionVMS.
the class ExchangeLogMapper method getRecipientOfPoll.
private static String getRecipientOfPoll(List<KeyValueType> pollReceiverList) throws ExchangeLogException {
if (pollReceiverList == null || pollReceiverList.isEmpty()) {
throw new ExchangeLogException("No poll receiver list");
}
String dnid = null;
String memberNumber = null;
String satelliteNumber = null;
String les = null;
for (KeyValueType pollReceiver : pollReceiverList) {
if (IdType.DNID.name().equalsIgnoreCase(pollReceiver.getKey())) {
dnid = pollReceiver.getValue();
} else if (IdType.MEMBER_NUMBER.name().equalsIgnoreCase(pollReceiver.getKey())) {
memberNumber = pollReceiver.getValue();
} else if (IdType.SERIAL_NUMBER.name().equalsIgnoreCase(pollReceiver.getKey())) {
satelliteNumber = pollReceiver.getValue();
} else if (IdType.LES.name().equalsIgnoreCase(pollReceiver.getKey())) {
les = pollReceiver.getValue();
}
}
if (dnid != null && memberNumber != null) {
return dnid + "." + memberNumber;
} else if (satelliteNumber != null) {
return satelliteNumber;
} else if (les != null) {
return les;
}
throw new ExchangeLogException("No receiver of poll");
}
use of eu.europa.ec.fisheries.uvms.exchange.service.exception.ExchangeLogException 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.uvms.exchange.service.exception.ExchangeLogException 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.uvms.exchange.service.exception.ExchangeLogException 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);
}
}
Aggregations