use of eu.europa.ec.fisheries.uvms.exchange.service.exception.ExchangeLogException 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);
}
}
use of eu.europa.ec.fisheries.uvms.exchange.service.exception.ExchangeLogException in project UVMS-ExchangeModule-APP by UnionVMS.
the class ExchangeLogServiceBean method getExchangeStatusHistoryList.
@Override
public List<ExchangeLogStatusType> getExchangeStatusHistoryList(ExchangeLogStatusTypeType status, TypeRefType type, Date from, Date to) throws ExchangeLogException {
log.info("Get pollstatus list in service layer:{}", status);
try {
List<ExchangeLogStatusTypeType> statusList = new ArrayList<>();
if (status != null) {
statusList.add(status);
}
List<TypeRefType> typeList = new ArrayList<>();
if (type != null) {
typeList.add(type);
}
ExchangeHistoryListQuery query = new ExchangeHistoryListQuery();
query.setTypeRefDateFrom(from);
query.setTypeRefDateTo(to);
query.getStatus().addAll(statusList);
query.getType().addAll(typeList);
List<ExchangeLogStatusType> pollStatusList = exchangeLogModel.getExchangeLogStatusHistoryByQuery(query);
return pollStatusList;
} catch (ExchangeModelException e) {
throw new ExchangeLogException("Couldn't get exchange status history list.");
}
}
use of eu.europa.ec.fisheries.uvms.exchange.service.exception.ExchangeLogException in project UVMS-ExchangeModule-APP by UnionVMS.
the class ExchangeLogServiceBean method getExchangeLogList.
@Override
public GetLogListByQueryResponse getExchangeLogList(ExchangeListQuery query) throws ExchangeLogException {
GetLogListByQueryResponse response = new GetLogListByQueryResponse();
try {
ListResponseDto exchangeLogList = exchangeLogModel.getExchangeLogListByQuery(query);
response.setCurrentPage(exchangeLogList.getCurrentPage());
response.setTotalNumberOfPages(exchangeLogList.getTotalNumberOfPages());
response.getExchangeLog().addAll(exchangeLogList.getExchangeLogList());
return response;
} catch (ExchangeModelException e) {
throw new ExchangeLogException("Couldn't get exchange log list.");
}
}
use of eu.europa.ec.fisheries.uvms.exchange.service.exception.ExchangeLogException in project UVMS-ExchangeModule-APP by UnionVMS.
the class ExchangeLogServiceBean method resend.
@Override
public void resend(List<String> messageIdList, String username) throws ExchangeLogException {
log.debug("resend in service layer:{} {}", messageIdList, username);
List<UnsentMessageType> unsentMessageList;
try {
unsentMessageList = unsentModel.resend(messageIdList);
sendAuditLogMessageForResendUnsentMessage(messageIdList.toString(), username);
} catch (ExchangeModelException e) {
log.error("Couldn't read unsent messages", e);
throw new ExchangeLogException("Couldn't read unsent messages");
}
if (unsentMessageList != null && !unsentMessageList.isEmpty()) {
sendingQueueEvent.fire(new NotificationMessage("messageIds", messageIdList));
for (UnsentMessageType unsentMessage : unsentMessageList) {
try {
String unsentMessageId = producer.sendMessageOnQueue(unsentMessage.getMessage(), MessageQueue.EVENT);
// TextMessage unsentResponse = consumer.getMessage(unsentMessageId, TextMessage.class);
sendAuditLogMessageForCreateUnsentMessage(unsentMessageId, username);
// ExchangeModuleResponseMapper.validateResponse(unsentResponse, unsentMessageId);
} catch (ExchangeMessageException e) {
log.error("Error when sending/receiving message {} {}", messageIdList, e);
}
}
}
}
use of eu.europa.ec.fisheries.uvms.exchange.service.exception.ExchangeLogException in project UVMS-ExchangeModule-APP by UnionVMS.
the class ExchangeLogMapper method getSendMovementExchangeLog.
public static ExchangeLogType getSendMovementExchangeLog(SendMovementToPluginType sendReport) throws ExchangeLogException {
if (sendReport == null) {
throw new ExchangeLogException("No request");
}
SendMovementType log = new SendMovementType();
log.setDateRecieved(sendReport.getTimestamp());
log.setType(LogType.SEND_MOVEMENT);
LogRefType logRefType = new LogRefType();
logRefType.setRefGuid(sendReport.getMovement().getGuid());
logRefType.setType(TypeRefType.MOVEMENT);
log.setTypeRef(logRefType);
String senderReceiver = getSendMovementSenderReceiver(sendReport);
log.setSenderReceiver(senderReceiver);
// TODO send fwdDate, fwdRule and recipient from Rules
log.setFwdDate(sendReport.getFwdDate());
log.setFwdRule(sendReport.getFwdRule());
log.setRecipient(sendReport.getRecipient());
return log;
}
Aggregations