Search in sources :

Example 21 with DefaultTenantProfileConfiguration

use of org.thingsboard.server.common.data.tenant.profile.DefaultTenantProfileConfiguration in project thingsboard by thingsboard.

the class ResourceDataValidator method validateCreate.

@Override
protected void validateCreate(TenantId tenantId, TbResource resource) {
    if (tenantId != null && !TenantId.SYS_TENANT_ID.equals(tenantId)) {
        DefaultTenantProfileConfiguration profileConfiguration = (DefaultTenantProfileConfiguration) tenantProfileCache.get(tenantId).getProfileData().getConfiguration();
        long maxSumResourcesDataInBytes = profileConfiguration.getMaxResourcesInBytes();
        validateMaxSumDataSizePerTenant(tenantId, resourceDao, maxSumResourcesDataInBytes, resource.getData().length(), TB_RESOURCE);
    }
}
Also used : DefaultTenantProfileConfiguration(org.thingsboard.server.common.data.tenant.profile.DefaultTenantProfileConfiguration)

Example 22 with DefaultTenantProfileConfiguration

use of org.thingsboard.server.common.data.tenant.profile.DefaultTenantProfileConfiguration in project thingsboard by thingsboard.

the class BaseTenantServiceTest method testSaveTenantWithIsolatedProfileInMonolithSetup.

@Test(expected = DataValidationException.class)
public void testSaveTenantWithIsolatedProfileInMonolithSetup() {
    TenantProfile tenantProfile = new TenantProfile();
    tenantProfile.setName("Isolated Tenant Profile");
    TenantProfileData profileData = new TenantProfileData();
    profileData.setConfiguration(new DefaultTenantProfileConfiguration());
    tenantProfile.setProfileData(profileData);
    tenantProfile.setDefault(false);
    tenantProfile.setIsolatedTbCore(true);
    tenantProfile.setIsolatedTbRuleEngine(true);
    TenantProfile isolatedTenantProfile = tenantProfileService.saveTenantProfile(TenantId.SYS_TENANT_ID, tenantProfile);
    Tenant tenant = new Tenant();
    tenant.setTitle("Tenant");
    tenant.setTenantProfileId(isolatedTenantProfile.getId());
    tenantService.saveTenant(tenant);
}
Also used : Tenant(org.thingsboard.server.common.data.Tenant) TenantProfileData(org.thingsboard.server.common.data.tenant.profile.TenantProfileData) TenantProfile(org.thingsboard.server.common.data.TenantProfile) DefaultTenantProfileConfiguration(org.thingsboard.server.common.data.tenant.profile.DefaultTenantProfileConfiguration) Test(org.junit.Test)

Aggregations

DefaultTenantProfileConfiguration (org.thingsboard.server.common.data.tenant.profile.DefaultTenantProfileConfiguration)22 TenantProfile (org.thingsboard.server.common.data.TenantProfile)8 TenantProfileData (org.thingsboard.server.common.data.tenant.profile.TenantProfileData)7 TenantId (org.thingsboard.server.common.data.id.TenantId)3 ArrayList (java.util.ArrayList)2 Date (java.util.Date)2 LinkedHashMap (java.util.LinkedHashMap)2 List (java.util.List)2 Map (java.util.Map)2 Test (org.junit.Test)2 Scheduled (org.springframework.scheduling.annotation.Scheduled)2 PageLink (org.thingsboard.server.common.data.page.PageLink)2 DataValidationException (org.thingsboard.server.dao.exception.DataValidationException)2 FutureCallback (com.google.common.util.concurrent.FutureCallback)1 JsonElement (com.google.gson.JsonElement)1 JsonObject (com.google.gson.JsonObject)1 JsonParseException (com.google.gson.JsonParseException)1 JsonParser (com.google.gson.JsonParser)1 JsonPrimitive (com.google.gson.JsonPrimitive)1 Arrays (java.util.Arrays)1