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);
}
}
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);
}
}
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);
}
}
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);
}
}
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);
}
}
Aggregations