public Tenant() { this.configuration = new TenantConfiguration(); }
TenantConfiguration configuration; if (Strings.isNullOrEmpty(result.getString("configuration"))) { configuration = new TenantConfiguration(configurationVersion, Collections.<String, Serializable>emptyMap()); } else { try { Map<String, Serializable> data = mapper.readValue(result.getString("configuration"), new TypeReference<Map<String, Object>>() {}); configuration = new TenantConfiguration(configurationVersion, data); } catch (IOException e) { final Logger logger = LoggerFactory.getLogger(TenantMapper.class); logger.error("Failed to load configuration for tenant with slug [{}]", e); configuration = new TenantConfiguration();
@Override public Tenant createDefaultTenant() throws EntityAlreadyExistsException { if (this.tenantStore.get().findAll(1, 0).size() != 0) { throw new EntityAlreadyExistsException("Cannot create default tenant : a tenant already exists"); } String slug = multitenancySettings.getDefaultTenantSlug(); TenantConfiguration configuration = new TenantConfiguration(); Tenant tenant = new Tenant(slug, configuration); try { this.tenantStore.get().create(tenant); } catch (InvalidEntityException e) { } return this.tenantStore.get().findBySlug(slug); }
TenantConfiguration configuration; if (Strings.isNullOrEmpty(result.getString("tenant_entity_configuration"))) { configuration = new TenantConfiguration(configurationVersion, Collections.<String, Serializable>emptyMap()); } else { try { Map<String, Serializable> data = mapper.readValue(result.getString("tenant_entity_configuration"), new TypeReference<Map<String, Object>>(){}); configuration = new TenantConfiguration(configurationVersion, data); } catch (IOException e) { final Logger logger = LoggerFactory.getLogger(TenantMapper.class); logger.error("Failed to load configuration for tenant with slug [{}]", e); configuration = new TenantConfiguration();
public void updateSettings(Map<String, Serializable> data) { ValidConfigurationEnforcer enforcer = new ValidConfigurationEnforcer(getExposedPlatformSettingsAsJson(), data); ValidConfigurationEnforcer.ValidationResult result = enforcer.enforce(); TenantConfiguration configuration = new TenantConfiguration(TenantConfiguration.CURRENT_VERSION, result.getResult()); this.tenantStore.get().updateConfiguration(configuration); // Invalidates the cached configuration for the tenant updating its configuration // TODO: do this from the configuration store instead this.configurations.invalidate(this.context.getTenant().getId()); // TODO throw an exception here when there are validation errors, so that it can be acknowledged to the // REST accounts consumer ? (meaning the operation has been partially successful only) }