use of eu.europa.ec.fisheries.uvms.exchange.service.exception.ExchangeServiceException in project UVMS-ExchangeModule-APP by UnionVMS.
the class PluginServiceBean method updatePluginSetting.
@Override
public void updatePluginSetting(@Observes @UpdatePluginSettingEvent ExchangeMessageEvent settingEvent) {
LOG.info("update plugin setting from module queue:{}", settingEvent);
try {
TextMessage jmsMessage = settingEvent.getJmsMessage();
UpdatePluginSettingRequest request = JAXBMarshaller.unmarshallTextMessage(jmsMessage, UpdatePluginSettingRequest.class);
updatePluginSetting(request.getServiceClassName(), request.getSetting(), request.getUsername());
String text = ExchangeModuleResponseMapper.mapUpdateSettingResponse(ExchangeModuleResponseMapper.mapAcknowledgeTypeOK());
producer.sendModuleResponseMessage(settingEvent.getJmsMessage(), text);
} catch (ExchangeModelMarshallException | ExchangeServiceException | ExchangeMessageException e) {
LOG.error("Couldn't unmarshall update setting request");
settingEvent.setErrorFault(ExchangeModuleResponseMapper.createFaultMessage(FaultCode.EXCHANGE_EVENT_SERVICE, "Couldn't update plugin setting"));
producer.sendModuleErrorResponseMessage(settingEvent);
}
}
use of eu.europa.ec.fisheries.uvms.exchange.service.exception.ExchangeServiceException in project UVMS-ExchangeModule-APP by UnionVMS.
the class PluginServiceBean method start.
@Override
public boolean start(String serviceClassName) throws ExchangeServiceException {
if (serviceClassName == null) {
throw new InputArgumentException("No service to start");
}
try {
if (isServiceRegistered(serviceClassName)) {
String text = ExchangePluginRequestMapper.createStartRequest();
producer.sendEventBusMessage(text, serviceClassName);
return true;
} else {
throw new ExchangeServiceException("Service with service class name: " + serviceClassName + " does not exist");
}
} catch (ExchangeModelMarshallException e) {
throw new ExchangeServiceException("[ Couldn't map start request for " + serviceClassName + " ]");
} catch (ExchangeMessageException e) {
throw new ExchangeServiceException("[ Couldn't send start request for " + serviceClassName + " ]");
}
}
use of eu.europa.ec.fisheries.uvms.exchange.service.exception.ExchangeServiceException 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 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.exchange.service.exception.ExchangeServiceException in project UVMS-ExchangeModule-APP by UnionVMS.
the class ExchangeEventIncomingServiceBean method processAcknowledge.
@Override
public void processAcknowledge(@Observes @ExchangeLogEvent ExchangeMessageEvent message) {
log.info("Process acknowledge:{}", message);
try {
AcknowledgeResponse response = JAXBMarshaller.unmarshallTextMessage(message.getJmsMessage(), AcknowledgeResponse.class);
AcknowledgeType acknowledge = response.getResponse();
String serviceClassName = response.getServiceClassName();
ExchangePluginMethod method = response.getMethod();
switch(method) {
case SET_COMMAND:
// Only Acknowledge for poll should have a poll status set
if (acknowledge.getPollStatus() != null && acknowledge.getPollStatus().getPollId() != null) {
handleSetPollStatusAcknowledge(method, serviceClassName, acknowledge);
} else {
handleUpdateExchangeLogAcknowledge(method, serviceClassName, acknowledge);
}
break;
case SET_REPORT:
handleUpdateExchangeLogAcknowledge(method, serviceClassName, acknowledge);
break;
case START:
handleUpdateServiceAcknowledge(serviceClassName, acknowledge, StatusType.STARTED);
pluginStatusEvent.fire(createNotificationMessage(serviceClassName, true));
break;
case STOP:
handleUpdateServiceAcknowledge(serviceClassName, acknowledge, StatusType.STOPPED);
pluginStatusEvent.fire(createNotificationMessage(serviceClassName, false));
break;
case SET_CONFIG:
default:
handleAcknowledge(method, serviceClassName, acknowledge);
break;
}
} catch (ExchangeModelMarshallException e) {
log.error("Process acknowledge couldn't be marshalled {} {}", message, e);
} catch (ExchangeServiceException e) {
// TODO Audit.log() couldn't process acknowledge in exchange service
log.error("Couldn't process acknowledge in exchange service:{} {} ", message, e.getMessage());
}
}
use of eu.europa.ec.fisheries.uvms.exchange.service.exception.ExchangeServiceException in project UVMS-ExchangeModule-APP by UnionVMS.
the class ExchangeServiceBean method registerService.
/**
* {@inheritDoc}
*
* @param data
* @throws ExchangeServiceException
*/
@Override
public ServiceResponseType registerService(ServiceType data, CapabilityListType capabilityList, SettingListType settingList, String username) throws ExchangeServiceException {
LOG.info("Register service invoked in service layer: {} {}", data, username);
try {
ServiceResponseType serviceResponseType = serviceRegistryModel.registerService(data, capabilityList, settingList, username);
sendAuditLogMessageForRegisterService(compressServiceClassName(serviceResponseType.getServiceClassName()), username);
return serviceResponseType;
} catch (ExchangeModelMapperException ex) {
throw new ExchangeServiceException(ex.getMessage());
} catch (ExchangeModelException e) {
throw new ExchangeServiceException(e.getMessage());
}
}
Aggregations