public void updateSettings(String module, Map<String, Serializable> configuration) throws NoSuchModuleException { if (!this.exposedSettings.containsKey(module)) { throw new NoSuchModuleException(); } Tenant tenant = this.context.getTenant(); TenantConfiguration currentConfiguration = tenant.getConfiguration(); Map<String, Serializable> data = Maps.newHashMap(currentConfiguration.getData()); data.put(module, Maps.newHashMap(configuration)); this.updateSettings(data); }
@Override public Map<String, Serializable> call() { synchronized (lock) { logger.debug("loading cache configuration value for tenant {}", tenant.getSlug()); Map<String, Serializable> tenantConfiguration = tenant.getConfiguration(); Map<String, Serializable> platformConfiguration = getExposedPlatformSettingsAsJson(); ConfigurationJsonMerger merger = new ConfigurationJsonMerger(platformConfiguration, tenantConfiguration); return merger.merge(); } } });
@Override public Tenant create(Tenant tenant) throws EntityAlreadyExistsException, InvalidEntityException { if (this.dao.findBySlug(TENANT_TABLE_NAME, tenant.getSlug()) != null) { throw new EntityAlreadyExistsException(); } this.dao.begin(); TenantConfiguration configuration = tenant.getConfiguration(); try { String configurationAsJson = convertConfigurationToJSON(configuration); UUID id = UUID.randomUUID(); tenant.setId(id); this.dao.createEntity(tenant, TENANT_TABLE_NAME); this.dao.create(tenant, configuration.getVersion(), configurationAsJson); this.dao.createOrUpdateAddons(tenant); return tenant; } catch (JsonProcessingException e) { throw new RuntimeException("Failed to create tenant", e); } finally { this.dao.commit(); } }