Search in sources :

Example 1 with RulesModelMarshallException

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

the class ExchangeEventIncomingServiceBean method receiveSalesReport.

@Override
public void receiveSalesReport(@Observes @ReceiveSalesReportEvent ExchangeMessageEvent event) {
    try {
        ReceiveSalesReportRequest request = JAXBMarshaller.unmarshallTextMessage(event.getJmsMessage(), ReceiveSalesReportRequest.class);
        log.info("Receive sales report in Exchange module:{}", request);
        String report = request.getReport();
        PluginType plugin = request.getPluginType();
        String sender = request.getSenderOrReceiver();
        String messageGuid = request.getMessageGuid();
        ExchangeLogType log = exchangeLog.log(request, LogType.RECEIVE_SALES_REPORT, ExchangeLogStatusTypeType.ISSUED, TypeRefType.SALES_REPORT, report, true);
        forwardToRules(RulesModuleRequestMapper.createReceiveSalesReportRequest(report, messageGuid, plugin.name(), log.getGuid(), sender, request.getOnValue()));
    } catch (ExchangeModelMarshallException e) {
        try {
            String errorMessage = "Couldn't map to SetSalesReportRequest when processing sales report from plugin. The event was " + event.getJmsMessage().getText();
            firePluginFault(event, errorMessage, e);
        } catch (JMSException e1) {
            firePluginFault(event, "Couldn't map to SetSalesReportRequest when processing sales report from plugin.", e);
        }
    } catch (ExchangeLogException e) {
        firePluginFault(event, "Could not log the incoming sales report.", e);
    } catch (RulesModelMarshallException e) {
        firePluginFault(event, "Could not create a request for the Rules module for an incoming sales report.", e);
    }
}
Also used : ExchangeModelMarshallException(eu.europa.ec.fisheries.uvms.exchange.model.exception.ExchangeModelMarshallException) RulesModelMarshallException(eu.europa.ec.fisheries.uvms.rules.model.exception.RulesModelMarshallException) ExchangeLogType(eu.europa.ec.fisheries.schema.exchange.v1.ExchangeLogType) ExchangeLogException(eu.europa.ec.fisheries.uvms.exchange.service.exception.ExchangeLogException) ReceiveSalesReportRequest(eu.europa.ec.fisheries.schema.exchange.module.v1.ReceiveSalesReportRequest) JMSException(javax.jms.JMSException) PluginType(eu.europa.ec.fisheries.schema.exchange.plugin.types.v1.PluginType)

Example 2 with RulesModelMarshallException

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

the class ExchangeEventIncomingServiceBean method receiveSalesQuery.

@Override
public void receiveSalesQuery(@Observes @ReceiveSalesQueryEvent ExchangeMessageEvent event) {
    try {
        ReceiveSalesQueryRequest request = JAXBMarshaller.unmarshallTextMessage(event.getJmsMessage(), ReceiveSalesQueryRequest.class);
        log.info("Process sales query in Exchange module:{}", request);
        String query = request.getQuery();
        PluginType plugin = request.getPluginType();
        String sender = request.getSenderOrReceiver();
        String messageGuid = request.getMessageGuid();
        ExchangeLogType log = exchangeLog.log(request, LogType.RECEIVE_SALES_QUERY, ExchangeLogStatusTypeType.ISSUED, TypeRefType.SALES_QUERY, query, true);
        forwardToRules(RulesModuleRequestMapper.createReceiveSalesQueryRequest(query, messageGuid, plugin.name(), log.getGuid(), sender, request.getOnValue()));
    } catch (ExchangeModelMarshallException e) {
        try {
            firePluginFault(event, "Couldn't map to SalesQueryRequest when processing sales query from plugin. The message was " + event.getJmsMessage().getText(), e);
        } catch (JMSException e1) {
            firePluginFault(event, "Couldn't map to SalesQueryRequest when processing sales query from plugin.", e);
        }
    } catch (ExchangeLogException e) {
        firePluginFault(event, "Could not log the incoming sales query.", e);
    } catch (RulesModelMarshallException e) {
        firePluginFault(event, "Could not create a request for the Rules module for an incoming sales query.", e);
    }
}
Also used : ExchangeModelMarshallException(eu.europa.ec.fisheries.uvms.exchange.model.exception.ExchangeModelMarshallException) RulesModelMarshallException(eu.europa.ec.fisheries.uvms.rules.model.exception.RulesModelMarshallException) ReceiveSalesQueryRequest(eu.europa.ec.fisheries.schema.exchange.module.v1.ReceiveSalesQueryRequest) ExchangeLogType(eu.europa.ec.fisheries.schema.exchange.v1.ExchangeLogType) ExchangeLogException(eu.europa.ec.fisheries.uvms.exchange.service.exception.ExchangeLogException) JMSException(javax.jms.JMSException) PluginType(eu.europa.ec.fisheries.schema.exchange.plugin.types.v1.PluginType)

Example 3 with RulesModelMarshallException

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

the class ExchangeEventIncomingServiceBean method receiveSalesResponse.

@Override
public void receiveSalesResponse(@Observes @ReceiveSalesResponseEvent ExchangeMessageEvent event) {
    try {
        ReceiveSalesResponseRequest request = JAXBMarshaller.unmarshallTextMessage(event.getJmsMessage(), ReceiveSalesResponseRequest.class);
        String response = request.getResponse();
        ExchangeLogType log = exchangeLog.log(request, LogType.RECEIVE_SALES_RESPONSE, ExchangeLogStatusTypeType.ISSUED, TypeRefType.SALES_RESPONSE, response, true);
        forwardToRules(RulesModuleRequestMapper.createReceiveSalesResponseRequest(response, log.getGuid(), request.getSenderOrReceiver()));
    } catch (ExchangeModelMarshallException e) {
        firePluginFault(event, "Error when receiving a Sales response from FLUX", e);
    } catch (ExchangeLogException e) {
        firePluginFault(event, "Could not log the incoming sales response.", e);
    } catch (RulesModelMarshallException e) {
        firePluginFault(event, "Could not create a request for the Rules module for an incoming sales response.", e);
    }
}
Also used : ExchangeModelMarshallException(eu.europa.ec.fisheries.uvms.exchange.model.exception.ExchangeModelMarshallException) ReceiveSalesResponseRequest(eu.europa.ec.fisheries.schema.exchange.module.v1.ReceiveSalesResponseRequest) RulesModelMarshallException(eu.europa.ec.fisheries.uvms.rules.model.exception.RulesModelMarshallException) ExchangeLogType(eu.europa.ec.fisheries.schema.exchange.v1.ExchangeLogType) ExchangeLogException(eu.europa.ec.fisheries.uvms.exchange.service.exception.ExchangeLogException)

Example 4 with RulesModelMarshallException

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

the class ExchangeToRulesSyncMsgBean method getValidationFromRules.

public ExchangeLogWithValidationResults getValidationFromRules(String guid, TypeRefType type) {
    if (StringUtils.isEmpty(guid)) {
        return new ExchangeLogWithValidationResults();
    }
    ExchangeLogWithValidationResults resp = new ExchangeLogWithValidationResults();
    try {
        String getValidationsByGuidRequest = RulesModuleRequestMapper.createGetValidationsByGuidRequest(guid, type == null ? null : type.name());
        String correlationId = exchangeProducerBean.sendRulesMessage(getValidationsByGuidRequest);
        TextMessage validationRespMsg = exchangeConsumerBean.getMessage(correlationId, TextMessage.class);
        ValidationMessageTypeResponse validTypeRespFromRules = JAXBMarshaller.unmarshallTextMessage(validationRespMsg, ValidationMessageTypeResponse.class);
        List<ValidationMessageType> validationsListResponse = validTypeRespFromRules.getValidationsListResponse();
        if (CollectionUtils.isNotEmpty(validationsListResponse)) {
            for (ValidationMessageType validMsgFromRules : validationsListResponse) {
                resp.getValidationList().add(mapToLogValidationResult(validMsgFromRules));
            }
        }
    } catch (ConfigMessageException | MessageException | RulesModelMarshallException | ExchangeModelMarshallException e) {
        log.error("Error while trying to get Validation Results for RawMessage GUID from Rules!", e);
    }
    return resp;
}
Also used : ConfigMessageException(eu.europa.ec.fisheries.uvms.config.exception.ConfigMessageException) ExchangeModelMarshallException(eu.europa.ec.fisheries.uvms.exchange.model.exception.ExchangeModelMarshallException) RulesModelMarshallException(eu.europa.ec.fisheries.uvms.rules.model.exception.RulesModelMarshallException) MessageException(eu.europa.ec.fisheries.uvms.commons.message.api.MessageException) ConfigMessageException(eu.europa.ec.fisheries.uvms.config.exception.ConfigMessageException) ValidationMessageTypeResponse(eu.europa.ec.fisheries.schema.rules.rule.v1.ValidationMessageTypeResponse) ValidationMessageType(eu.europa.ec.fisheries.schema.rules.rule.v1.ValidationMessageType) ExchangeLogWithValidationResults(eu.europa.ec.fisheries.schema.exchange.v1.ExchangeLogWithValidationResults) TextMessage(javax.jms.TextMessage)

Aggregations

ExchangeModelMarshallException (eu.europa.ec.fisheries.uvms.exchange.model.exception.ExchangeModelMarshallException)4 RulesModelMarshallException (eu.europa.ec.fisheries.uvms.rules.model.exception.RulesModelMarshallException)4 ExchangeLogType (eu.europa.ec.fisheries.schema.exchange.v1.ExchangeLogType)3 ExchangeLogException (eu.europa.ec.fisheries.uvms.exchange.service.exception.ExchangeLogException)3 PluginType (eu.europa.ec.fisheries.schema.exchange.plugin.types.v1.PluginType)2 JMSException (javax.jms.JMSException)2 ReceiveSalesQueryRequest (eu.europa.ec.fisheries.schema.exchange.module.v1.ReceiveSalesQueryRequest)1 ReceiveSalesReportRequest (eu.europa.ec.fisheries.schema.exchange.module.v1.ReceiveSalesReportRequest)1 ReceiveSalesResponseRequest (eu.europa.ec.fisheries.schema.exchange.module.v1.ReceiveSalesResponseRequest)1 ExchangeLogWithValidationResults (eu.europa.ec.fisheries.schema.exchange.v1.ExchangeLogWithValidationResults)1 ValidationMessageType (eu.europa.ec.fisheries.schema.rules.rule.v1.ValidationMessageType)1 ValidationMessageTypeResponse (eu.europa.ec.fisheries.schema.rules.rule.v1.ValidationMessageTypeResponse)1 MessageException (eu.europa.ec.fisheries.uvms.commons.message.api.MessageException)1 ConfigMessageException (eu.europa.ec.fisheries.uvms.config.exception.ConfigMessageException)1 TextMessage (javax.jms.TextMessage)1