Search in sources :

Example 6 with RulesModelMapperException

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

the class ActivityRulesModuleServiceBean method composeAndSendTripUpdateFaQueryToRules.

@Override
public void composeAndSendTripUpdateFaQueryToRules(String tripId) throws ActivityModuleException {
    String sendTo = fishingTripService.getOwnerFluxPartyFromTripId(tripId);
    if (StringUtils.isEmpty(sendTo)) {
        throw new ActivityModuleException("Owner for the provided Trip Id [ " + tripId + " ] was not found, so the Update Trip Query cannot be executed!");
    }
    // TODO : Ask cedric where to get this parameter from! or ask Greg
    boolean consolidated = false;
    FAQuery faQueryForTrip = FaQueryFactory.createFaQueryForTrip(tripId, sendTo, consolidated);
    if (faQueryForTrip == null) {
        throw new ActivityModuleException("Fa Query is null!! Check the [tripId, sendTo] parameters!");
    }
    try {
        SubscriptionPermissionResponse subscriptionPermissionResponse = permissionChecker.checkPermissionForFaQuery(faQueryForTrip);
        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 = faQueryForTrip.getID().getValue();
            FLUXFAQueryMessage fluxfaQueryMessage = new FLUXFAQueryMessage(faQueryForTrip);
            final String faqReqStr = JAXBMarshaller.marshallJaxBObjectToString(fluxfaQueryMessage);
            // TODO : change this values (username, senderOrReceiver (Node name?)) when got answer from CEDRIC
            // senderOrReceiver :  From subscription
            // FR : system parameter
            // username : Mock to FLUX
            rulesProducerBean.sendModuleMessage(RulesModuleRequestMapper.createSendFaQueryMessageRequest(faqReqStr, "FLUX", logId, dataFlow, "BEL"), activityConsumerBean.getDestination());
        } else {
            throw new ActivityModuleException("The FaQuery that was build with the following parameters [" + tripId + "," + sendTo + ",consolidated : " + consolidated + "] doesn't match to any subscription!");
        }
    } 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) FLUXFAQueryMessage(un.unece.uncefact.data.standard.fluxfaquerymessage._3.FLUXFAQueryMessage) MessageException(eu.europa.ec.fisheries.uvms.commons.message.api.MessageException) FAQuery(un.unece.uncefact.data.standard.reusableaggregatebusinessinformationentity._20.FAQuery) 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