Search in sources :

Example 11 with MessageException

use of eu.europa.ec.fisheries.uvms.commons.message.api.MessageException 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 12 with MessageException

use of eu.europa.ec.fisheries.uvms.commons.message.api.MessageException in project UVMS-ActivityModule-APP by UnionVMS.

the class AssetModuleServiceBean method getAssetListResponse.

@Override
public List<Asset> getAssetListResponse(AssetListQuery assetListQuery) throws ServiceException {
    List<Asset> assetList;
    try {
        String assetsRequest = AssetModuleRequestMapper.createAssetListModuleRequest(assetListQuery);
        String correlationID = assetProducer.sendModuleMessage(assetsRequest, activityConsumer.getDestination());
        TextMessage response = activityConsumer.getMessage(correlationID, TextMessage.class);
        assetList = AssetModuleResponseMapper.mapToAssetListFromResponse(response, correlationID);
    } catch (AssetModelMapperException | MessageException e) {
        log.error("Error while trying to send message to Assets module.", e);
        throw new ServiceException(e.getMessage(), e.getCause());
    }
    return assetList;
}
Also used : ServiceException(eu.europa.ec.fisheries.uvms.commons.service.exception.ServiceException) MessageException(eu.europa.ec.fisheries.uvms.commons.message.api.MessageException) AssetModelMapperException(eu.europa.ec.fisheries.uvms.asset.model.exception.AssetModelMapperException) TextMessage(javax.jms.TextMessage)

Example 13 with MessageException

use of eu.europa.ec.fisheries.uvms.commons.message.api.MessageException in project UVMS-ActivityModule-APP by UnionVMS.

the class SpatialModuleServiceBean method getGeometryForPortCode.

@Override
public String getGeometryForPortCode(String portCode) throws ServiceException {
    log.info("Inside getGeometryForPortCode :" + portCode);
    try {
        String request = SpatialModuleRequestMapper.mapToGeometryByPortCodeRequest(portCode);
        String correlationId = spatialProducer.sendModuleMessage(request, activityConsumer.getDestination());
        TextMessage message = activityConsumer.getMessage(correlationId, TextMessage.class);
        if (message != null && !isUserFault(message)) {
            GeometryByPortCodeResponse response = SpatialModuleResponseMapper.mapGeometryByPortCodeResponseToString(message, correlationId);
            return response.getPortGeometry();
        } else {
            throw new ServiceException("FAILED TO GET GEOMETRY FROM SPATIAL");
        }
    } catch (ServiceException | MessageException | SpatialModelMapperException e) {
        log.error("Exception in communication with spatial while retrieving GEOMETRY", e);
        throw new ServiceException(e.getMessage(), e);
    }
}
Also used : ServiceException(eu.europa.ec.fisheries.uvms.commons.service.exception.ServiceException) MessageException(eu.europa.ec.fisheries.uvms.commons.message.api.MessageException) GeometryByPortCodeResponse(eu.europa.ec.fisheries.uvms.spatial.model.schemas.GeometryByPortCodeResponse) TextMessage(javax.jms.TextMessage) SpatialModelMapperException(eu.europa.ec.fisheries.uvms.spatial.model.exception.SpatialModelMapperException)

Example 14 with MessageException

use of eu.europa.ec.fisheries.uvms.commons.message.api.MessageException in project UVMS-ActivityModule-APP by UnionVMS.

the class ActivityEventServiceBean method getMapToSubscriptionMessage.

@Override
public void getMapToSubscriptionMessage(@Observes @MapToSubscriptionRequestEvent EventMessage message) {
    log.info(GOT_JMS_INSIDE_ACTIVITY_TO_GET + "MapToSubscriptionRequestEvent");
    try {
        TextMessage jmsMessage = message.getJmsMessage();
        String jmsCorrelationID = jmsMessage.getJMSMessageID();
        String messageReceived = jmsMessage.getText();
        SubscriptionDataRequest subscriptionDataRequest = null;
        MapToSubscriptionRequest baseRequest = JAXBUtils.unMarshallMessage(messageReceived, MapToSubscriptionRequest.class);
        switch(baseRequest.getMessageType()) {
            case FLUX_FA_QUERY_MESSAGE:
                FLUXFAQueryMessage fluxfaQueryMessage = JAXBUtils.unMarshallMessage(baseRequest.getRequest(), FLUXFAQueryMessage.class);
                subscriptionDataRequest = SubscriptionMapper.mapToSubscriptionDataRequest(fluxfaQueryMessage.getFAQuery());
                break;
            case FLUX_FA_REPORT_MESSAGE:
                FLUXFAReportMessage fluxFAReportMessage = JAXBUtils.unMarshallMessage(baseRequest.getRequest(), FLUXFAReportMessage.class);
                subscriptionDataRequest = SubscriptionMapper.mapToSubscriptionDataRequest(fluxFAReportMessage);
                break;
            default:
                sendError(message, new IllegalArgumentException("VERBODEN VRUCHT"));
        }
        subscriptionProducer.sendMessageWithSpecificIds(JAXBUtils.marshallJaxBObjectToString(subscriptionDataRequest), subscriptionProducer.getDestination(), JMSUtils.lookupQueue(MessageConstants.QUEUE_RULES), null, jmsCorrelationID);
    } catch (JAXBException | MessageException | JMSException e) {
        sendError(message, e);
    }
}
Also used : FLUXFAQueryMessage(un.unece.uncefact.data.standard.fluxfaquerymessage._3.FLUXFAQueryMessage) FLUXFAReportMessage(un.unece.uncefact.data.standard.fluxfareportmessage._3.FLUXFAReportMessage) MessageException(eu.europa.ec.fisheries.uvms.commons.message.api.MessageException) JAXBException(javax.xml.bind.JAXBException) MapToSubscriptionRequest(eu.europa.ec.fisheries.uvms.activity.model.schemas.MapToSubscriptionRequest) JMSException(javax.jms.JMSException) SubscriptionDataRequest(eu.europa.ec.fisheries.wsdl.subscription.module.SubscriptionDataRequest) TextMessage(javax.jms.TextMessage)

Example 15 with MessageException

use of eu.europa.ec.fisheries.uvms.commons.message.api.MessageException 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

MessageException (eu.europa.ec.fisheries.uvms.commons.message.api.MessageException)16 TextMessage (javax.jms.TextMessage)10 ServiceException (eu.europa.ec.fisheries.uvms.commons.service.exception.ServiceException)9 JMSException (javax.jms.JMSException)8 ActivityModelMarshallException (eu.europa.ec.fisheries.uvms.activity.model.exception.ActivityModelMarshallException)7 ActivityModuleException (eu.europa.ec.fisheries.ers.service.exception.ActivityModuleException)3 AssetModelMapperException (eu.europa.ec.fisheries.uvms.asset.model.exception.AssetModelMapperException)3 RulesModelMapperException (eu.europa.ec.fisheries.uvms.rules.model.exception.RulesModelMapperException)2 SpatialModelMapperException (eu.europa.ec.fisheries.uvms.spatial.model.exception.SpatialModelMapperException)2 SubscriptionParameter (eu.europa.ec.fisheries.wsdl.subscription.module.SubscriptionParameter)2 SubscriptionPermissionResponse (eu.europa.ec.fisheries.wsdl.subscription.module.SubscriptionPermissionResponse)2 ArrayList (java.util.ArrayList)2 JAXBException (javax.xml.bind.JAXBException)2 FLUXFAQueryMessage (un.unece.uncefact.data.standard.fluxfaquerymessage._3.FLUXFAQueryMessage)2 ExchangeLogWithValidationResults (eu.europa.ec.fisheries.schema.exchange.v1.ExchangeLogWithValidationResults)1 MovementMapResponseType (eu.europa.ec.fisheries.schema.movement.search.v1.MovementMapResponseType)1 MovementQuery (eu.europa.ec.fisheries.schema.movement.search.v1.MovementQuery)1 MovementType (eu.europa.ec.fisheries.schema.movement.v1.MovementType)1 ValidationMessageType (eu.europa.ec.fisheries.schema.rules.rule.v1.ValidationMessageType)1 ValidationMessageTypeResponse (eu.europa.ec.fisheries.schema.rules.rule.v1.ValidationMessageTypeResponse)1