use of eu.europa.ec.fisheries.schema.exchange.service.v1.ServiceResponseType 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());
}
}
use of eu.europa.ec.fisheries.schema.exchange.service.v1.ServiceResponseType in project UVMS-ExchangeModule-APP by UnionVMS.
the class PluginServiceBean method checkPluginType.
private boolean checkPluginType(PluginType pluginType, String responseTopicMessageSelector, String messageId) throws ExchangeModelMarshallException, ExchangeMessageException {
LOG.debug("checkPluginType " + pluginType.name());
if (PluginType.EMAIL == pluginType || PluginType.NAF == pluginType) {
// Check if type already exists
List<PluginType> type = new ArrayList<>();
type.add(pluginType);
try {
List<ServiceResponseType> services = exchangeService.getServiceList(type);
if (!services.isEmpty()) {
for (ServiceResponseType service : services) {
if (service.isActive()) {
// TODO log to audit log
String response = ExchangePluginResponseMapper.mapToRegisterServiceResponseNOK(messageId, "Plugin of " + pluginType + " already registered. Only one is allowed.");
producer.sendEventBusMessage(response, responseTopicMessageSelector);
return false;
}
}
}
} catch (ExchangeServiceException e) {
String response = ExchangePluginResponseMapper.mapToRegisterServiceResponseNOK(messageId, "Exchange service exception when registering plugin [ " + e.getMessage() + " ]");
producer.sendEventBusMessage(response, responseTopicMessageSelector);
return false;
}
}
return true;
}
use of eu.europa.ec.fisheries.schema.exchange.service.v1.ServiceResponseType in project UVMS-ExchangeModule-APP by UnionVMS.
the class PluginServiceBean method unregisterService.
@Override
public void unregisterService(@Observes @UnRegisterServiceEvent PluginMessageEvent event) {
LOG.info("unregister service:{}", event);
TextMessage textMessage = event.getJmsMessage();
ServiceResponseType service = null;
try {
UnregisterServiceRequest unregister = JAXBMarshaller.unmarshallTextMessage(textMessage, UnregisterServiceRequest.class);
service = exchangeService.unregisterService(unregister.getService(), unregister.getService().getName());
String serviceClassName = service.getServiceClassName();
// NO ack back to plugin
// TODO log to exchange log
} catch (ExchangeModelMarshallException | ExchangeServiceException e) {
LOG.error("Unregister service exception " + e.getMessage());
errorEvent.fire(new PluginMessageEvent(textMessage, service, ExchangePluginResponseMapper.mapToPluginFaultResponse(FaultCode.EXCHANGE_PLUGIN_EVENT.getCode(), "Exception when unregister service")));
}
}
use of eu.europa.ec.fisheries.schema.exchange.service.v1.ServiceResponseType in project UVMS-ExchangeModule-APP by UnionVMS.
the class PluginServiceBean method registerService.
private void registerService(RegisterServiceRequest register, String messageId) throws ExchangeModelMarshallException, ExchangeMessageException {
try {
overrideSettingsFromConfig(register);
ServiceResponseType service = exchangeService.registerService(register.getService(), register.getCapabilityList(), register.getSettingList(), register.getService().getName());
// push to config module
try {
String serviceClassName = register.getService().getServiceClassName();
SettingListType settings = register.getSettingList();
for (SettingType setting : settings.getSetting()) {
String description = "Plugin " + serviceClassName + " " + setting.getKey() + " setting";
configService.pushSettingToConfig(SettingTypeMapper.map(setting.getKey(), setting.getValue(), description), false);
}
} catch (ConfigServiceException e) {
LOG.error("Couldn't register plugin settings in config parameter table");
}
// TODO log to exchange log
String response = ExchangePluginResponseMapper.mapToRegisterServiceResponseOK(messageId, service);
producer.sendEventBusMessage(response, register.getService().getServiceResponseMessageName());
setServiceStatusOnRegister(register.getService().getServiceClassName());
} catch (ExchangeServiceException | ExchangeModelMapperException e) {
String response = ExchangePluginResponseMapper.mapToRegisterServiceResponseNOK(messageId, "Exchange service exception when registering plugin [ " + e.getMessage() + " ]");
producer.sendEventBusMessage(response, register.getService().getServiceResponseMessageName());
}
}
use of eu.europa.ec.fisheries.schema.exchange.service.v1.ServiceResponseType in project UVMS-ExchangeModule-APP by UnionVMS.
the class PluginServiceBean method updatePluginSetting.
private void updatePluginSetting(String serviceClassName, SettingType updatedSetting, String username) throws ExchangeServiceException, ExchangeModelMarshallException, ExchangeMessageException {
SettingListType settingListType = new SettingListType();
settingListType.getSetting().add(updatedSetting);
ServiceResponseType service = exchangeService.upsertSettings(serviceClassName, settingListType, username);
// Send the plugin settings to the topic where all plugins should listen to
String text = ExchangePluginRequestMapper.createSetConfigRequest(service.getSettingList());
producer.sendEventBusMessage(text, serviceClassName);
}
Aggregations