Commit e83d69c40ced610b0cfc7db05424b8b4bb43e73f

Authored by YevhenBondarenko
Committed by Andrew Shvayka
1 parent d380ac71

isolated tenant improvements

... ... @@ -28,6 +28,7 @@ import org.springframework.web.bind.annotation.ResponseBody;
28 28 import org.springframework.web.bind.annotation.ResponseStatus;
29 29 import org.springframework.web.bind.annotation.RestController;
30 30 import org.thingsboard.server.common.data.Tenant;
  31 +import org.thingsboard.server.common.data.exception.ThingsboardErrorCode;
31 32 import org.thingsboard.server.common.data.exception.ThingsboardException;
32 33 import org.thingsboard.server.common.data.id.TenantId;
33 34 import org.thingsboard.server.common.data.page.TextPageData;
... ... @@ -72,6 +73,16 @@ public class TenantController extends BaseController {
72 73 try {
73 74 boolean newTenant = tenant.getId() == null;
74 75
  76 + if (!newTenant) {
  77 + Tenant oldTenant = tenantService.findTenantById(tenant.getTenantId());
  78 + if (oldTenant.isIsolatedTbCore() != tenant.isIsolatedTbCore()) {
  79 + throw new ThingsboardException("Field isolatedTbCore from Tenant can't be changed.", ThingsboardErrorCode.BAD_REQUEST_PARAMS);
  80 + }
  81 + if (oldTenant.isIsolatedTbRuleEngine() != tenant.isIsolatedTbRuleEngine()) {
  82 + throw new ThingsboardException("Field isolatedTbRuleEngine from Tenant can't be changed.", ThingsboardErrorCode.BAD_REQUEST_PARAMS);
  83 + }
  84 + }
  85 +
75 86 Operation operation = newTenant ? Operation.CREATE : Operation.WRITE;
76 87
77 88 accessControlService.checkPermission(getCurrentUser(), Resource.TENANT, operation,
... ...
... ... @@ -221,7 +221,10 @@ public class SqlDatabaseUpgradeService implements DatabaseEntitiesUpgradeService
221 221 }
222 222 }
223 223 }
224   - conn.createStatement().execute("ALTER TABLE tenant ADD COLUMN isolated_tb_core boolean DEFAULT (false), ADD COLUMN isolated_tb_rule_engine boolean DEFAULT (false)");
  224 + try {
  225 + conn.createStatement().execute("ALTER TABLE tenant ADD COLUMN isolated_tb_core boolean DEFAULT (false), ADD COLUMN isolated_tb_rule_engine boolean DEFAULT (false)");
  226 + } catch (Exception e) {
  227 + }
225 228 log.info("Schema updated.");
226 229 }
227 230 break;
... ...
... ... @@ -47,14 +47,14 @@
47 47 </md-input-container>
48 48 <tb-contact contact="tenant" the-form="theForm" is-edit="isEdit"></tb-contact>
49 49 <md-input-container class="md-block">
50   - <md-checkbox ng-disabled="$root.loading || !isEdit"
  50 + <md-checkbox ng-disabled="{{theForm.$name != 'theForm'}}"
51 51 ng-model="tenant.isolatedTbCore">
52 52 {{'tenant.isolated-tb-core' | translate}}<br/>
53 53 <span style="font-size: 10px">{{'tenant.isolated-tb-core-details' | translate}}</span>
54 54 </md-checkbox>
55 55 </md-input-container>
56 56 <md-input-container class="md-block">
57   - <md-checkbox ng-disabled="$root.loading || !isEdit"
  57 + <md-checkbox ng-disabled="{{theForm.$name != 'theForm'}}"
58 58 ng-model="tenant.isolatedTbRuleEngine">
59 59 {{'tenant.isolated-tb-rule-engine' | translate}}<br/>
60 60 <span style="font-size: 10px">{{'tenant.isolated-tb-rule-engine-details' | translate}}</span>
... ...