use of eu.europa.ec.fisheries.schema.exchange.service.v1.SettingListType 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.SettingListType 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.SettingListType 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;
}
use of eu.europa.ec.fisheries.schema.exchange.service.v1.SettingListType in project UVMS-ExchangeModule-APP by UnionVMS.
the class MapperTest method testEntityAndModelToEntity.
@Test
public void testEntityAndModelToEntity() throws ExchangeDaoException, ExchangeDaoMappingException {
Integer id = 1;
Service entity = MockData.getEntity(id);
ServiceType service = MockData.getModel(1);
CapabilityListType capabilityListType = MockData.getCapabilityList();
SettingListType settingListType = MockData.getSettingList();
// mockDaoToEntity();
Service result = mapper.toServiceEntity(entity, service, capabilityListType, settingListType, "TEST");
assertSame(entity.getName(), result.getName());
assertSame(entity.getServiceClassName(), result.getServiceClassName());
}
use of eu.europa.ec.fisheries.schema.exchange.service.v1.SettingListType in project UVMS-ExchangeModule-APP by UnionVMS.
the class MapperTest method testUpsert.
@Test
public void testUpsert() {
String newValue = "NEW_VALUE";
Service entity = MockData.getEntity(1);
entity.setServiceCapabilityList(MockData.getEntityCapabilities(entity));
entity.setServiceSettingList(MockData.getEntitySettings(entity));
SettingListType updateSettings = new SettingListType();
SettingType updateSetting = new SettingType();
updateSetting.setKey(MockData.SETTING_KEY);
updateSetting.setValue(newValue);
updateSettings.getSetting().add(updateSetting);
List<ServiceSetting> list = mapper.mapSettingsList(entity, updateSettings, "TEST");
assertFalse(list.isEmpty());
for (ServiceSetting setting : list) {
assertSame(setting.getValue(), newValue);
}
SettingListType newSettings = new SettingListType();
SettingType newSetting = new SettingType();
newSetting.setKey("NEW.KEY");
newSetting.setValue("NEW.VALUE");
newSettings.getSetting().add(newSetting);
list = mapper.mapSettingsList(entity, newSettings, "TEST");
assertTrue(list.size() == 1);
}
Aggregations