Search in sources :

Example 6 with ActivityModelMarshallException

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

the class ActivityEventServiceBean method getFishingActivityForTripsRequest.

@Override
public void getFishingActivityForTripsRequest(@Observes @GetFishingActivityForTripsRequestEvent EventMessage message) {
    log.info(GOT_JMS_INSIDE_ACTIVITY_TO_GET + " Fishing activities related to trips.");
    try {
        log.debug(message.getJmsMessage().getText());
        GetFishingActivitiesForTripRequest request = JAXBMarshaller.unmarshallTextMessage(message.getJmsMessage(), GetFishingActivitiesForTripRequest.class);
        GetFishingActivitiesForTripResponse response = activityServiceBean.getFaAndTripIdsFromTripIds(request.getFaAndTripIds());
        String responseStr = JAXBMarshaller.marshallJaxBObjectToString(response);
        producer.sendModuleResponseMessage(message.getJmsMessage(), responseStr, producer.getModuleName());
    } catch (ActivityModelMarshallException | JMSException | ServiceException e) {
        sendError(message, e);
    }
}
Also used : ActivityModelMarshallException(eu.europa.ec.fisheries.uvms.activity.model.exception.ActivityModelMarshallException) ServiceException(eu.europa.ec.fisheries.uvms.commons.service.exception.ServiceException) GetFishingActivitiesForTripRequest(eu.europa.ec.fisheries.uvms.activity.model.schemas.GetFishingActivitiesForTripRequest) GetFishingActivitiesForTripResponse(eu.europa.ec.fisheries.uvms.activity.model.schemas.GetFishingActivitiesForTripResponse) JMSException(javax.jms.JMSException)

Example 7 with ActivityModelMarshallException

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

the class ActivityEventServiceBean method getFishingTripList.

@Override
public void getFishingTripList(@Observes @GetFishingTripListEvent EventMessage message) {
    log.info(GOT_JMS_INSIDE_ACTIVITY_TO_GET + "FishingTripIds:");
    try {
        log.debug("JMS Incoming text message: {}", message.getJmsMessage().getText());
        FishingTripRequest baseRequest = JAXBMarshaller.unmarshallTextMessage(message.getJmsMessage(), FishingTripRequest.class);
        log.debug("FishingTriId Request Unmarshalled");
        FishingTripResponse baseResponse = fishingTripService.filterFishingTripsForReporting(FishingActivityRequestMapper.buildFishingActivityQueryFromRequest(baseRequest));
        log.debug("FishingTripResponse ::: " + FACatchSummaryHelper.printJsonstructure(baseResponse));
        String response = JAXBMarshaller.marshallJaxBObjectToString(baseResponse);
        log.debug("FishingTriId response marshalled");
        producer.sendModuleResponseMessage(message.getJmsMessage(), response, producer.getModuleName());
        log.debug("Response sent back.");
    } catch (ActivityModelMarshallException | JMSException | ServiceException e) {
        sendError(message, e);
    }
}
Also used : FishingTripRequest(eu.europa.ec.fisheries.uvms.activity.model.schemas.FishingTripRequest) FishingTripResponse(eu.europa.ec.fisheries.uvms.activity.model.schemas.FishingTripResponse) ActivityModelMarshallException(eu.europa.ec.fisheries.uvms.activity.model.exception.ActivityModelMarshallException) ServiceException(eu.europa.ec.fisheries.uvms.commons.service.exception.ServiceException) JMSException(javax.jms.JMSException)

Example 8 with ActivityModelMarshallException

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

Example 9 with ActivityModelMarshallException

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

Example 10 with ActivityModelMarshallException

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

the class ActivityEventServiceBean method getFishingActivityMessage.

@Override
public void getFishingActivityMessage(@Observes @ReceiveFishingActivityRequestEvent EventMessage eventMessage) {
    log.info(GOT_JMS_INSIDE_ACTIVITY_TO_GET + "SetFLUXFAReportOrQueryMessageRequest");
    try {
        TextMessage jmsMessage = eventMessage.getJmsMessage();
        SetFLUXFAReportOrQueryMessageRequest request = JAXBMarshaller.unmarshallTextMessage(jmsMessage, SetFLUXFAReportOrQueryMessageRequest.class);
        log.info("SetFLUXFAReportOrQueryMessageRequest unmarshalled");
        if (request == null) {
            log.error("Unmarshalled SetFLUXFAReportOrQueryMessageRequest is null. Something went wrong during jms comm?!");
            return;
        }
        switch(eventMessage.getMethod()) {
            case GET_FLUX_FA_REPORT:
                FLUXFAReportMessage fluxFAReportMessage = JAXBMarshaller.unmarshallTextMessage(request.getRequest(), FLUXFAReportMessage.class);
                deleteDuplicatedReportsFromXMLDocument(fluxFAReportMessage);
                if (CollectionUtils.isNotEmpty(fluxFAReportMessage.getFAReportDocuments())) {
                    fluxMessageService.saveFishingActivityReportDocuments(fluxFAReportMessage, extractPluginType(request.getPluginType()));
                } else {
                    log.error("[ERROR] After checking faReportDocuments IDs, all of them exist already in Activity DB.. So nothing will be saved!!");
                }
                break;
            case GET_FLUX_FA_QUERY:
                FLUXFAQueryMessage fluxFAQueryMessage = JAXBMarshaller.unmarshallTextMessage(request.getRequest(), FLUXFAQueryMessage.class);
                // TODO : Implement me... Map tp real HQl/SQL query and run the query and map the results to FLUXFAReportMessage and send it to rules...
                log.error("TODO : FAQUERY mappers NOT implemented yet....");
                break;
        }
    } catch (ActivityModelMarshallException | ServiceException e) {
        sendError(eventMessage, e);
    }
}
Also used : SetFLUXFAReportOrQueryMessageRequest(eu.europa.ec.fisheries.uvms.activity.model.schemas.SetFLUXFAReportOrQueryMessageRequest) ActivityModelMarshallException(eu.europa.ec.fisheries.uvms.activity.model.exception.ActivityModelMarshallException) ServiceException(eu.europa.ec.fisheries.uvms.commons.service.exception.ServiceException) FLUXFAReportMessage(un.unece.uncefact.data.standard.fluxfareportmessage._3.FLUXFAReportMessage) FLUXFAQueryMessage(un.unece.uncefact.data.standard.fluxfaquerymessage._3.FLUXFAQueryMessage) TextMessage(javax.jms.TextMessage)

Aggregations

ActivityModelMarshallException (eu.europa.ec.fisheries.uvms.activity.model.exception.ActivityModelMarshallException)11 JMSException (javax.jms.JMSException)6 ServiceException (eu.europa.ec.fisheries.uvms.commons.service.exception.ServiceException)5 TextMessage (javax.jms.TextMessage)4 MessageException (eu.europa.ec.fisheries.uvms.commons.message.api.MessageException)3 ActivityModuleException (eu.europa.ec.fisheries.ers.service.exception.ActivityModuleException)2 GetNonUniqueIdsRequest (eu.europa.ec.fisheries.uvms.activity.model.schemas.GetNonUniqueIdsRequest)2 GetNonUniqueIdsResponse (eu.europa.ec.fisheries.uvms.activity.model.schemas.GetNonUniqueIdsResponse)2 RulesModelMapperException (eu.europa.ec.fisheries.uvms.rules.model.exception.RulesModelMapperException)2 SubscriptionParameter (eu.europa.ec.fisheries.wsdl.subscription.module.SubscriptionParameter)2 SubscriptionPermissionResponse (eu.europa.ec.fisheries.wsdl.subscription.module.SubscriptionPermissionResponse)2 TransactionAttribute (javax.ejb.TransactionAttribute)2 FLUXFAQueryMessage (un.unece.uncefact.data.standard.fluxfaquerymessage._3.FLUXFAQueryMessage)2 EventMessage (eu.europa.ec.fisheries.uvms.activity.message.event.carrier.EventMessage)1 ActivityModuleMethod (eu.europa.ec.fisheries.uvms.activity.model.schemas.ActivityModuleMethod)1 ActivityModuleRequest (eu.europa.ec.fisheries.uvms.activity.model.schemas.ActivityModuleRequest)1 ActivityUniquinessList (eu.europa.ec.fisheries.uvms.activity.model.schemas.ActivityUniquinessList)1 FACatchSummaryReportRequest (eu.europa.ec.fisheries.uvms.activity.model.schemas.FACatchSummaryReportRequest)1 FACatchSummaryReportResponse (eu.europa.ec.fisheries.uvms.activity.model.schemas.FACatchSummaryReportResponse)1 FishingTripRequest (eu.europa.ec.fisheries.uvms.activity.model.schemas.FishingTripRequest)1