use of eu.europa.ec.fisheries.uvms.asset.model.exception.AssetModelMapperException 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.asset.model.exception.AssetModelMapperException in project UVMS-ActivityModule-APP by UnionVMS.
the class AssetModuleServiceBean method getAssetGuids.
@Override
public List<String> getAssetGuids(String vesselSearchStr, String vesselGroupSearch) throws ServiceException {
List<String> guidsFromVesselSearchStr = null;
List<String> guidsFromVesselGroup = null;
String request;
// Get the list of guids from assets if vesselSearchStr is provided
if (StringUtils.isNotEmpty(vesselSearchStr)) {
try {
request = AssetModuleRequestMapper.createAssetListModuleRequest(createAssetListQuery(vesselSearchStr));
} catch (AssetModelMapperException e) {
log.error("Error while trying to map the request for assets Module.", e);
throw new ServiceException(e.getMessage(), e.getCause());
}
guidsFromVesselSearchStr = getGuidsFromAssets(request);
}
// If the list of guids is not empty then we have to provide this on the query also
if (StringUtils.isNotEmpty(vesselGroupSearch)) {
try {
request = AssetModuleRequestMapper.createAssetListModuleRequest(createAssetGroupQuery(vesselGroupSearch));
} catch (AssetModelMapperException e) {
log.error("Error while trying to map the request for assets Module.", e);
throw new ServiceException(e.getMessage(), e.getCause());
}
guidsFromVesselGroup = getGuidsFromAssets(request);
}
return joinResults(guidsFromVesselSearchStr, guidsFromVesselGroup);
}
use of eu.europa.ec.fisheries.uvms.asset.model.exception.AssetModelMapperException 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.asset.model.exception.AssetModelMapperException in project UVMS-ActivityModule-APP by UnionVMS.
the class AssetModuleServiceBean method getAssetListResponse.
@Override
public List<Asset> getAssetListResponse(AssetListQuery assetListQuery) throws ServiceException {
List<Asset> assetList;
try {
String assetsRequest = AssetModuleRequestMapper.createAssetListModuleRequest(assetListQuery);
String correlationID = assetProducer.sendModuleMessage(assetsRequest, activityConsumer.getDestination());
TextMessage response = activityConsumer.getMessage(correlationID, TextMessage.class);
assetList = AssetModuleResponseMapper.mapToAssetListFromResponse(response, correlationID);
} catch (AssetModelMapperException | MessageException e) {
log.error("Error while trying to send message to Assets module.", e);
throw new ServiceException(e.getMessage(), e.getCause());
}
return assetList;
}
Aggregations