Search in sources :

Example 11 with ExchangeLogException

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

Example 12 with ExchangeLogException

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.");
    }
}
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 13 with ExchangeLogException

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.");
    }
}
Also used : GetLogListByQueryResponse(eu.europa.ec.fisheries.schema.exchange.source.v1.GetLogListByQueryResponse) ExchangeLogException(eu.europa.ec.fisheries.uvms.exchange.service.exception.ExchangeLogException) ExchangeModelException(eu.europa.ec.fisheries.uvms.exchange.model.exception.ExchangeModelException) ListResponseDto(eu.europa.ec.fisheries.uvms.exchange.model.dto.ListResponseDto)

Example 14 with ExchangeLogException

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);
            }
        }
    }
}
Also used : UnsentMessageType(eu.europa.ec.fisheries.schema.exchange.v1.UnsentMessageType) NotificationMessage(eu.europa.ec.fisheries.uvms.longpolling.notifications.NotificationMessage) ExchangeLogException(eu.europa.ec.fisheries.uvms.exchange.service.exception.ExchangeLogException) ExchangeMessageException(eu.europa.ec.fisheries.uvms.exchange.message.exception.ExchangeMessageException) ExchangeModelException(eu.europa.ec.fisheries.uvms.exchange.model.exception.ExchangeModelException)

Example 15 with ExchangeLogException

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

Aggregations

ExchangeLogException (eu.europa.ec.fisheries.uvms.exchange.service.exception.ExchangeLogException)33 ExchangeModelMarshallException (eu.europa.ec.fisheries.uvms.exchange.model.exception.ExchangeModelMarshallException)15 ExchangeLogType (eu.europa.ec.fisheries.schema.exchange.v1.ExchangeLogType)14 NotificationMessage (eu.europa.ec.fisheries.uvms.longpolling.notifications.NotificationMessage)9 ExchangeModelException (eu.europa.ec.fisheries.uvms.exchange.model.exception.ExchangeModelException)8 ExchangeMessageException (eu.europa.ec.fisheries.uvms.exchange.message.exception.ExchangeMessageException)7 JMSException (javax.jms.JMSException)6 ExchangeLogStatusTypeType (eu.europa.ec.fisheries.schema.exchange.v1.ExchangeLogStatusTypeType)5 LogRefType (eu.europa.ec.fisheries.schema.exchange.v1.LogRefType)5 PluginType (eu.europa.ec.fisheries.schema.exchange.plugin.types.v1.PluginType)4 RulesModelMapperException (eu.europa.ec.fisheries.uvms.rules.model.exception.RulesModelMapperException)4 ServiceResponseType (eu.europa.ec.fisheries.schema.exchange.service.v1.ServiceResponseType)3 UnsentMessageTypeProperty (eu.europa.ec.fisheries.schema.exchange.v1.UnsentMessageTypeProperty)3 RulesModelMarshallException (eu.europa.ec.fisheries.uvms.rules.model.exception.RulesModelMarshallException)3 ArrayList (java.util.ArrayList)3 AcknowledgeType (eu.europa.ec.fisheries.schema.exchange.common.v1.AcknowledgeType)2 SetFAQueryMessageRequest (eu.europa.ec.fisheries.schema.exchange.module.v1.SetFAQueryMessageRequest)2 SetFLUXFAReportMessageRequest (eu.europa.ec.fisheries.schema.exchange.module.v1.SetFLUXFAReportMessageRequest)2 SetReportMovementType (eu.europa.ec.fisheries.schema.exchange.movement.v1.SetReportMovementType)2 ExchangeLogStatusType (eu.europa.ec.fisheries.schema.exchange.v1.ExchangeLogStatusType)2