Search in sources :

Example 1 with ExchangeLogStatusTypeType

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);
    }
}
Also used : ExchangeModelMarshallException(eu.europa.ec.fisheries.uvms.exchange.model.exception.ExchangeModelMarshallException) UpdateLogStatusRequest(eu.europa.ec.fisheries.schema.exchange.module.v1.UpdateLogStatusRequest) ExchangeLogStatusTypeType(eu.europa.ec.fisheries.schema.exchange.v1.ExchangeLogStatusTypeType) ExchangeLogException(eu.europa.ec.fisheries.uvms.exchange.service.exception.ExchangeLogException)

Example 2 with ExchangeLogStatusTypeType

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());
    }
}
Also used : NotificationMessage(eu.europa.ec.fisheries.uvms.longpolling.notifications.NotificationMessage) ExchangeLogStatusTypeType(eu.europa.ec.fisheries.schema.exchange.v1.ExchangeLogStatusTypeType) ExchangeLogException(eu.europa.ec.fisheries.uvms.exchange.service.exception.ExchangeLogException) ExchangeLogType(eu.europa.ec.fisheries.schema.exchange.v1.ExchangeLogType) LogRefType(eu.europa.ec.fisheries.schema.exchange.v1.LogRefType)

Example 3 with ExchangeLogStatusTypeType

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);
    }
}
Also used : ExchangeLogStatusTypeType(eu.europa.ec.fisheries.schema.exchange.v1.ExchangeLogStatusTypeType) ExchangeMessageException(eu.europa.ec.fisheries.uvms.exchange.message.exception.ExchangeMessageException) ExchangeModelMarshallException(eu.europa.ec.fisheries.uvms.exchange.model.exception.ExchangeModelMarshallException) SendSalesResponseRequest(eu.europa.ec.fisheries.schema.exchange.module.v1.SendSalesResponseRequest) ExchangeLogException(eu.europa.ec.fisheries.uvms.exchange.service.exception.ExchangeLogException)

Example 4 with ExchangeLogStatusTypeType

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.");
    }
}
Also used : ExchangeLogStatusType(eu.europa.ec.fisheries.schema.exchange.v1.ExchangeLogStatusType) ExchangeLogStatusTypeType(eu.europa.ec.fisheries.schema.exchange.v1.ExchangeLogStatusTypeType) TypeRefType(eu.europa.ec.fisheries.schema.exchange.v1.TypeRefType) ExchangeLogException(eu.europa.ec.fisheries.uvms.exchange.service.exception.ExchangeLogException) ArrayList(java.util.ArrayList) ExchangeModelException(eu.europa.ec.fisheries.uvms.exchange.model.exception.ExchangeModelException) ExchangeHistoryListQuery(eu.europa.ec.fisheries.schema.exchange.v1.ExchangeHistoryListQuery)

Example 5 with ExchangeLogStatusTypeType

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;
}
Also used : ExchangeLogStatusType(eu.europa.ec.fisheries.schema.exchange.v1.ExchangeLogStatusType) ExchangeLogStatusHistoryType(eu.europa.ec.fisheries.schema.exchange.v1.ExchangeLogStatusHistoryType) ArrayList(java.util.ArrayList)

Aggregations

ExchangeLogStatusTypeType (eu.europa.ec.fisheries.schema.exchange.v1.ExchangeLogStatusTypeType)27 ExchangeLogType (eu.europa.ec.fisheries.schema.exchange.v1.ExchangeLogType)21 ExchangeLog (eu.europa.ec.fisheries.uvms.exchange.entity.exchangelog.ExchangeLog)21 Test (org.junit.Test)21 Date (java.util.Date)20 LogRefType (eu.europa.ec.fisheries.schema.exchange.v1.LogRefType)11 TypeRefType (eu.europa.ec.fisheries.schema.exchange.v1.TypeRefType)10 ExchangeLogException (eu.europa.ec.fisheries.uvms.exchange.service.exception.ExchangeLogException)7 ExchangeLogStatusType (eu.europa.ec.fisheries.schema.exchange.v1.ExchangeLogStatusType)4 ExchangeModelException (eu.europa.ec.fisheries.uvms.exchange.model.exception.ExchangeModelException)3 ExchangeModelMarshallException (eu.europa.ec.fisheries.uvms.exchange.model.exception.ExchangeModelMarshallException)3 NotificationMessage (eu.europa.ec.fisheries.uvms.longpolling.notifications.NotificationMessage)3 ArrayList (java.util.ArrayList)3 ExchangeMessageException (eu.europa.ec.fisheries.uvms.exchange.message.exception.ExchangeMessageException)2 SendSalesReportRequest (eu.europa.ec.fisheries.schema.exchange.module.v1.SendSalesReportRequest)1 SendSalesResponseRequest (eu.europa.ec.fisheries.schema.exchange.module.v1.SendSalesResponseRequest)1 UpdateLogStatusRequest (eu.europa.ec.fisheries.schema.exchange.module.v1.UpdateLogStatusRequest)1 ExchangeHistoryListQuery (eu.europa.ec.fisheries.schema.exchange.v1.ExchangeHistoryListQuery)1 ExchangeLogStatusHistoryType (eu.europa.ec.fisheries.schema.exchange.v1.ExchangeLogStatusHistoryType)1 PollStatus (eu.europa.ec.fisheries.schema.exchange.v1.PollStatus)1