Search in sources :

Example 1 with SpatialModelMapperException

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

Example 2 with SpatialModelMapperException

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

Aggregations

MessageException (eu.europa.ec.fisheries.uvms.commons.message.api.MessageException)2 ServiceException (eu.europa.ec.fisheries.uvms.commons.service.exception.ServiceException)2 SpatialModelMapperException (eu.europa.ec.fisheries.uvms.spatial.model.exception.SpatialModelMapperException)2 TextMessage (javax.jms.TextMessage)2 AreaIdentifierType (eu.europa.ec.fisheries.uvms.spatial.model.schemas.AreaIdentifierType)1 FilterAreasSpatialRS (eu.europa.ec.fisheries.uvms.spatial.model.schemas.FilterAreasSpatialRS)1 GeometryByPortCodeResponse (eu.europa.ec.fisheries.uvms.spatial.model.schemas.GeometryByPortCodeResponse)1