Search in sources :

Example 1 with MessageException

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

the class ExchangeAssetServiceBean method getAsset.

@Override
public Asset getAsset(String assetGuid) throws ExchangeServiceException {
    try {
        String request = AssetModuleRequestMapper.createGetAssetModuleRequest(assetGuid, AssetIdType.GUID);
        String messageId = producer.sendMessageOnQueue(request, MessageQueue.VESSEL);
        TextMessage response = consumer.getMessage(messageId, TextMessage.class);
        return AssetModuleResponseMapper.mapToAssetFromResponse(response, messageId);
    } catch (ExchangeMessageException | MessageException e) {
        LOG.error("Couldn't send message to vessel module");
        throw new ExchangeServiceException("Couldn't send message to vessel module");
    } catch (AssetModelMapperException e) {
        LOG.error("Couldn't map asset object by guid:  {}", assetGuid);
        throw new ExchangeServiceException("Couldn't map asset object by guid:  " + assetGuid);
    }
}
Also used : MessageException(eu.europa.ec.fisheries.uvms.commons.message.api.MessageException) ExchangeMessageException(eu.europa.ec.fisheries.uvms.exchange.message.exception.ExchangeMessageException) AssetModelMapperException(eu.europa.ec.fisheries.uvms.asset.model.exception.AssetModelMapperException) ExchangeMessageException(eu.europa.ec.fisheries.uvms.exchange.message.exception.ExchangeMessageException) TextMessage(javax.jms.TextMessage) ExchangeServiceException(eu.europa.ec.fisheries.uvms.exchange.service.exception.ExchangeServiceException)

Example 2 with MessageException

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

the class AssetModuleServiceBean method getGuidsFromAssets.

@NotNull
protected List<String> getGuidsFromAssets(String request) throws ServiceException {
    try {
        String correlationId = assetProducer.sendModuleMessage(request, activityConsumer.getDestination());
        TextMessage response = activityConsumer.getMessage(correlationId, TextMessage.class);
        if (response != null && !isUserFault(response)) {
            List<Asset> assets = AssetModuleResponseMapper.mapToAssetListFromResponse(response, correlationId);
            List<String> assetGuids = new ArrayList<>();
            for (Asset asset : assets) {
                assetGuids.add(asset.getAssetId().getGuid());
            }
            return assetGuids;
        } else {
            throw new ServiceException("FAILED TO GET DATA FROM ASSET");
        }
    } catch (ServiceException | MessageException | AssetModelMapperException e) {
        log.error("Exception in communication with movements", 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) AssetModelMapperException(eu.europa.ec.fisheries.uvms.asset.model.exception.AssetModelMapperException) TextMessage(javax.jms.TextMessage) NotNull(org.jetbrains.annotations.NotNull)

Example 3 with MessageException

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

the class MdrModuleServiceBean method getAcronymFromMdr.

@Override
public Map<String, List<String>> getAcronymFromMdr(String acronym, String filter, List<String> filterColumns, Integer nrOfResults, String... returnColumns) throws ServiceException {
    Map<String, List<String>> columnNameValuesMap = prepareColumnNameValuesMap(returnColumns);
    try {
        String request = MdrModuleMapper.createFluxMdrGetCodeListRequest(acronym, filter, filterColumns, nrOfResults);
        String correlationId = mdrProducer.sendModuleMessage(request, activityConsumer.getDestination());
        TextMessage message = activityConsumer.getMessage(correlationId, TextMessage.class);
        if (null != message) {
            String messageStr = message.getText();
            MdrGetCodeListResponse response = JAXBMarshaller.unmarshallTextMessage(messageStr, MdrGetCodeListResponse.class);
            for (ObjectRepresentation objectRep : response.getDataSets()) {
                for (ColumnDataType nameVal : objectRep.getFields()) {
                    if (columnNameValuesMap.containsKey(nameVal.getColumnName())) {
                        columnNameValuesMap.get(nameVal.getColumnName()).add(nameVal.getColumnValue());
                    }
                }
            }
            return columnNameValuesMap;
        } else {
            throw new ServiceException("Unable to get data from MDR Module");
        }
    } catch (JMSException | MessageException | MdrModelMarshallException | ActivityModelMarshallException e) {
        log.error("MdrModelMarshallException in communication with mdr", e.getCause());
        throw new ServiceException("Exception caught in mdrModuleServiceBean", e.getCause());
    }
}
Also used : MdrModelMarshallException(eu.europa.ec.fisheries.uvms.mdr.model.exception.MdrModelMarshallException) ColumnDataType(un.unece.uncefact.data.standard.mdr.communication.ColumnDataType) JMSException(javax.jms.JMSException) ActivityModelMarshallException(eu.europa.ec.fisheries.uvms.activity.model.exception.ActivityModelMarshallException) ServiceException(eu.europa.ec.fisheries.uvms.commons.service.exception.ServiceException) MdrGetCodeListResponse(un.unece.uncefact.data.standard.mdr.communication.MdrGetCodeListResponse) MessageException(eu.europa.ec.fisheries.uvms.commons.message.api.MessageException) ArrayList(java.util.ArrayList) List(java.util.List) TextMessage(javax.jms.TextMessage) ObjectRepresentation(un.unece.uncefact.data.standard.mdr.communication.ObjectRepresentation)

Example 4 with MessageException

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

the class MovementModuleServiceBean method getMovement.

/**
 * {@inheritDoc}
 */
@Override
@TransactionAttribute(TransactionAttributeType.REQUIRES_NEW)
public List<MovementType> getMovement(List<String> vesselIds, Date startDate, Date endDate) throws ServiceException {
    try {
        MovementQuery movementQuery = new MovementQuery();
        addListCriteria(vesselIds, movementQuery);
        addRangeCriteria(startDate, endDate, movementQuery);
        movementQuery.setExcludeFirstAndLastSegment(true);
        String request = MovementModuleRequestMapper.mapToGetMovementMapByQueryRequest(movementQuery);
        String moduleMessage = movementProducer.sendModuleMessage(request, activityConsumer.getDestination());
        TextMessage response = activityConsumer.getMessage(moduleMessage, TextMessage.class);
        if (response != null && !isUserFault(response)) {
            List<MovementMapResponseType> mapResponseTypes = MovementModuleResponseMapper.mapToMovementMapResponse(response);
            List<MovementType> movements = new ArrayList<>();
            for (MovementMapResponseType movementMap : mapResponseTypes) {
                movements.addAll(movementMap.getMovements());
            }
            return movements;
        } else {
            throw new ServiceException("FAILED TO GET DATA FROM MOVEMENT");
        }
    } catch (MovementDuplicateException | MovementFaultException | ServiceException | MessageException | JMSException | ModelMapperException e) {
        log.error("Exception in communication with movements", e);
        throw new ServiceException(e.getMessage(), e);
    }
}
Also used : MovementQuery(eu.europa.ec.fisheries.schema.movement.search.v1.MovementQuery) MovementFaultException(eu.europa.ec.fisheries.uvms.movement.model.exception.MovementFaultException) MovementDuplicateException(eu.europa.ec.fisheries.uvms.movement.model.exception.MovementDuplicateException) ArrayList(java.util.ArrayList) MovementMapResponseType(eu.europa.ec.fisheries.schema.movement.search.v1.MovementMapResponseType) JMSException(javax.jms.JMSException) MovementType(eu.europa.ec.fisheries.schema.movement.v1.MovementType) ServiceException(eu.europa.ec.fisheries.uvms.commons.service.exception.ServiceException) MessageException(eu.europa.ec.fisheries.uvms.commons.message.api.MessageException) ModelMapperException(eu.europa.ec.fisheries.uvms.movement.model.exception.ModelMapperException) TextMessage(javax.jms.TextMessage) TransactionAttribute(javax.ejb.TransactionAttribute)

Example 5 with MessageException

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

the class SpatialModuleServiceBean method getFilteredAreaGeom.

/**
 * {@inheritDoc}
 */
@Override
public String getFilteredAreaGeom(Collection<AreaIdentifierType> areaIdentifiers) throws ServiceException {
    try {
        String request = SpatialModuleRequestMapper.mapToFilterAreaSpatialRequest(new ArrayList<>(areaIdentifiers), new ArrayList<AreaIdentifierType>());
        String correlationId = spatialProducer.sendModuleMessage(request, activityConsumer.getDestination());
        TextMessage message = activityConsumer.getMessage(correlationId, TextMessage.class);
        if (message != null && !isUserFault(message)) {
            FilterAreasSpatialRS response = SpatialModuleResponseMapper.mapToFilterAreasSpatialRSFromResponse(message, correlationId);
            return response.getGeometry();
        } else {
            throw new ServiceException("FAILED TO GET DATA FROM SPATIAL");
        }
    } catch (ServiceException | MessageException | SpatialModelMapperException e) {
        log.error("Exception in communication with spatial while retrieving filtered area", e);
        throw new ServiceException(e.getMessage(), e);
    }
}
Also used : FilterAreasSpatialRS(eu.europa.ec.fisheries.uvms.spatial.model.schemas.FilterAreasSpatialRS) ServiceException(eu.europa.ec.fisheries.uvms.commons.service.exception.ServiceException) MessageException(eu.europa.ec.fisheries.uvms.commons.message.api.MessageException) AreaIdentifierType(eu.europa.ec.fisheries.uvms.spatial.model.schemas.AreaIdentifierType) TextMessage(javax.jms.TextMessage) SpatialModelMapperException(eu.europa.ec.fisheries.uvms.spatial.model.exception.SpatialModelMapperException)

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