Search in sources :

Example 6 with DefaultTenantProfileConfiguration

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

the class DeviceDataValidator method validateCreate.

@Override
protected void validateCreate(TenantId tenantId, Device device) {
    DefaultTenantProfileConfiguration profileConfiguration = (DefaultTenantProfileConfiguration) tenantProfileCache.get(tenantId).getProfileData().getConfiguration();
    long maxDevices = profileConfiguration.getMaxDevices();
    validateNumberOfEntitiesPerTenant(tenantId, deviceDao, maxDevices, EntityType.DEVICE);
}
Also used : DefaultTenantProfileConfiguration(org.thingsboard.server.common.data.tenant.profile.DefaultTenantProfileConfiguration)

Example 7 with DefaultTenantProfileConfiguration

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

the class OtaPackageDataValidator method validateUpdate.

@Override
protected void validateUpdate(TenantId tenantId, OtaPackage otaPackage) {
    OtaPackage otaPackageOld = otaPackageDao.findById(tenantId, otaPackage.getUuidId());
    validateUpdate(otaPackage, otaPackageOld);
    if (otaPackageOld.getData() != null && !otaPackageOld.getData().equals(otaPackage.getData())) {
        throw new DataValidationException("Updating otaPackage data is prohibited!");
    }
    if (otaPackageOld.getData() == null && otaPackage.getData() != null) {
        DefaultTenantProfileConfiguration profileConfiguration = (DefaultTenantProfileConfiguration) tenantProfileCache.get(tenantId).getProfileData().getConfiguration();
        long maxOtaPackagesInBytes = profileConfiguration.getMaxOtaPackagesInBytes();
        validateMaxSumDataSizePerTenant(tenantId, otaPackageDao, maxOtaPackagesInBytes, otaPackage.getDataSize(), OTA_PACKAGE);
    }
}
Also used : DataValidationException(org.thingsboard.server.dao.exception.DataValidationException) OtaPackage(org.thingsboard.server.common.data.OtaPackage) DefaultTenantProfileConfiguration(org.thingsboard.server.common.data.tenant.profile.DefaultTenantProfileConfiguration)

Example 8 with DefaultTenantProfileConfiguration

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

the class OtaPackageDataValidator method validateCreate.

@Override
protected void validateCreate(TenantId tenantId, OtaPackage otaPackage) {
    DefaultTenantProfileConfiguration profileConfiguration = (DefaultTenantProfileConfiguration) tenantProfileCache.get(tenantId).getProfileData().getConfiguration();
    long maxOtaPackagesInBytes = profileConfiguration.getMaxOtaPackagesInBytes();
    validateMaxSumDataSizePerTenant(tenantId, otaPackageDao, maxOtaPackagesInBytes, otaPackage.getDataSize(), OTA_PACKAGE);
}
Also used : DefaultTenantProfileConfiguration(org.thingsboard.server.common.data.tenant.profile.DefaultTenantProfileConfiguration)

Example 9 with DefaultTenantProfileConfiguration

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

the class DefaultSystemDataLoaderService method createDefaultTenantProfiles.

@Override
public void createDefaultTenantProfiles() throws Exception {
    tenantProfileService.findOrCreateDefaultTenantProfile(TenantId.SYS_TENANT_ID);
    TenantProfileData tenantProfileData = new TenantProfileData();
    tenantProfileData.setConfiguration(new DefaultTenantProfileConfiguration());
    TenantProfile isolatedTbCoreProfile = new TenantProfile();
    isolatedTbCoreProfile.setDefault(false);
    isolatedTbCoreProfile.setName("Isolated TB Core");
    isolatedTbCoreProfile.setDescription("Isolated TB Core tenant profile");
    isolatedTbCoreProfile.setIsolatedTbCore(true);
    isolatedTbCoreProfile.setIsolatedTbRuleEngine(false);
    isolatedTbCoreProfile.setProfileData(tenantProfileData);
    try {
        tenantProfileService.saveTenantProfile(TenantId.SYS_TENANT_ID, isolatedTbCoreProfile);
    } catch (DataValidationException e) {
        log.warn(e.getMessage());
    }
    TenantProfile isolatedTbRuleEngineProfile = new TenantProfile();
    isolatedTbRuleEngineProfile.setDefault(false);
    isolatedTbRuleEngineProfile.setName("Isolated TB Rule Engine");
    isolatedTbRuleEngineProfile.setDescription("Isolated TB Rule Engine tenant profile");
    isolatedTbRuleEngineProfile.setIsolatedTbCore(false);
    isolatedTbRuleEngineProfile.setIsolatedTbRuleEngine(true);
    isolatedTbRuleEngineProfile.setProfileData(tenantProfileData);
    try {
        tenantProfileService.saveTenantProfile(TenantId.SYS_TENANT_ID, isolatedTbRuleEngineProfile);
    } catch (DataValidationException e) {
        log.warn(e.getMessage());
    }
    TenantProfile isolatedTbCoreAndTbRuleEngineProfile = new TenantProfile();
    isolatedTbCoreAndTbRuleEngineProfile.setDefault(false);
    isolatedTbCoreAndTbRuleEngineProfile.setName("Isolated TB Core and TB Rule Engine");
    isolatedTbCoreAndTbRuleEngineProfile.setDescription("Isolated TB Core and TB Rule Engine tenant profile");
    isolatedTbCoreAndTbRuleEngineProfile.setIsolatedTbCore(true);
    isolatedTbCoreAndTbRuleEngineProfile.setIsolatedTbRuleEngine(true);
    isolatedTbCoreAndTbRuleEngineProfile.setProfileData(tenantProfileData);
    try {
        tenantProfileService.saveTenantProfile(TenantId.SYS_TENANT_ID, isolatedTbCoreAndTbRuleEngineProfile);
    } catch (DataValidationException e) {
        log.warn(e.getMessage());
    }
}
Also used : DataValidationException(org.thingsboard.server.dao.exception.DataValidationException) 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)

Example 10 with DefaultTenantProfileConfiguration

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

the class TenantProfile method createDefaultTenantProfileData.

public TenantProfileData createDefaultTenantProfileData() {
    TenantProfileData tpd = new TenantProfileData();
    tpd.setConfiguration(new DefaultTenantProfileConfiguration());
    return tpd;
}
Also used : TenantProfileData(org.thingsboard.server.common.data.tenant.profile.TenantProfileData) DefaultTenantProfileConfiguration(org.thingsboard.server.common.data.tenant.profile.DefaultTenantProfileConfiguration)

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