use of eu.europa.ec.fisheries.schema.exchange.v1.ExchangeLogStatusTypeType in project UVMS-ExchangeModule-APP by UnionVMS.
the class ExchangeEventIncomingServiceBean method updateLogStatus.
@Override
public void updateLogStatus(@Observes @UpdateLogStatusEvent ExchangeMessageEvent message) {
try {
UpdateLogStatusRequest request = JAXBMarshaller.unmarshallTextMessage(message.getJmsMessage(), UpdateLogStatusRequest.class);
String logGuid = request.getLogGuid();
ExchangeLogStatusTypeType status = request.getNewStatus();
exchangeLog.updateStatus(logGuid, status);
} catch (ExchangeLogException e) {
fireExchangeFault(message, "Could not update the status of a message log.", e);
} catch (ExchangeModelMarshallException e) {
fireExchangeFault(message, "Could not unmarshall the incoming UpdateLogStatus message", e);
}
}
use of eu.europa.ec.fisheries.schema.exchange.v1.ExchangeLogStatusTypeType 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.ExchangeLogStatusTypeType in project UVMS-ExchangeModule-APP by UnionVMS.
the class ExchangeEventIncomingServiceBean method sendSalesResponse.
@Override
public void sendSalesResponse(@Observes @SendSalesResponseEvent ExchangeMessageEvent message) {
try {
SendSalesResponseRequest request = JAXBMarshaller.unmarshallTextMessage(message.getJmsMessage(), SendSalesResponseRequest.class);
ExchangeLogStatusTypeType validationStatus = request.getValidationStatus();
exchangeLog.log(request, LogType.SEND_SALES_RESPONSE, validationStatus, TypeRefType.SALES_RESPONSE, request.getResponse(), false);
if (validationStatus == ExchangeLogStatusTypeType.SUCCESSFUL || validationStatus == ExchangeLogStatusTypeType.SUCCESSFUL_WITH_WARNINGS) {
eu.europa.ec.fisheries.schema.exchange.plugin.v1.SendSalesResponseRequest pluginRequest = new eu.europa.ec.fisheries.schema.exchange.plugin.v1.SendSalesResponseRequest();
pluginRequest.setRecipient(request.getSenderOrReceiver());
pluginRequest.setResponse(request.getResponse());
pluginRequest.setMethod(ExchangePluginMethod.SEND_SALES_RESPONSE);
exchangeEventOutgoingService.sendSalesResponseToPlugin(pluginRequest, request.getPluginType());
} else {
log.error("Received invalid response from the Sales module: " + request.getResponse());
}
} 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 response.", e);
}
}
use of eu.europa.ec.fisheries.schema.exchange.v1.ExchangeLogStatusTypeType 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.schema.exchange.v1.ExchangeLogStatusTypeType in project UVMS-ExchangeModule-APP by UnionVMS.
the class ExchangeLogServiceBean method createExchangeLogStatusType.
private ExchangeLogStatusType createExchangeLogStatusType(ExchangeLogStatusTypeType logStatus, String logGuid) {
ExchangeLogStatusType exchangeLogStatusType = new ExchangeLogStatusType();
exchangeLogStatusType.setGuid(logGuid);
ArrayList statusHistoryList = new ArrayList();
ExchangeLogStatusHistoryType statusHistory = new ExchangeLogStatusHistoryType();
statusHistory.setStatus(logStatus);
statusHistoryList.add(statusHistory);
exchangeLogStatusType.getHistory().addAll(statusHistoryList);
return exchangeLogStatusType;
}
Aggregations