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