Search in sources :

Example 21 with ExchangeModelMarshallException

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

the class ExchangeEventIncomingServiceBean method sendSalesReport.

@Override
public void sendSalesReport(@Observes @SendSalesReportEvent ExchangeMessageEvent message) {
    try {
        SendSalesReportRequest request = JAXBMarshaller.unmarshallTextMessage(message.getJmsMessage(), SendSalesReportRequest.class);
        ExchangeLogStatusTypeType validationStatus = request.getValidationStatus();
        exchangeLog.log(request, LogType.SEND_SALES_REPORT, validationStatus, TypeRefType.SALES_REPORT, request.getReport(), false);
        if (validationStatus == ExchangeLogStatusTypeType.SUCCESSFUL || validationStatus == ExchangeLogStatusTypeType.SUCCESSFUL_WITH_WARNINGS) {
            eu.europa.ec.fisheries.schema.exchange.plugin.v1.SendSalesReportRequest pluginRequest = new eu.europa.ec.fisheries.schema.exchange.plugin.v1.SendSalesReportRequest();
            pluginRequest.setRecipient(request.getSenderOrReceiver());
            pluginRequest.setReport(request.getReport());
            if (request.getSenderOrReceiver() != null) {
                pluginRequest.setSenderOrReceiver(request.getSenderOrReceiver());
            }
            pluginRequest.setMethod(ExchangePluginMethod.SEND_SALES_RESPONSE);
            exchangeEventOutgoingService.sendSalesReportToFLUX(pluginRequest);
        } else {
            log.error("Received invalid report from the Sales module: " + request.getReport());
        }
    } 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 report.", e);
    }
}
Also used : ExchangeLogStatusTypeType(eu.europa.ec.fisheries.schema.exchange.v1.ExchangeLogStatusTypeType) SendSalesReportRequest(eu.europa.ec.fisheries.schema.exchange.module.v1.SendSalesReportRequest) ExchangeMessageException(eu.europa.ec.fisheries.uvms.exchange.message.exception.ExchangeMessageException) ExchangeModelMarshallException(eu.europa.ec.fisheries.uvms.exchange.model.exception.ExchangeModelMarshallException) ExchangeLogException(eu.europa.ec.fisheries.uvms.exchange.service.exception.ExchangeLogException)

Example 22 with ExchangeModelMarshallException

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

the class ExchangeEventIncomingServiceBean method ping.

@Override
public void ping(@Observes @PingEvent ExchangeMessageEvent message) {
    try {
        PingResponse response = new PingResponse();
        response.setResponse("pong");
        producer.sendModuleResponseMessage(message.getJmsMessage(), JAXBMarshaller.marshallJaxBObjectToString(response));
    } catch (ExchangeModelMarshallException e) {
        log.error("[ Error when marshalling ping response ]");
    }
}
Also used : ExchangeModelMarshallException(eu.europa.ec.fisheries.uvms.exchange.model.exception.ExchangeModelMarshallException) PingResponse(eu.europa.ec.fisheries.schema.exchange.module.v1.PingResponse)

Example 23 with ExchangeModelMarshallException

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

Example 24 with ExchangeModelMarshallException

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

the class PluginServiceBean method setConfig.

@Override
public void setConfig(@Observes @ConfigSettingUpdatedEvent ConfigSettingEvent settingEvent) {
    switch(settingEvent.getType()) {
        case STORE:
            // ConfigModule and/or Exchange module deployed
            break;
        case UPDATE:
            LOG.info("ConfigModule updated parameter table with settings of plugins");
            try {
                String key = settingEvent.getKey();
                String value = parameterService.getStringValue(key);
                String settingKey;
                String[] splittedKey = key.split(PARAMETER_DELIMETER);
                if (splittedKey.length > 2) {
                    settingKey = key;
                    String serviceClassName = "";
                    for (int i = 0; i < splittedKey.length - 2; i++) {
                        serviceClassName += splittedKey[i] + ".";
                    }
                    serviceClassName += splittedKey[splittedKey.length - 2];
                    SettingType settingType = new SettingType();
                    settingType.setKey(key);
                    settingType.setValue(value);
                    updatePluginSetting(serviceClassName, settingType, "UVMS");
                } else {
                    LOG.error("No key or malformed key sent in settingEvent: key: {}, value: {}", key, value);
                }
            } catch (ConfigServiceException e) {
                LOG.error("Couldn't get updated parameter table value");
            } catch (ExchangeServiceException e) {
                LOG.error("Couldn't upsert settings in exchange");
            } catch (ExchangeModelMarshallException e) {
                LOG.error("Couldn't create plugin set config request");
            } catch (ExchangeMessageException e) {
                LOG.error("Couldn't send message to plugin");
            }
            break;
        case DELETE:
            LOG.info("ConfigModule removed parameter setting");
            break;
    }
}
Also used : ExchangeModelMarshallException(eu.europa.ec.fisheries.uvms.exchange.model.exception.ExchangeModelMarshallException) ConfigServiceException(eu.europa.ec.fisheries.uvms.config.exception.ConfigServiceException) ExchangeMessageException(eu.europa.ec.fisheries.uvms.exchange.message.exception.ExchangeMessageException) SettingType(eu.europa.ec.fisheries.schema.exchange.service.v1.SettingType) ExchangeServiceException(eu.europa.ec.fisheries.uvms.exchange.service.exception.ExchangeServiceException)

Example 25 with ExchangeModelMarshallException

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

the class PluginServiceBean method unregisterService.

@Override
public void unregisterService(@Observes @UnRegisterServiceEvent PluginMessageEvent event) {
    LOG.info("unregister service:{}", event);
    TextMessage textMessage = event.getJmsMessage();
    ServiceResponseType service = null;
    try {
        UnregisterServiceRequest unregister = JAXBMarshaller.unmarshallTextMessage(textMessage, UnregisterServiceRequest.class);
        service = exchangeService.unregisterService(unregister.getService(), unregister.getService().getName());
        String serviceClassName = service.getServiceClassName();
    // NO ack back to plugin
    // TODO log to exchange log
    } catch (ExchangeModelMarshallException | ExchangeServiceException e) {
        LOG.error("Unregister service exception " + e.getMessage());
        errorEvent.fire(new PluginMessageEvent(textMessage, service, ExchangePluginResponseMapper.mapToPluginFaultResponse(FaultCode.EXCHANGE_PLUGIN_EVENT.getCode(), "Exception when unregister service")));
    }
}
Also used : ExchangeModelMarshallException(eu.europa.ec.fisheries.uvms.exchange.model.exception.ExchangeModelMarshallException) ServiceResponseType(eu.europa.ec.fisheries.schema.exchange.service.v1.ServiceResponseType) UnregisterServiceRequest(eu.europa.ec.fisheries.schema.exchange.registry.v1.UnregisterServiceRequest) PluginMessageEvent(eu.europa.ec.fisheries.uvms.exchange.message.event.carrier.PluginMessageEvent) TextMessage(javax.jms.TextMessage) ExchangeServiceException(eu.europa.ec.fisheries.uvms.exchange.service.exception.ExchangeServiceException)

Aggregations

ExchangeModelMarshallException (eu.europa.ec.fisheries.uvms.exchange.model.exception.ExchangeModelMarshallException)27 ExchangeLogException (eu.europa.ec.fisheries.uvms.exchange.service.exception.ExchangeLogException)15 ExchangeMessageException (eu.europa.ec.fisheries.uvms.exchange.message.exception.ExchangeMessageException)13 ExchangeLogType (eu.europa.ec.fisheries.schema.exchange.v1.ExchangeLogType)8 ExchangeServiceException (eu.europa.ec.fisheries.uvms.exchange.service.exception.ExchangeServiceException)8 TextMessage (javax.jms.TextMessage)7 RulesModelMapperException (eu.europa.ec.fisheries.uvms.rules.model.exception.RulesModelMapperException)4 RulesModelMarshallException (eu.europa.ec.fisheries.uvms.rules.model.exception.RulesModelMarshallException)4 JMSException (javax.jms.JMSException)4 PluginType (eu.europa.ec.fisheries.schema.exchange.plugin.types.v1.PluginType)3 ExchangeLogStatusTypeType (eu.europa.ec.fisheries.schema.exchange.v1.ExchangeLogStatusTypeType)3 PluginMessageEvent (eu.europa.ec.fisheries.uvms.exchange.message.event.carrier.PluginMessageEvent)3 InputArgumentException (eu.europa.ec.fisheries.uvms.exchange.service.exception.InputArgumentException)3 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 AcknowledgeResponse (eu.europa.ec.fisheries.schema.exchange.plugin.v1.AcknowledgeResponse)2 RegisterServiceRequest (eu.europa.ec.fisheries.schema.exchange.registry.v1.RegisterServiceRequest)2 UnregisterServiceRequest (eu.europa.ec.fisheries.schema.exchange.registry.v1.UnregisterServiceRequest)2 ServiceResponseType (eu.europa.ec.fisheries.schema.exchange.service.v1.ServiceResponseType)2