Search in sources :

Example 1 with RulesModelMapperException

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

the class ExchangeEventIncomingServiceBean method processFLUXFAReportMessage.

@Override
public void processFLUXFAReportMessage(@Observes @SetFluxFAReportMessageEvent ExchangeMessageEvent message) {
    try {
        SetFLUXFAReportMessageRequest request = JAXBMarshaller.unmarshallTextMessage(message.getJmsMessage(), SetFLUXFAReportMessageRequest.class);
        log.debug("Got FLUXFAReportMessage in exchange :" + request.getRequest());
        ExchangeLogType exchangeLogType = exchangeLog.log(request, LogType.RCV_FLUX_FA_REPORT_MSG, ExchangeLogStatusTypeType.ISSUED, TypeRefType.FA_REPORT, request.getRequest(), true);
        String msg = RulesModuleRequestMapper.createSetFLUXFAReportMessageRequest(extractPluginType(request), request.getRequest(), request.getUsername(), extractLogId(message, exchangeLogType), request.getFluxDataFlow(), request.getSenderOrReceiver(), request.getOnValue());
        forwardToRules(msg, message, null);
    } catch (RulesModelMapperException | ExchangeModelMarshallException e) {
        log.error("Couldn't map to SetFLUXFAReportMessageRequest when processing FLUXFAReportMessage coming from fa-plugin!", e);
    } catch (ExchangeLogException e) {
        log.error("Couldn't log FAReportMessage received from plugin into database", e);
    }
}
Also used : ExchangeModelMarshallException(eu.europa.ec.fisheries.uvms.exchange.model.exception.ExchangeModelMarshallException) ExchangeLogType(eu.europa.ec.fisheries.schema.exchange.v1.ExchangeLogType) ExchangeLogException(eu.europa.ec.fisheries.uvms.exchange.service.exception.ExchangeLogException) RulesModelMapperException(eu.europa.ec.fisheries.uvms.rules.model.exception.RulesModelMapperException) SetFLUXFAReportMessageRequest(eu.europa.ec.fisheries.schema.exchange.module.v1.SetFLUXFAReportMessageRequest)

Example 2 with RulesModelMapperException

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

the class ExchangeEventIncomingServiceBean method processFAQueryMessage.

@Override
public void processFAQueryMessage(@Observes @SetFaQueryMessageEvent ExchangeMessageEvent message) {
    try {
        SetFAQueryMessageRequest request = JAXBMarshaller.unmarshallTextMessage(message.getJmsMessage(), SetFAQueryMessageRequest.class);
        log.debug("Got FAQueryMessage in exchange :" + request.getRequest());
        ExchangeLogType exchangeLogType = exchangeLog.log(request, LogType.RECEIVE_FA_QUERY_MSG, ExchangeLogStatusTypeType.ISSUED, TypeRefType.FA_QUERY, request.getRequest(), true);
        String msg = RulesModuleRequestMapper.createSetFaQueryMessageRequest(extractPluginType(request), request.getRequest(), request.getUsername(), extractLogId(message, exchangeLogType), request.getFluxDataFlow(), request.getSenderOrReceiver(), request.getOnValue());
        forwardToRules(msg, message, null);
    } catch (RulesModelMapperException | ExchangeModelMarshallException e) {
        log.error("Couldn't map to SetFAQueryMessageRequest when processing FAQueryMessage coming from fa-plugin!", e);
    } catch (ExchangeLogException e) {
        log.error("Couldn't log FAQueryMessage received from plugin into database", e);
    }
}
Also used : ExchangeModelMarshallException(eu.europa.ec.fisheries.uvms.exchange.model.exception.ExchangeModelMarshallException) SetFAQueryMessageRequest(eu.europa.ec.fisheries.schema.exchange.module.v1.SetFAQueryMessageRequest) ExchangeLogType(eu.europa.ec.fisheries.schema.exchange.v1.ExchangeLogType) ExchangeLogException(eu.europa.ec.fisheries.uvms.exchange.service.exception.ExchangeLogException) RulesModelMapperException(eu.europa.ec.fisheries.uvms.rules.model.exception.RulesModelMapperException)

Example 3 with RulesModelMapperException

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

the class ExchangeEventIncomingServiceBean method processMovement.

@Override
public void processMovement(@Observes @SetMovementEvent ExchangeMessageEvent message) {
    try {
        final TextMessage jmsMessage = message.getJmsMessage();
        final String jmsMessageID = jmsMessage.getJMSMessageID();
        SetMovementReportRequest request = JAXBMarshaller.unmarshallTextMessage(jmsMessage, SetMovementReportRequest.class);
        log.info("[INFO] Processing Movement : {}", request);
        String username;
        SetReportMovementType setRepMovType = request.getRequest();
        if (MovementSourceType.MANUAL.equals(setRepMovType.getMovement().getSource())) {
            // A person has created a position
            username = request.getUsername();
            // Send some response to Movement, if it originated from there (manual movement)
            ProcessedMovementAck response = MovementModuleResponseMapper.mapProcessedMovementAck(eu.europa.ec.fisheries.schema.movement.common.v1.AcknowledgeTypeType.OK, jmsMessageID, "Movement successfully processed");
            producer.sendModuleAckMessage(jmsMessageID, MessageQueue.MOVEMENT_RESPONSE, JAXBMarshaller.marshallJaxBObjectToString(response));
        } else {
            // A plugin has reported a position
            username = setRepMovType.getPluginType().name();
        }
        String pluginName = setRepMovType.getPluginName();
        ServiceResponseType service = exchangeService.getService(pluginName);
        PluginType pluginType = setRepMovType.getPluginType();
        if (validate(setRepMovType, service, jmsMessage)) {
            MovementBaseType baseMovement = setRepMovType.getMovement();
            RawMovementType rawMovement = MovementMapper.getInstance().getMapper().map(baseMovement, RawMovementType.class);
            final AssetId assetId = rawMovement.getAssetId();
            if (assetId != null && assetId.getAssetIdList() != null) {
                assetId.getAssetIdList().addAll(MovementMapper.mapAssetIdList(baseMovement.getAssetId().getAssetIdList()));
            }
            if (baseMovement.getMobileTerminalId() != null && baseMovement.getMobileTerminalId().getMobileTerminalIdList() != null) {
                rawMovement.getMobileTerminal().getMobileTerminalIdList().addAll(MovementMapper.mapMobileTerminalIdList(baseMovement.getMobileTerminalId().getMobileTerminalIdList()));
            }
            rawMovement.setPluginType(pluginType.value());
            rawMovement.setPluginName(pluginName);
            rawMovement.setDateRecieved(setRepMovType.getTimestamp());
            // TODO : Temporary - probably better to change corr id to have the same though the entire flow;
            // TODO : then we can use this to send response to original caller from anywhere needed
            rawMovement.setAckResponseMessageID(jmsMessageID);
            log.info("[INFO] Logging received movement.");
            exchangeLog.log(request, LogType.RECEIVE_MOVEMENT, ExchangeLogStatusTypeType.ISSUED, TypeRefType.MOVEMENT, JAXBMarshaller.marshallJaxBObjectToString(request), true);
            forwardToRules(RulesModuleRequestMapper.createSetMovementReportRequest(PluginTypeMapper.map(pluginType), rawMovement, username), message, service);
            log.info("[INFO] Finished forwarding received movement to rules module.");
        } else {
            log.debug("[ERROR] Validation error. Event sent to plugin {}", message);
        }
    } catch (ExchangeServiceException e) {
        log.error("[ERROR] Couldn't get the Service type for the received message : {} {}", message, e);
    } catch (ExchangeModelMarshallException e) {
        log.error("[ERROR] Couldn't map to SetMovementReportRequest when processing movement from plugin:{} {}", message, e);
    } catch (JMSException e) {
        log.error("[ERROR] Failed to get response queue:{} {}", message, e);
    } catch (RulesModelMapperException e) {
        log.error("[ERROR] Failed to build Rules momvent request:{} {}", message, e);
    } catch (ExchangeLogException e) {
        log.error("[ERROR] Failed to log momvent request : {} {}", message, e);
    }
}
Also used : ServiceResponseType(eu.europa.ec.fisheries.schema.exchange.service.v1.ServiceResponseType) MovementBaseType(eu.europa.ec.fisheries.schema.exchange.movement.v1.MovementBaseType) JMSException(javax.jms.JMSException) ProcessedMovementAck(eu.europa.ec.fisheries.schema.movement.module.v1.ProcessedMovementAck) PluginType(eu.europa.ec.fisheries.schema.exchange.plugin.types.v1.PluginType) RulesModelMapperException(eu.europa.ec.fisheries.uvms.rules.model.exception.RulesModelMapperException) ExchangeServiceException(eu.europa.ec.fisheries.uvms.exchange.service.exception.ExchangeServiceException) ExchangeModelMarshallException(eu.europa.ec.fisheries.uvms.exchange.model.exception.ExchangeModelMarshallException) RawMovementType(eu.europa.ec.fisheries.schema.rules.movement.v1.RawMovementType) ExchangeLogException(eu.europa.ec.fisheries.uvms.exchange.service.exception.ExchangeLogException) SetReportMovementType(eu.europa.ec.fisheries.schema.exchange.movement.v1.SetReportMovementType) AssetId(eu.europa.ec.fisheries.schema.rules.asset.v1.AssetId) TextMessage(javax.jms.TextMessage) SetMovementReportRequest(eu.europa.ec.fisheries.schema.exchange.module.v1.SetMovementReportRequest)

Example 4 with RulesModelMapperException

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

the class ExchangeEventIncomingServiceBean method processFluxFAResponseMessage.

@Override
public void processFluxFAResponseMessage(@Observes @ReceivedFluxFaResponseMessageEvent ExchangeMessageEvent message) {
    try {
        RcvFLUXFaResponseMessageRequest request = JAXBMarshaller.unmarshallTextMessage(message.getJmsMessage(), RcvFLUXFaResponseMessageRequest.class);
        log.debug("Got FLUXResponseMessage in exchange :" + request.getRequest());
        ExchangeLogType exchangeLogType = exchangeLog.log(request, LogType.RECEIVE_FLUX_RESPONSE_MSG, ExchangeLogStatusTypeType.ISSUED, TypeRefType.FA_RESPONSE, request.getRequest(), true);
        String msg = RulesModuleRequestMapper.createRcvFluxFaResponseMessageRequest(extractPluginType(request), request.getRequest(), request.getUsername(), extractLogId(message, exchangeLogType), request.getFluxDataFlow(), request.getSenderOrReceiver(), request.getOnValue());
        forwardToRules(msg, message, null);
    } catch (RulesModelMapperException | ExchangeModelMarshallException e) {
        log.error("Couldn't map to RcvFLUXFaResponseMessageRequest when processing FLUXResponseMessage coming from fa-plugin!", e);
    } catch (ExchangeLogException e) {
        log.error("Couldn't log FLUXResponseMessage received from plugin into database", e);
    }
}
Also used : ExchangeModelMarshallException(eu.europa.ec.fisheries.uvms.exchange.model.exception.ExchangeModelMarshallException) ExchangeLogType(eu.europa.ec.fisheries.schema.exchange.v1.ExchangeLogType) ExchangeLogException(eu.europa.ec.fisheries.uvms.exchange.service.exception.ExchangeLogException) RulesModelMapperException(eu.europa.ec.fisheries.uvms.rules.model.exception.RulesModelMapperException) RcvFLUXFaResponseMessageRequest(eu.europa.ec.fisheries.schema.exchange.module.v1.RcvFLUXFaResponseMessageRequest)

Example 5 with RulesModelMapperException

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

the class ActivityRulesModuleServiceBean method sendSyncAsyncFaReportToRules.

@Override
public void sendSyncAsyncFaReportToRules(FLUXFAReportMessage faReportXMLObj, String onValue, SyncAsyncRequestType type, String jmsMessageCorrId) throws ActivityModuleException {
    String sendTo = extractOwnerFromFLUXReportDocument(faReportXMLObj.getFLUXReportDocument());
    if (StringUtils.isEmpty(sendTo)) {
        throw new ActivityModuleException("Owner for the provided FLUXFAReportMessage was not found, so FLUXFAReportMessage won't be sent!");
    }
    try {
        SubscriptionPermissionResponse subscriptionPermissionResponse = permissionChecker.checkPermissionForFaReport(faReportXMLObj);
        if (SubscriptionPermissionAnswer.YES.equals(subscriptionPermissionResponse.getSubscriptionCheck())) {
            final List<SubscriptionParameter> parameters = subscriptionPermissionResponse.getParameters();
            String dataFlow = extractParameterByName(parameters, "DF");
            // TODO : mocking up df value untill subscription is ready
            if (StringUtils.isEmpty(dataFlow)) {
                dataFlow = "urn:un:unece:uncefact:fisheries:FLUX:FA:EU:2";
            }
            // TODO : END Mocking
            if (StringUtils.isEmpty(dataFlow)) {
                log.error("[ERROR] Subscription is missing the dataFlow parameter! Cannot send FaQuery! ");
                throw new ActivityModuleException("Subscription is missing the dataFlow parameter! Cannot send FaQuery!");
            }
            String logId = null;
            if (faReportXMLObj.getFLUXReportDocument() != null && CollectionUtils.isNotEmpty(faReportXMLObj.getFLUXReportDocument().getIDS())) {
                logId = faReportXMLObj.getFLUXReportDocument().getIDS().get(0).getValue();
            }
            final String faReportXMLStr = JAXBMarshaller.marshallJaxBObjectToString(faReportXMLObj);
            // TODO : change this values (username, senderOrReceiver (Node name?)) when got answer from CEDRIC
            final String sendFLUXFAReportMessageRequest = RulesModuleRequestMapper.createSendFLUXFAReportMessageRequest(faReportXMLStr, "FLUX", logId, dataFlow, "BEL", onValue, isEmptyReportMessage(faReportXMLObj));
            if (SyncAsyncRequestType.SYNC.equals(type)) {
                activityResponseQueueProducer.sendMessageWithSpecificIds(sendFLUXFAReportMessageRequest, activityConsumerBean.getDestination(), null, null, jmsMessageCorrId);
            } else {
                rulesProducerBean.sendModuleMessage(sendFLUXFAReportMessageRequest, activityConsumerBean.getDestination());
            }
        } else {
            throw new ActivityModuleException("Error while trying to prepare the transmission of FaReportMessage!");
        }
    } catch (MessageException | RulesModelMapperException | ActivityModelMarshallException e) {
        log.error("[ERROR] Error while trying to ActivityRulesModuleService.composeAndSendTripUpdateFaQueryToRules(...)!", e);
        throw new ActivityModuleException("JAXBException or MessageException!", e);
    }
}
Also used : ActivityModelMarshallException(eu.europa.ec.fisheries.uvms.activity.model.exception.ActivityModelMarshallException) MessageException(eu.europa.ec.fisheries.uvms.commons.message.api.MessageException) SubscriptionPermissionResponse(eu.europa.ec.fisheries.wsdl.subscription.module.SubscriptionPermissionResponse) ActivityModuleException(eu.europa.ec.fisheries.ers.service.exception.ActivityModuleException) SubscriptionParameter(eu.europa.ec.fisheries.wsdl.subscription.module.SubscriptionParameter) RulesModelMapperException(eu.europa.ec.fisheries.uvms.rules.model.exception.RulesModelMapperException)

Aggregations

RulesModelMapperException (eu.europa.ec.fisheries.uvms.rules.model.exception.RulesModelMapperException)6 ExchangeModelMarshallException (eu.europa.ec.fisheries.uvms.exchange.model.exception.ExchangeModelMarshallException)4 ExchangeLogException (eu.europa.ec.fisheries.uvms.exchange.service.exception.ExchangeLogException)4 ExchangeLogType (eu.europa.ec.fisheries.schema.exchange.v1.ExchangeLogType)3 ActivityModuleException (eu.europa.ec.fisheries.ers.service.exception.ActivityModuleException)2 ActivityModelMarshallException (eu.europa.ec.fisheries.uvms.activity.model.exception.ActivityModelMarshallException)2 MessageException (eu.europa.ec.fisheries.uvms.commons.message.api.MessageException)2 SubscriptionParameter (eu.europa.ec.fisheries.wsdl.subscription.module.SubscriptionParameter)2 SubscriptionPermissionResponse (eu.europa.ec.fisheries.wsdl.subscription.module.SubscriptionPermissionResponse)2 RcvFLUXFaResponseMessageRequest (eu.europa.ec.fisheries.schema.exchange.module.v1.RcvFLUXFaResponseMessageRequest)1 SetFAQueryMessageRequest (eu.europa.ec.fisheries.schema.exchange.module.v1.SetFAQueryMessageRequest)1 SetFLUXFAReportMessageRequest (eu.europa.ec.fisheries.schema.exchange.module.v1.SetFLUXFAReportMessageRequest)1 SetMovementReportRequest (eu.europa.ec.fisheries.schema.exchange.module.v1.SetMovementReportRequest)1 MovementBaseType (eu.europa.ec.fisheries.schema.exchange.movement.v1.MovementBaseType)1 SetReportMovementType (eu.europa.ec.fisheries.schema.exchange.movement.v1.SetReportMovementType)1 PluginType (eu.europa.ec.fisheries.schema.exchange.plugin.types.v1.PluginType)1 ServiceResponseType (eu.europa.ec.fisheries.schema.exchange.service.v1.ServiceResponseType)1 ProcessedMovementAck (eu.europa.ec.fisheries.schema.movement.module.v1.ProcessedMovementAck)1 AssetId (eu.europa.ec.fisheries.schema.rules.asset.v1.AssetId)1 RawMovementType (eu.europa.ec.fisheries.schema.rules.movement.v1.RawMovementType)1