use of eu.europa.ec.fisheries.uvms.commons.message.api.MessageException in project UVMS-ExchangeModule-APP by UnionVMS.
the class ExchangeToRulesSyncMsgBean method getValidationFromRules.
public ExchangeLogWithValidationResults getValidationFromRules(String guid, TypeRefType type) {
if (StringUtils.isEmpty(guid)) {
return new ExchangeLogWithValidationResults();
}
ExchangeLogWithValidationResults resp = new ExchangeLogWithValidationResults();
try {
String getValidationsByGuidRequest = RulesModuleRequestMapper.createGetValidationsByGuidRequest(guid, type == null ? null : type.name());
String correlationId = exchangeProducerBean.sendRulesMessage(getValidationsByGuidRequest);
TextMessage validationRespMsg = exchangeConsumerBean.getMessage(correlationId, TextMessage.class);
ValidationMessageTypeResponse validTypeRespFromRules = JAXBMarshaller.unmarshallTextMessage(validationRespMsg, ValidationMessageTypeResponse.class);
List<ValidationMessageType> validationsListResponse = validTypeRespFromRules.getValidationsListResponse();
if (CollectionUtils.isNotEmpty(validationsListResponse)) {
for (ValidationMessageType validMsgFromRules : validationsListResponse) {
resp.getValidationList().add(mapToLogValidationResult(validMsgFromRules));
}
}
} catch (ConfigMessageException | MessageException | RulesModelMarshallException | ExchangeModelMarshallException e) {
log.error("Error while trying to get Validation Results for RawMessage GUID from Rules!", e);
}
return resp;
}
use of eu.europa.ec.fisheries.uvms.commons.message.api.MessageException 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;
}
use of eu.europa.ec.fisheries.uvms.commons.message.api.MessageException 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);
}
}
use of eu.europa.ec.fisheries.uvms.commons.message.api.MessageException in project UVMS-ActivityModule-APP by UnionVMS.
the class ActivityEventServiceBean method getMapToSubscriptionMessage.
@Override
public void getMapToSubscriptionMessage(@Observes @MapToSubscriptionRequestEvent EventMessage message) {
log.info(GOT_JMS_INSIDE_ACTIVITY_TO_GET + "MapToSubscriptionRequestEvent");
try {
TextMessage jmsMessage = message.getJmsMessage();
String jmsCorrelationID = jmsMessage.getJMSMessageID();
String messageReceived = jmsMessage.getText();
SubscriptionDataRequest subscriptionDataRequest = null;
MapToSubscriptionRequest baseRequest = JAXBUtils.unMarshallMessage(messageReceived, MapToSubscriptionRequest.class);
switch(baseRequest.getMessageType()) {
case FLUX_FA_QUERY_MESSAGE:
FLUXFAQueryMessage fluxfaQueryMessage = JAXBUtils.unMarshallMessage(baseRequest.getRequest(), FLUXFAQueryMessage.class);
subscriptionDataRequest = SubscriptionMapper.mapToSubscriptionDataRequest(fluxfaQueryMessage.getFAQuery());
break;
case FLUX_FA_REPORT_MESSAGE:
FLUXFAReportMessage fluxFAReportMessage = JAXBUtils.unMarshallMessage(baseRequest.getRequest(), FLUXFAReportMessage.class);
subscriptionDataRequest = SubscriptionMapper.mapToSubscriptionDataRequest(fluxFAReportMessage);
break;
default:
sendError(message, new IllegalArgumentException("VERBODEN VRUCHT"));
}
subscriptionProducer.sendMessageWithSpecificIds(JAXBUtils.marshallJaxBObjectToString(subscriptionDataRequest), subscriptionProducer.getDestination(), JMSUtils.lookupQueue(MessageConstants.QUEUE_RULES), null, jmsCorrelationID);
} catch (JAXBException | MessageException | JMSException e) {
sendError(message, e);
}
}
use of eu.europa.ec.fisheries.uvms.commons.message.api.MessageException in project UVMS-ActivityModule-APP by UnionVMS.
the class ActivityRulesModuleServiceBean method sendSyncAsyncFaReportToRules.
@Override
public void sendSyncAsyncFaReportToRules(FLUXFAReportMessage faReportXMLObj, String onValue, SyncAsyncRequestType type, String jmsMessageCorrId) throws ActivityModuleException {
String sendTo = extractOwnerFromFLUXReportDocument(faReportXMLObj.getFLUXReportDocument());
if (StringUtils.isEmpty(sendTo)) {
throw new ActivityModuleException("Owner for the provided FLUXFAReportMessage was not found, so FLUXFAReportMessage won't be sent!");
}
try {
SubscriptionPermissionResponse subscriptionPermissionResponse = permissionChecker.checkPermissionForFaReport(faReportXMLObj);
if (SubscriptionPermissionAnswer.YES.equals(subscriptionPermissionResponse.getSubscriptionCheck())) {
final List<SubscriptionParameter> parameters = subscriptionPermissionResponse.getParameters();
String dataFlow = extractParameterByName(parameters, "DF");
// TODO : mocking up df value untill subscription is ready
if (StringUtils.isEmpty(dataFlow)) {
dataFlow = "urn:un:unece:uncefact:fisheries:FLUX:FA:EU:2";
}
// TODO : END Mocking
if (StringUtils.isEmpty(dataFlow)) {
log.error("[ERROR] Subscription is missing the dataFlow parameter! Cannot send FaQuery! ");
throw new ActivityModuleException("Subscription is missing the dataFlow parameter! Cannot send FaQuery!");
}
String logId = null;
if (faReportXMLObj.getFLUXReportDocument() != null && CollectionUtils.isNotEmpty(faReportXMLObj.getFLUXReportDocument().getIDS())) {
logId = faReportXMLObj.getFLUXReportDocument().getIDS().get(0).getValue();
}
final String faReportXMLStr = JAXBMarshaller.marshallJaxBObjectToString(faReportXMLObj);
// TODO : change this values (username, senderOrReceiver (Node name?)) when got answer from CEDRIC
final String sendFLUXFAReportMessageRequest = RulesModuleRequestMapper.createSendFLUXFAReportMessageRequest(faReportXMLStr, "FLUX", logId, dataFlow, "BEL", onValue, isEmptyReportMessage(faReportXMLObj));
if (SyncAsyncRequestType.SYNC.equals(type)) {
activityResponseQueueProducer.sendMessageWithSpecificIds(sendFLUXFAReportMessageRequest, activityConsumerBean.getDestination(), null, null, jmsMessageCorrId);
} else {
rulesProducerBean.sendModuleMessage(sendFLUXFAReportMessageRequest, activityConsumerBean.getDestination());
}
} else {
throw new ActivityModuleException("Error while trying to prepare the transmission of FaReportMessage!");
}
} catch (MessageException | RulesModelMapperException | ActivityModelMarshallException e) {
log.error("[ERROR] Error while trying to ActivityRulesModuleService.composeAndSendTripUpdateFaQueryToRules(...)!", e);
throw new ActivityModuleException("JAXBException or MessageException!", e);
}
}
Aggregations