use of eu.europa.ec.fisheries.uvms.exchange.model.exception.ExchangeModelMarshallException in project UVMS-ExchangeModule-APP by UnionVMS.
the class ExchangeEventIncomingServiceBean method processFLUXFAReportMessage.
@Override
public void processFLUXFAReportMessage(@Observes @SetFluxFAReportMessageEvent ExchangeMessageEvent message) {
try {
SetFLUXFAReportMessageRequest request = JAXBMarshaller.unmarshallTextMessage(message.getJmsMessage(), SetFLUXFAReportMessageRequest.class);
log.debug("Got FLUXFAReportMessage in exchange :" + request.getRequest());
ExchangeLogType exchangeLogType = exchangeLog.log(request, LogType.RCV_FLUX_FA_REPORT_MSG, ExchangeLogStatusTypeType.ISSUED, TypeRefType.FA_REPORT, request.getRequest(), true);
String msg = RulesModuleRequestMapper.createSetFLUXFAReportMessageRequest(extractPluginType(request), request.getRequest(), request.getUsername(), extractLogId(message, exchangeLogType), request.getFluxDataFlow(), request.getSenderOrReceiver(), request.getOnValue());
forwardToRules(msg, message, null);
} catch (RulesModelMapperException | ExchangeModelMarshallException e) {
log.error("Couldn't map to SetFLUXFAReportMessageRequest when processing FLUXFAReportMessage coming from fa-plugin!", e);
} catch (ExchangeLogException e) {
log.error("Couldn't log FAReportMessage received from plugin into database", e);
}
}
use of eu.europa.ec.fisheries.uvms.exchange.model.exception.ExchangeModelMarshallException in project UVMS-ExchangeModule-APP by UnionVMS.
the class ExchangeEventIncomingServiceBean method processFAQueryMessage.
@Override
public void processFAQueryMessage(@Observes @SetFaQueryMessageEvent ExchangeMessageEvent message) {
try {
SetFAQueryMessageRequest request = JAXBMarshaller.unmarshallTextMessage(message.getJmsMessage(), SetFAQueryMessageRequest.class);
log.debug("Got FAQueryMessage in exchange :" + request.getRequest());
ExchangeLogType exchangeLogType = exchangeLog.log(request, LogType.RECEIVE_FA_QUERY_MSG, ExchangeLogStatusTypeType.ISSUED, TypeRefType.FA_QUERY, request.getRequest(), true);
String msg = RulesModuleRequestMapper.createSetFaQueryMessageRequest(extractPluginType(request), request.getRequest(), request.getUsername(), extractLogId(message, exchangeLogType), request.getFluxDataFlow(), request.getSenderOrReceiver(), request.getOnValue());
forwardToRules(msg, message, null);
} catch (RulesModelMapperException | ExchangeModelMarshallException e) {
log.error("Couldn't map to SetFAQueryMessageRequest when processing FAQueryMessage coming from fa-plugin!", e);
} catch (ExchangeLogException e) {
log.error("Couldn't log FAQueryMessage received from plugin into database", e);
}
}
use of eu.europa.ec.fisheries.uvms.exchange.model.exception.ExchangeModelMarshallException in project UVMS-ExchangeModule-APP by UnionVMS.
the class ExchangeEventIncomingServiceBean method updateLogStatus.
@Override
public void updateLogStatus(@Observes @UpdateLogStatusEvent ExchangeMessageEvent message) {
try {
UpdateLogStatusRequest request = JAXBMarshaller.unmarshallTextMessage(message.getJmsMessage(), UpdateLogStatusRequest.class);
String logGuid = request.getLogGuid();
ExchangeLogStatusTypeType status = request.getNewStatus();
exchangeLog.updateStatus(logGuid, status);
} catch (ExchangeLogException e) {
fireExchangeFault(message, "Could not update the status of a message log.", e);
} catch (ExchangeModelMarshallException e) {
fireExchangeFault(message, "Could not unmarshall the incoming UpdateLogStatus message", e);
}
}
use of eu.europa.ec.fisheries.uvms.exchange.model.exception.ExchangeModelMarshallException in project UVMS-ExchangeModule-APP by UnionVMS.
the class ExchangeEventIncomingServiceBean method processMovement.
@Override
public void processMovement(@Observes @SetMovementEvent ExchangeMessageEvent message) {
try {
final TextMessage jmsMessage = message.getJmsMessage();
final String jmsMessageID = jmsMessage.getJMSMessageID();
SetMovementReportRequest request = JAXBMarshaller.unmarshallTextMessage(jmsMessage, SetMovementReportRequest.class);
log.info("[INFO] Processing Movement : {}", request);
String username;
SetReportMovementType setRepMovType = request.getRequest();
if (MovementSourceType.MANUAL.equals(setRepMovType.getMovement().getSource())) {
// A person has created a position
username = request.getUsername();
// Send some response to Movement, if it originated from there (manual movement)
ProcessedMovementAck response = MovementModuleResponseMapper.mapProcessedMovementAck(eu.europa.ec.fisheries.schema.movement.common.v1.AcknowledgeTypeType.OK, jmsMessageID, "Movement successfully processed");
producer.sendModuleAckMessage(jmsMessageID, MessageQueue.MOVEMENT_RESPONSE, JAXBMarshaller.marshallJaxBObjectToString(response));
} else {
// A plugin has reported a position
username = setRepMovType.getPluginType().name();
}
String pluginName = setRepMovType.getPluginName();
ServiceResponseType service = exchangeService.getService(pluginName);
PluginType pluginType = setRepMovType.getPluginType();
if (validate(setRepMovType, service, jmsMessage)) {
MovementBaseType baseMovement = setRepMovType.getMovement();
RawMovementType rawMovement = MovementMapper.getInstance().getMapper().map(baseMovement, RawMovementType.class);
final AssetId assetId = rawMovement.getAssetId();
if (assetId != null && assetId.getAssetIdList() != null) {
assetId.getAssetIdList().addAll(MovementMapper.mapAssetIdList(baseMovement.getAssetId().getAssetIdList()));
}
if (baseMovement.getMobileTerminalId() != null && baseMovement.getMobileTerminalId().getMobileTerminalIdList() != null) {
rawMovement.getMobileTerminal().getMobileTerminalIdList().addAll(MovementMapper.mapMobileTerminalIdList(baseMovement.getMobileTerminalId().getMobileTerminalIdList()));
}
rawMovement.setPluginType(pluginType.value());
rawMovement.setPluginName(pluginName);
rawMovement.setDateRecieved(setRepMovType.getTimestamp());
// TODO : Temporary - probably better to change corr id to have the same though the entire flow;
// TODO : then we can use this to send response to original caller from anywhere needed
rawMovement.setAckResponseMessageID(jmsMessageID);
log.info("[INFO] Logging received movement.");
exchangeLog.log(request, LogType.RECEIVE_MOVEMENT, ExchangeLogStatusTypeType.ISSUED, TypeRefType.MOVEMENT, JAXBMarshaller.marshallJaxBObjectToString(request), true);
forwardToRules(RulesModuleRequestMapper.createSetMovementReportRequest(PluginTypeMapper.map(pluginType), rawMovement, username), message, service);
log.info("[INFO] Finished forwarding received movement to rules module.");
} else {
log.debug("[ERROR] Validation error. Event sent to plugin {}", message);
}
} catch (ExchangeServiceException e) {
log.error("[ERROR] Couldn't get the Service type for the received message : {} {}", message, e);
} catch (ExchangeModelMarshallException e) {
log.error("[ERROR] Couldn't map to SetMovementReportRequest when processing movement from plugin:{} {}", message, e);
} catch (JMSException e) {
log.error("[ERROR] Failed to get response queue:{} {}", message, e);
} catch (RulesModelMapperException e) {
log.error("[ERROR] Failed to build Rules momvent request:{} {}", message, e);
} catch (ExchangeLogException e) {
log.error("[ERROR] Failed to log momvent request : {} {}", message, e);
}
}
use of eu.europa.ec.fisheries.uvms.exchange.model.exception.ExchangeModelMarshallException in project UVMS-ExchangeModule-APP by UnionVMS.
the class ExchangeEventIncomingServiceBean method receiveInvalidSalesMessage.
@Override
public void receiveInvalidSalesMessage(@Observes @ReceiveInvalidSalesMessageEvent ExchangeMessageEvent event) {
try {
ReceiveInvalidSalesMessage request = JAXBMarshaller.unmarshallTextMessage(event.getJmsMessage(), ReceiveInvalidSalesMessage.class);
exchangeLog.log(request, LogType.RECEIVE_SALES_REPORT, ExchangeLogStatusTypeType.FAILED, TypeRefType.SALES_REPORT, request.getRespondToInvalidMessageRequest(), true);
producer.sendMessageOnQueue(request.getRespondToInvalidMessageRequest(), MessageQueue.SALES);
} catch (ExchangeLogException e) {
firePluginFault(event, "Could not log the incoming invalid sales message", e);
} catch (ExchangeMessageException | ExchangeModelMarshallException e) {
firePluginFault(event, "Error when receiving an invalid sales message from FLUX", e);
}
}
Aggregations