Commit e83d69c40ced610b0cfc7db05424b8b4bb43e73f
Committed by
Andrew Shvayka
1 parent
d380ac71
isolated tenant improvements
Showing
3 changed files
with
17 additions
and
3 deletions
@@ -28,6 +28,7 @@ import org.springframework.web.bind.annotation.ResponseBody; | @@ -28,6 +28,7 @@ import org.springframework.web.bind.annotation.ResponseBody; | ||
28 | import org.springframework.web.bind.annotation.ResponseStatus; | 28 | import org.springframework.web.bind.annotation.ResponseStatus; |
29 | import org.springframework.web.bind.annotation.RestController; | 29 | import org.springframework.web.bind.annotation.RestController; |
30 | import org.thingsboard.server.common.data.Tenant; | 30 | import org.thingsboard.server.common.data.Tenant; |
31 | +import org.thingsboard.server.common.data.exception.ThingsboardErrorCode; | ||
31 | import org.thingsboard.server.common.data.exception.ThingsboardException; | 32 | import org.thingsboard.server.common.data.exception.ThingsboardException; |
32 | import org.thingsboard.server.common.data.id.TenantId; | 33 | import org.thingsboard.server.common.data.id.TenantId; |
33 | import org.thingsboard.server.common.data.page.TextPageData; | 34 | import org.thingsboard.server.common.data.page.TextPageData; |
@@ -72,6 +73,16 @@ public class TenantController extends BaseController { | @@ -72,6 +73,16 @@ public class TenantController extends BaseController { | ||
72 | try { | 73 | try { |
73 | boolean newTenant = tenant.getId() == null; | 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 | Operation operation = newTenant ? Operation.CREATE : Operation.WRITE; | 86 | Operation operation = newTenant ? Operation.CREATE : Operation.WRITE; |
76 | 87 | ||
77 | accessControlService.checkPermission(getCurrentUser(), Resource.TENANT, operation, | 88 | accessControlService.checkPermission(getCurrentUser(), Resource.TENANT, operation, |
@@ -221,7 +221,10 @@ public class SqlDatabaseUpgradeService implements DatabaseEntitiesUpgradeService | @@ -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 | log.info("Schema updated."); | 228 | log.info("Schema updated."); |
226 | } | 229 | } |
227 | break; | 230 | break; |
@@ -47,14 +47,14 @@ | @@ -47,14 +47,14 @@ | ||
47 | </md-input-container> | 47 | </md-input-container> |
48 | <tb-contact contact="tenant" the-form="theForm" is-edit="isEdit"></tb-contact> | 48 | <tb-contact contact="tenant" the-form="theForm" is-edit="isEdit"></tb-contact> |
49 | <md-input-container class="md-block"> | 49 | <md-input-container class="md-block"> |
50 | - <md-checkbox ng-disabled="$root.loading || !isEdit" | 50 | + <md-checkbox ng-disabled="{{theForm.$name != 'theForm'}}" |
51 | ng-model="tenant.isolatedTbCore"> | 51 | ng-model="tenant.isolatedTbCore"> |
52 | {{'tenant.isolated-tb-core' | translate}}<br/> | 52 | {{'tenant.isolated-tb-core' | translate}}<br/> |
53 | <span style="font-size: 10px">{{'tenant.isolated-tb-core-details' | translate}}</span> | 53 | <span style="font-size: 10px">{{'tenant.isolated-tb-core-details' | translate}}</span> |
54 | </md-checkbox> | 54 | </md-checkbox> |
55 | </md-input-container> | 55 | </md-input-container> |
56 | <md-input-container class="md-block"> | 56 | <md-input-container class="md-block"> |
57 | - <md-checkbox ng-disabled="$root.loading || !isEdit" | 57 | + <md-checkbox ng-disabled="{{theForm.$name != 'theForm'}}" |
58 | ng-model="tenant.isolatedTbRuleEngine"> | 58 | ng-model="tenant.isolatedTbRuleEngine"> |
59 | {{'tenant.isolated-tb-rule-engine' | translate}}<br/> | 59 | {{'tenant.isolated-tb-rule-engine' | translate}}<br/> |
60 | <span style="font-size: 10px">{{'tenant.isolated-tb-rule-engine-details' | translate}}</span> | 60 | <span style="font-size: 10px">{{'tenant.isolated-tb-rule-engine-details' | translate}}</span> |