Search in sources :

Example 11 with ServiceException

use of eu.europa.ec.fisheries.uvms.commons.service.exception.ServiceException 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 12 with ServiceException

use of eu.europa.ec.fisheries.uvms.commons.service.exception.ServiceException 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 13 with ServiceException

use of eu.europa.ec.fisheries.uvms.commons.service.exception.ServiceException 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.sendResponseMessageToSender(message.getJmsMessage(), responseStr);
    } catch (ActivityModelMarshallException | JMSException | ServiceException | MessageException 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) MessageException(eu.europa.ec.fisheries.uvms.commons.message.api.MessageException) 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 14 with ServiceException

use of eu.europa.ec.fisheries.uvms.commons.service.exception.ServiceException 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.sendResponseMessageToSender(message.getJmsMessage(), response);
        log.debug("Response sent back.");
    } catch (ActivityModelMarshallException | JMSException | ServiceException | MessageException 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) MessageException(eu.europa.ec.fisheries.uvms.commons.message.api.MessageException) JMSException(javax.jms.JMSException)

Example 15 with ServiceException

use of eu.europa.ec.fisheries.uvms.commons.service.exception.ServiceException in project UVMS-ActivityModule-APP by UnionVMS.

the class ActivityEventServiceBean method getFACatchSummaryReport.

@Override
public void getFACatchSummaryReport(@Observes @GetFACatchSummaryReportEvent EventMessage message) {
    log.info(GOT_JMS_INSIDE_ACTIVITY_TO_GET + "FACatchSummaryReport:");
    try {
        log.debug("JMS Incoming text message: {}", message.getJmsMessage().getText());
        FACatchSummaryReportRequest baseRequest = JAXBMarshaller.unmarshallTextMessage(message.getJmsMessage(), FACatchSummaryReportRequest.class);
        FACatchSummaryReportResponse faCatchSummaryReportResponse = faCatchReportService.getFACatchSummaryReportResponse(FishingActivityRequestMapper.buildFishingActivityQueryFromRequest(baseRequest));
        String response = JAXBMarshaller.marshallJaxBObjectToString(faCatchSummaryReportResponse);
        producer.sendResponseMessageToSender(message.getJmsMessage(), response);
    } catch (ActivityModelMarshallException | JMSException | ServiceException | MessageException 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) MessageException(eu.europa.ec.fisheries.uvms.commons.message.api.MessageException) FACatchSummaryReportRequest(eu.europa.ec.fisheries.uvms.activity.model.schemas.FACatchSummaryReportRequest) JMSException(javax.jms.JMSException) FACatchSummaryReportResponse(eu.europa.ec.fisheries.uvms.activity.model.schemas.FACatchSummaryReportResponse)

Aggregations

ServiceException (eu.europa.ec.fisheries.uvms.commons.service.exception.ServiceException)42 ArrayList (java.util.ArrayList)11 MessageException (eu.europa.ec.fisheries.uvms.commons.message.api.MessageException)9 Geometry (com.vividsolutions.jts.geom.Geometry)8 ParseException (com.vividsolutions.jts.io.ParseException)7 SearchFilter (eu.europa.ec.fisheries.uvms.activity.model.schemas.SearchFilter)7 TextMessage (javax.jms.TextMessage)7 List (java.util.List)6 ActivityModelMarshallException (eu.europa.ec.fisheries.uvms.activity.model.exception.ActivityModelMarshallException)5 GroupCriteria (eu.europa.ec.fisheries.uvms.activity.model.schemas.GroupCriteria)5 JMSException (javax.jms.JMSException)5 FilterMap (eu.europa.ec.fisheries.ers.service.search.FilterMap)4 Map (java.util.Map)4 FaCatchSummaryCustomProxy (eu.europa.ec.fisheries.ers.fa.dao.proxy.FaCatchSummaryCustomProxy)3 VesselTransportMeansEntity (eu.europa.ec.fisheries.ers.fa.entities.VesselTransportMeansEntity)3 GroupCriteriaMapper (eu.europa.ec.fisheries.ers.service.search.GroupCriteriaMapper)3 AssetModelMapperException (eu.europa.ec.fisheries.uvms.asset.model.exception.AssetModelMapperException)3 AreaIdentifierType (eu.europa.ec.fisheries.uvms.spatial.model.schemas.AreaIdentifierType)3 EnumMap (java.util.EnumMap)3 NotNull (org.jetbrains.annotations.NotNull)3