Search in sources :

Example 1 with ExchangeModelException

use of eu.europa.ec.fisheries.uvms.exchange.model.exception.ExchangeModelException in project UVMS-ExchangeModule-APP by UnionVMS.

the class ExchangeEventIncomingServiceBean method logRefIdByTypeExists.

@Override
public void logRefIdByTypeExists(@Observes @LogRefIdByTypeExists ExchangeMessageEvent event) {
    try {
        LogRefIdByTypeExistsRequest request = unMarshallMessage(event.getJmsMessage().getText(), LogRefIdByTypeExistsRequest.class);
        String refGuid = request.getRefGuid();
        List<TypeRefType> refTypes = request.getRefTypes();
        List<ExchangeLogStatusType> exchangeStatusHistoryList = exchangeLogModel.getExchangeLogsStatusHistories(refGuid, refTypes);
        LogRefIdByTypeExistsResponse response = new LogRefIdByTypeExistsResponse();
        if (CollectionUtils.isNotEmpty(exchangeStatusHistoryList)) {
            response.setRefGuid(exchangeStatusHistoryList.get(0).getTypeRef().getRefGuid());
        }
        String responseAsString = JAXBUtils.marshallJaxBObjectToString(response);
        producer.sendModuleResponseMessage(event.getJmsMessage(), responseAsString);
    } catch (ExchangeModelException | JAXBException | JMSException e) {
        fireExchangeFault(event, "Could not un-marshall " + LogRefIdByTypeExistsRequest.class, e);
    }
}
Also used : ExchangeLogStatusType(eu.europa.ec.fisheries.schema.exchange.v1.ExchangeLogStatusType) LogRefIdByTypeExistsRequest(eu.europa.ec.fisheries.schema.exchange.module.v1.LogRefIdByTypeExistsRequest) TypeRefType(eu.europa.ec.fisheries.schema.exchange.v1.TypeRefType) LogRefIdByTypeExistsResponse(eu.europa.ec.fisheries.schema.exchange.module.v1.LogRefIdByTypeExistsResponse) JAXBException(javax.xml.bind.JAXBException) ExchangeModelException(eu.europa.ec.fisheries.uvms.exchange.model.exception.ExchangeModelException) JMSException(javax.jms.JMSException)

Example 2 with ExchangeModelException

use of eu.europa.ec.fisheries.uvms.exchange.model.exception.ExchangeModelException in project UVMS-ExchangeModule-APP by UnionVMS.

the class ExchangeEventIncomingServiceBean method logIdByTypeExists.

@Override
public void logIdByTypeExists(@Observes @LogIdByTypeExists ExchangeMessageEvent event) {
    try {
        LogIdByTypeExistsRequest request = unMarshallMessage(event.getJmsMessage().getText(), LogIdByTypeExistsRequest.class);
        String messageGuid = request.getMessageGuid();
        TypeRefType refType = request.getRefType();
        ExchangeLogType exchangeLogByGuid = exchangeLogModel.getExchangeLogByGuidAndType(messageGuid, refType);
        LogIdByTypeExistsResponse response = new LogIdByTypeExistsResponse();
        if (exchangeLogByGuid != null) {
            response.setMessageGuid(exchangeLogByGuid.getGuid());
        }
        String responseAsString = JAXBUtils.marshallJaxBObjectToString(response);
        producer.sendModuleResponseMessage(event.getJmsMessage(), responseAsString);
    } catch (ExchangeModelException | JAXBException | JMSException e) {
        fireExchangeFault(event, "Could not un-marshall " + LogRefIdByTypeExistsRequest.class, e);
    }
}
Also used : TypeRefType(eu.europa.ec.fisheries.schema.exchange.v1.TypeRefType) LogIdByTypeExistsResponse(eu.europa.ec.fisheries.schema.exchange.module.v1.LogIdByTypeExistsResponse) ExchangeLogType(eu.europa.ec.fisheries.schema.exchange.v1.ExchangeLogType) JAXBException(javax.xml.bind.JAXBException) ExchangeModelException(eu.europa.ec.fisheries.uvms.exchange.model.exception.ExchangeModelException) JMSException(javax.jms.JMSException) LogIdByTypeExistsRequest(eu.europa.ec.fisheries.schema.exchange.module.v1.LogIdByTypeExistsRequest)

Example 3 with ExchangeModelException

use of eu.europa.ec.fisheries.uvms.exchange.model.exception.ExchangeModelException 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 4 with ExchangeModelException

use of eu.europa.ec.fisheries.uvms.exchange.model.exception.ExchangeModelException 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 5 with ExchangeModelException

use of eu.europa.ec.fisheries.uvms.exchange.model.exception.ExchangeModelException 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)

Aggregations

ExchangeModelException (eu.europa.ec.fisheries.uvms.exchange.model.exception.ExchangeModelException)28 ExchangeDaoException (eu.europa.ec.fisheries.uvms.exchange.exception.ExchangeDaoException)12 InputArgumentException (eu.europa.ec.fisheries.uvms.exchange.model.exception.InputArgumentException)10 ExchangeLogType (eu.europa.ec.fisheries.schema.exchange.v1.ExchangeLogType)9 ExchangeLogException (eu.europa.ec.fisheries.uvms.exchange.service.exception.ExchangeLogException)8 ExchangeLog (eu.europa.ec.fisheries.uvms.exchange.entity.exchangelog.ExchangeLog)7 NotificationMessage (eu.europa.ec.fisheries.uvms.longpolling.notifications.NotificationMessage)6 ArrayList (java.util.ArrayList)6 ExchangeLogStatusType (eu.europa.ec.fisheries.schema.exchange.v1.ExchangeLogStatusType)5 ServiceResponseType (eu.europa.ec.fisheries.schema.exchange.service.v1.ServiceResponseType)4 TypeRefType (eu.europa.ec.fisheries.schema.exchange.v1.TypeRefType)4 UnsentMessageType (eu.europa.ec.fisheries.schema.exchange.v1.UnsentMessageType)4 ExchangeServiceException (eu.europa.ec.fisheries.uvms.exchange.service.exception.ExchangeServiceException)4 ExchangeLogStatus (eu.europa.ec.fisheries.uvms.exchange.entity.exchangelog.ExchangeLogStatus)3 UnsentMessage (eu.europa.ec.fisheries.uvms.exchange.entity.unsent.UnsentMessage)3 ExchangeSearchMapperException (eu.europa.ec.fisheries.uvms.exchange.model.exception.ExchangeSearchMapperException)3 ParseException (java.text.ParseException)3 ListResponseDto (eu.europa.ec.fisheries.uvms.exchange.model.dto.ListResponseDto)2 ExchangeModelMapperException (eu.europa.ec.fisheries.uvms.exchange.model.exception.ExchangeModelMapperException)2 JMSException (javax.jms.JMSException)2