use of eu.europa.ec.fisheries.schema.exchange.service.v1.SettingType 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.SettingType 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);
}
use of eu.europa.ec.fisheries.schema.exchange.service.v1.SettingType in project UVMS-ExchangeModule-APP by UnionVMS.
the class PluginServiceBean method setConfig.
@Override
public void setConfig(@Observes @ConfigSettingUpdatedEvent ConfigSettingEvent settingEvent) {
switch(settingEvent.getType()) {
case STORE:
// ConfigModule and/or Exchange module deployed
break;
case UPDATE:
LOG.info("ConfigModule updated parameter table with settings of plugins");
try {
String key = settingEvent.getKey();
String value = parameterService.getStringValue(key);
String settingKey;
String[] splittedKey = key.split(PARAMETER_DELIMETER);
if (splittedKey.length > 2) {
settingKey = key;
String serviceClassName = "";
for (int i = 0; i < splittedKey.length - 2; i++) {
serviceClassName += splittedKey[i] + ".";
}
serviceClassName += splittedKey[splittedKey.length - 2];
SettingType settingType = new SettingType();
settingType.setKey(key);
settingType.setValue(value);
updatePluginSetting(serviceClassName, settingType, "UVMS");
} else {
LOG.error("No key or malformed key sent in settingEvent: key: {}, value: {}", key, value);
}
} catch (ConfigServiceException e) {
LOG.error("Couldn't get updated parameter table value");
} catch (ExchangeServiceException e) {
LOG.error("Couldn't upsert settings in exchange");
} catch (ExchangeModelMarshallException e) {
LOG.error("Couldn't create plugin set config request");
} catch (ExchangeMessageException e) {
LOG.error("Couldn't send message to plugin");
}
break;
case DELETE:
LOG.info("ConfigModule removed parameter setting");
break;
}
}
use of eu.europa.ec.fisheries.schema.exchange.service.v1.SettingType in project UVMS-ExchangeModule-APP by UnionVMS.
the class PluginServiceBean method overrideSettingsFromConfig.
private void overrideSettingsFromConfig(RegisterServiceRequest registerServiceRequest) {
List<SettingType> currentRequestSettings = registerServiceRequest.getSettingList().getSetting();
try {
List<eu.europa.ec.fisheries.schema.config.types.v1.SettingType> configServiceSettings = configService.getSettings(registerServiceRequest.getService().getServiceClassName());
Map<String, SettingType> configServiceSettingsMap = putConfigSettingsInAMap(configServiceSettings);
if (!configServiceSettingsMap.isEmpty()) {
for (SettingType type : currentRequestSettings) {
SettingType configSettingType = configServiceSettingsMap.get(type.getKey());
if (configSettingType != null && !configSettingType.getValue().equalsIgnoreCase(type.getValue())) {
type.setValue(configSettingType.getValue());
}
}
}
} catch (ConfigServiceException e) {
LOG.error("Register service exception, cannot read Exchange settings from Config {} {}", registerServiceRequest, e.getMessage());
// Ignore when we can't get the settings from Config. It is possible there is no Config module setup.
}
}
use of eu.europa.ec.fisheries.schema.exchange.service.v1.SettingType in project UVMS-ExchangeModule-APP by UnionVMS.
the class MockData method getSettingList.
public static SettingListType getSettingList() {
SettingListType dto = new SettingListType();
SettingType setting = new SettingType();
setting.setKey(SETTING_KEY);
setting.setValue("setting.value");
dto.getSetting().add(setting);
return dto;
}
Aggregations