|
@@ -319,17 +319,25 @@ public abstract class BaseController { |
|
@@ -319,17 +319,25 @@ public abstract class BaseController { |
319
|
}
|
319
|
}
|
320
|
|
320
|
|
321
|
<T> T checkNotNull(T reference) throws ThingsboardException {
|
321
|
<T> T checkNotNull(T reference) throws ThingsboardException {
|
|
|
322
|
+ return checkNotNull(reference, "Requested item wasn't found!");
|
|
|
323
|
+ }
|
|
|
324
|
+
|
|
|
325
|
+ <T> T checkNotNull(T reference, String notFoundMessage) throws ThingsboardException {
|
322
|
if (reference == null) {
|
326
|
if (reference == null) {
|
323
|
- throw new ThingsboardException("Requested item wasn't found!", ThingsboardErrorCode.ITEM_NOT_FOUND);
|
327
|
+ throw new ThingsboardException(notFoundMessage, ThingsboardErrorCode.ITEM_NOT_FOUND);
|
324
|
}
|
328
|
}
|
325
|
return reference;
|
329
|
return reference;
|
326
|
}
|
330
|
}
|
327
|
|
331
|
|
328
|
<T> T checkNotNull(Optional<T> reference) throws ThingsboardException {
|
332
|
<T> T checkNotNull(Optional<T> reference) throws ThingsboardException {
|
|
|
333
|
+ return checkNotNull(reference, "Requested item wasn't found!");
|
|
|
334
|
+ }
|
|
|
335
|
+
|
|
|
336
|
+ <T> T checkNotNull(Optional<T> reference, String notFoundMessage) throws ThingsboardException {
|
329
|
if (reference.isPresent()) {
|
337
|
if (reference.isPresent()) {
|
330
|
return reference.get();
|
338
|
return reference.get();
|
331
|
} else {
|
339
|
} else {
|
332
|
- throw new ThingsboardException("Requested item wasn't found!", ThingsboardErrorCode.ITEM_NOT_FOUND);
|
340
|
+ throw new ThingsboardException(notFoundMessage, ThingsboardErrorCode.ITEM_NOT_FOUND);
|
333
|
}
|
341
|
}
|
334
|
}
|
342
|
}
|
335
|
|
343
|
|
|
@@ -389,7 +397,7 @@ public abstract class BaseController { |
|
@@ -389,7 +397,7 @@ public abstract class BaseController { |
389
|
try {
|
397
|
try {
|
390
|
validateId(tenantId, INCORRECT_TENANT_ID + tenantId);
|
398
|
validateId(tenantId, INCORRECT_TENANT_ID + tenantId);
|
391
|
Tenant tenant = tenantService.findTenantById(tenantId);
|
399
|
Tenant tenant = tenantService.findTenantById(tenantId);
|
392
|
- checkNotNull(tenant);
|
400
|
+ checkNotNull(tenant, "Tenant with id [" + tenantId + "] is not found");
|
393
|
accessControlService.checkPermission(getCurrentUser(), Resource.TENANT, operation, tenantId, tenant);
|
401
|
accessControlService.checkPermission(getCurrentUser(), Resource.TENANT, operation, tenantId, tenant);
|
394
|
return tenant;
|
402
|
return tenant;
|
395
|
} catch (Exception e) {
|
403
|
} catch (Exception e) {
|
|
@@ -401,7 +409,7 @@ public abstract class BaseController { |
|
@@ -401,7 +409,7 @@ public abstract class BaseController { |
401
|
try {
|
409
|
try {
|
402
|
validateId(tenantId, INCORRECT_TENANT_ID + tenantId);
|
410
|
validateId(tenantId, INCORRECT_TENANT_ID + tenantId);
|
403
|
TenantInfo tenant = tenantService.findTenantInfoById(tenantId);
|
411
|
TenantInfo tenant = tenantService.findTenantInfoById(tenantId);
|
404
|
- checkNotNull(tenant);
|
412
|
+ checkNotNull(tenant, "Tenant with id [" + tenantId + "] is not found");
|
405
|
accessControlService.checkPermission(getCurrentUser(), Resource.TENANT, operation, tenantId, tenant);
|
413
|
accessControlService.checkPermission(getCurrentUser(), Resource.TENANT, operation, tenantId, tenant);
|
406
|
return tenant;
|
414
|
return tenant;
|
407
|
} catch (Exception e) {
|
415
|
} catch (Exception e) {
|
|
@@ -413,7 +421,7 @@ public abstract class BaseController { |
|
@@ -413,7 +421,7 @@ public abstract class BaseController { |
413
|
try {
|
421
|
try {
|
414
|
validateId(tenantProfileId, "Incorrect tenantProfileId " + tenantProfileId);
|
422
|
validateId(tenantProfileId, "Incorrect tenantProfileId " + tenantProfileId);
|
415
|
TenantProfile tenantProfile = tenantProfileService.findTenantProfileById(getTenantId(), tenantProfileId);
|
423
|
TenantProfile tenantProfile = tenantProfileService.findTenantProfileById(getTenantId(), tenantProfileId);
|
416
|
- checkNotNull(tenantProfile);
|
424
|
+ checkNotNull(tenantProfile, "Tenant profile with id [" + tenantProfileId + "] is not found");
|
417
|
accessControlService.checkPermission(getCurrentUser(), Resource.TENANT_PROFILE, operation);
|
425
|
accessControlService.checkPermission(getCurrentUser(), Resource.TENANT_PROFILE, operation);
|
418
|
return tenantProfile;
|
426
|
return tenantProfile;
|
419
|
} catch (Exception e) {
|
427
|
} catch (Exception e) {
|
|
@@ -429,7 +437,7 @@ public abstract class BaseController { |
|
@@ -429,7 +437,7 @@ public abstract class BaseController { |
429
|
try {
|
437
|
try {
|
430
|
validateId(customerId, "Incorrect customerId " + customerId);
|
438
|
validateId(customerId, "Incorrect customerId " + customerId);
|
431
|
Customer customer = customerService.findCustomerById(getTenantId(), customerId);
|
439
|
Customer customer = customerService.findCustomerById(getTenantId(), customerId);
|
432
|
- checkNotNull(customer);
|
440
|
+ checkNotNull(customer, "Customer with id [" + customerId + "] is not found");
|
433
|
accessControlService.checkPermission(getCurrentUser(), Resource.CUSTOMER, operation, customerId, customer);
|
441
|
accessControlService.checkPermission(getCurrentUser(), Resource.CUSTOMER, operation, customerId, customer);
|
434
|
return customer;
|
442
|
return customer;
|
435
|
} catch (Exception e) {
|
443
|
} catch (Exception e) {
|
|
@@ -441,7 +449,7 @@ public abstract class BaseController { |
|
@@ -441,7 +449,7 @@ public abstract class BaseController { |
441
|
try {
|
449
|
try {
|
442
|
validateId(userId, "Incorrect userId " + userId);
|
450
|
validateId(userId, "Incorrect userId " + userId);
|
443
|
User user = userService.findUserById(getCurrentUser().getTenantId(), userId);
|
451
|
User user = userService.findUserById(getCurrentUser().getTenantId(), userId);
|
444
|
- checkNotNull(user);
|
452
|
+ checkNotNull(user, "User with id [" + userId + "] is not found");
|
445
|
accessControlService.checkPermission(getCurrentUser(), Resource.USER, operation, userId, user);
|
453
|
accessControlService.checkPermission(getCurrentUser(), Resource.USER, operation, userId, user);
|
446
|
return user;
|
454
|
return user;
|
447
|
} catch (Exception e) {
|
455
|
} catch (Exception e) {
|
|
@@ -460,7 +468,9 @@ public abstract class BaseController { |
|
@@ -460,7 +468,9 @@ public abstract class BaseController { |
460
|
|
468
|
|
461
|
protected void checkEntityId(EntityId entityId, Operation operation) throws ThingsboardException {
|
469
|
protected void checkEntityId(EntityId entityId, Operation operation) throws ThingsboardException {
|
462
|
try {
|
470
|
try {
|
463
|
- checkNotNull(entityId);
|
471
|
+ if (entityId == null) {
|
|
|
472
|
+ throw new ThingsboardException("Parameter entityId can't be empty!", ThingsboardErrorCode.BAD_REQUEST_PARAMS);
|
|
|
473
|
+ }
|
464
|
validateId(entityId.getId(), "Incorrect entityId " + entityId);
|
474
|
validateId(entityId.getId(), "Incorrect entityId " + entityId);
|
465
|
switch (entityId.getEntityType()) {
|
475
|
switch (entityId.getEntityType()) {
|
466
|
case ALARM:
|
476
|
case ALARM:
|
|
@@ -526,7 +536,7 @@ public abstract class BaseController { |
|
@@ -526,7 +536,7 @@ public abstract class BaseController { |
526
|
try {
|
536
|
try {
|
527
|
validateId(deviceId, "Incorrect deviceId " + deviceId);
|
537
|
validateId(deviceId, "Incorrect deviceId " + deviceId);
|
528
|
Device device = deviceService.findDeviceById(getCurrentUser().getTenantId(), deviceId);
|
538
|
Device device = deviceService.findDeviceById(getCurrentUser().getTenantId(), deviceId);
|
529
|
- checkNotNull(device);
|
539
|
+ checkNotNull(device, "Device with id [" + deviceId + "] is not found");
|
530
|
accessControlService.checkPermission(getCurrentUser(), Resource.DEVICE, operation, deviceId, device);
|
540
|
accessControlService.checkPermission(getCurrentUser(), Resource.DEVICE, operation, deviceId, device);
|
531
|
return device;
|
541
|
return device;
|
532
|
} catch (Exception e) {
|
542
|
} catch (Exception e) {
|
|
@@ -538,7 +548,7 @@ public abstract class BaseController { |
|
@@ -538,7 +548,7 @@ public abstract class BaseController { |
538
|
try {
|
548
|
try {
|
539
|
validateId(deviceId, "Incorrect deviceId " + deviceId);
|
549
|
validateId(deviceId, "Incorrect deviceId " + deviceId);
|
540
|
DeviceInfo device = deviceService.findDeviceInfoById(getCurrentUser().getTenantId(), deviceId);
|
550
|
DeviceInfo device = deviceService.findDeviceInfoById(getCurrentUser().getTenantId(), deviceId);
|
541
|
- checkNotNull(device);
|
551
|
+ checkNotNull(device, "Device with id [" + deviceId + "] is not found");
|
542
|
accessControlService.checkPermission(getCurrentUser(), Resource.DEVICE, operation, deviceId, device);
|
552
|
accessControlService.checkPermission(getCurrentUser(), Resource.DEVICE, operation, deviceId, device);
|
543
|
return device;
|
553
|
return device;
|
544
|
} catch (Exception e) {
|
554
|
} catch (Exception e) {
|
|
@@ -550,7 +560,7 @@ public abstract class BaseController { |
|
@@ -550,7 +560,7 @@ public abstract class BaseController { |
550
|
try {
|
560
|
try {
|
551
|
validateId(deviceProfileId, "Incorrect deviceProfileId " + deviceProfileId);
|
561
|
validateId(deviceProfileId, "Incorrect deviceProfileId " + deviceProfileId);
|
552
|
DeviceProfile deviceProfile = deviceProfileService.findDeviceProfileById(getCurrentUser().getTenantId(), deviceProfileId);
|
562
|
DeviceProfile deviceProfile = deviceProfileService.findDeviceProfileById(getCurrentUser().getTenantId(), deviceProfileId);
|
553
|
- checkNotNull(deviceProfile);
|
563
|
+ checkNotNull(deviceProfile, "Device profile with id [" + deviceProfileId + "] is not found");
|
554
|
accessControlService.checkPermission(getCurrentUser(), Resource.DEVICE_PROFILE, operation, deviceProfileId, deviceProfile);
|
564
|
accessControlService.checkPermission(getCurrentUser(), Resource.DEVICE_PROFILE, operation, deviceProfileId, deviceProfile);
|
555
|
return deviceProfile;
|
565
|
return deviceProfile;
|
556
|
} catch (Exception e) {
|
566
|
} catch (Exception e) {
|
|
@@ -562,7 +572,7 @@ public abstract class BaseController { |
|
@@ -562,7 +572,7 @@ public abstract class BaseController { |
562
|
try {
|
572
|
try {
|
563
|
validateId(entityViewId, "Incorrect entityViewId " + entityViewId);
|
573
|
validateId(entityViewId, "Incorrect entityViewId " + entityViewId);
|
564
|
EntityView entityView = entityViewService.findEntityViewById(getCurrentUser().getTenantId(), entityViewId);
|
574
|
EntityView entityView = entityViewService.findEntityViewById(getCurrentUser().getTenantId(), entityViewId);
|
565
|
- checkNotNull(entityView);
|
575
|
+ checkNotNull(entityView, "Entity view with id [" + entityViewId + "] is not found");
|
566
|
accessControlService.checkPermission(getCurrentUser(), Resource.ENTITY_VIEW, operation, entityViewId, entityView);
|
576
|
accessControlService.checkPermission(getCurrentUser(), Resource.ENTITY_VIEW, operation, entityViewId, entityView);
|
567
|
return entityView;
|
577
|
return entityView;
|
568
|
} catch (Exception e) {
|
578
|
} catch (Exception e) {
|
|
@@ -574,7 +584,7 @@ public abstract class BaseController { |
|
@@ -574,7 +584,7 @@ public abstract class BaseController { |
574
|
try {
|
584
|
try {
|
575
|
validateId(entityViewId, "Incorrect entityViewId " + entityViewId);
|
585
|
validateId(entityViewId, "Incorrect entityViewId " + entityViewId);
|
576
|
EntityViewInfo entityView = entityViewService.findEntityViewInfoById(getCurrentUser().getTenantId(), entityViewId);
|
586
|
EntityViewInfo entityView = entityViewService.findEntityViewInfoById(getCurrentUser().getTenantId(), entityViewId);
|
577
|
- checkNotNull(entityView);
|
587
|
+ checkNotNull(entityView, "Entity view with id [" + entityViewId + "] is not found");
|
578
|
accessControlService.checkPermission(getCurrentUser(), Resource.ENTITY_VIEW, operation, entityViewId, entityView);
|
588
|
accessControlService.checkPermission(getCurrentUser(), Resource.ENTITY_VIEW, operation, entityViewId, entityView);
|
579
|
return entityView;
|
589
|
return entityView;
|
580
|
} catch (Exception e) {
|
590
|
} catch (Exception e) {
|
|
@@ -586,7 +596,7 @@ public abstract class BaseController { |
|
@@ -586,7 +596,7 @@ public abstract class BaseController { |
586
|
try {
|
596
|
try {
|
587
|
validateId(assetId, "Incorrect assetId " + assetId);
|
597
|
validateId(assetId, "Incorrect assetId " + assetId);
|
588
|
Asset asset = assetService.findAssetById(getCurrentUser().getTenantId(), assetId);
|
598
|
Asset asset = assetService.findAssetById(getCurrentUser().getTenantId(), assetId);
|
589
|
- checkNotNull(asset);
|
599
|
+ checkNotNull(asset, "Asset with id [" + assetId + "] is not found");
|
590
|
accessControlService.checkPermission(getCurrentUser(), Resource.ASSET, operation, assetId, asset);
|
600
|
accessControlService.checkPermission(getCurrentUser(), Resource.ASSET, operation, assetId, asset);
|
591
|
return asset;
|
601
|
return asset;
|
592
|
} catch (Exception e) {
|
602
|
} catch (Exception e) {
|
|
@@ -598,7 +608,7 @@ public abstract class BaseController { |
|
@@ -598,7 +608,7 @@ public abstract class BaseController { |
598
|
try {
|
608
|
try {
|
599
|
validateId(assetId, "Incorrect assetId " + assetId);
|
609
|
validateId(assetId, "Incorrect assetId " + assetId);
|
600
|
AssetInfo asset = assetService.findAssetInfoById(getCurrentUser().getTenantId(), assetId);
|
610
|
AssetInfo asset = assetService.findAssetInfoById(getCurrentUser().getTenantId(), assetId);
|
601
|
- checkNotNull(asset);
|
611
|
+ checkNotNull(asset, "Asset with id [" + assetId + "] is not found");
|
602
|
accessControlService.checkPermission(getCurrentUser(), Resource.ASSET, operation, assetId, asset);
|
612
|
accessControlService.checkPermission(getCurrentUser(), Resource.ASSET, operation, assetId, asset);
|
603
|
return asset;
|
613
|
return asset;
|
604
|
} catch (Exception e) {
|
614
|
} catch (Exception e) {
|
|
@@ -610,7 +620,7 @@ public abstract class BaseController { |
|
@@ -610,7 +620,7 @@ public abstract class BaseController { |
610
|
try {
|
620
|
try {
|
611
|
validateId(alarmId, "Incorrect alarmId " + alarmId);
|
621
|
validateId(alarmId, "Incorrect alarmId " + alarmId);
|
612
|
Alarm alarm = alarmService.findAlarmByIdAsync(getCurrentUser().getTenantId(), alarmId).get();
|
622
|
Alarm alarm = alarmService.findAlarmByIdAsync(getCurrentUser().getTenantId(), alarmId).get();
|
613
|
- checkNotNull(alarm);
|
623
|
+ checkNotNull(alarm, "Alarm with id [" + alarmId + "] is not found");
|
614
|
accessControlService.checkPermission(getCurrentUser(), Resource.ALARM, operation, alarmId, alarm);
|
624
|
accessControlService.checkPermission(getCurrentUser(), Resource.ALARM, operation, alarmId, alarm);
|
615
|
return alarm;
|
625
|
return alarm;
|
616
|
} catch (Exception e) {
|
626
|
} catch (Exception e) {
|
|
@@ -622,7 +632,7 @@ public abstract class BaseController { |
|
@@ -622,7 +632,7 @@ public abstract class BaseController { |
622
|
try {
|
632
|
try {
|
623
|
validateId(alarmId, "Incorrect alarmId " + alarmId);
|
633
|
validateId(alarmId, "Incorrect alarmId " + alarmId);
|
624
|
AlarmInfo alarmInfo = alarmService.findAlarmInfoByIdAsync(getCurrentUser().getTenantId(), alarmId).get();
|
634
|
AlarmInfo alarmInfo = alarmService.findAlarmInfoByIdAsync(getCurrentUser().getTenantId(), alarmId).get();
|
625
|
- checkNotNull(alarmInfo);
|
635
|
+ checkNotNull(alarmInfo, "Alarm with id [" + alarmId + "] is not found");
|
626
|
accessControlService.checkPermission(getCurrentUser(), Resource.ALARM, operation, alarmId, alarmInfo);
|
636
|
accessControlService.checkPermission(getCurrentUser(), Resource.ALARM, operation, alarmId, alarmInfo);
|
627
|
return alarmInfo;
|
637
|
return alarmInfo;
|
628
|
} catch (Exception e) {
|
638
|
} catch (Exception e) {
|
|
@@ -634,7 +644,7 @@ public abstract class BaseController { |
|
@@ -634,7 +644,7 @@ public abstract class BaseController { |
634
|
try {
|
644
|
try {
|
635
|
validateId(widgetsBundleId, "Incorrect widgetsBundleId " + widgetsBundleId);
|
645
|
validateId(widgetsBundleId, "Incorrect widgetsBundleId " + widgetsBundleId);
|
636
|
WidgetsBundle widgetsBundle = widgetsBundleService.findWidgetsBundleById(getCurrentUser().getTenantId(), widgetsBundleId);
|
646
|
WidgetsBundle widgetsBundle = widgetsBundleService.findWidgetsBundleById(getCurrentUser().getTenantId(), widgetsBundleId);
|
637
|
- checkNotNull(widgetsBundle);
|
647
|
+ checkNotNull(widgetsBundle, "Widgets bundle with id [" + widgetsBundleId + "] is not found");
|
638
|
accessControlService.checkPermission(getCurrentUser(), Resource.WIDGETS_BUNDLE, operation, widgetsBundleId, widgetsBundle);
|
648
|
accessControlService.checkPermission(getCurrentUser(), Resource.WIDGETS_BUNDLE, operation, widgetsBundleId, widgetsBundle);
|
639
|
return widgetsBundle;
|
649
|
return widgetsBundle;
|
640
|
} catch (Exception e) {
|
650
|
} catch (Exception e) {
|
|
@@ -646,7 +656,7 @@ public abstract class BaseController { |
|
@@ -646,7 +656,7 @@ public abstract class BaseController { |
646
|
try {
|
656
|
try {
|
647
|
validateId(widgetTypeId, "Incorrect widgetTypeId " + widgetTypeId);
|
657
|
validateId(widgetTypeId, "Incorrect widgetTypeId " + widgetTypeId);
|
648
|
WidgetTypeDetails widgetTypeDetails = widgetTypeService.findWidgetTypeDetailsById(getCurrentUser().getTenantId(), widgetTypeId);
|
658
|
WidgetTypeDetails widgetTypeDetails = widgetTypeService.findWidgetTypeDetailsById(getCurrentUser().getTenantId(), widgetTypeId);
|
649
|
- checkNotNull(widgetTypeDetails);
|
659
|
+ checkNotNull(widgetTypeDetails, "Widget type with id [" + widgetTypeId + "] is not found");
|
650
|
accessControlService.checkPermission(getCurrentUser(), Resource.WIDGET_TYPE, operation, widgetTypeId, widgetTypeDetails);
|
660
|
accessControlService.checkPermission(getCurrentUser(), Resource.WIDGET_TYPE, operation, widgetTypeId, widgetTypeDetails);
|
651
|
return widgetTypeDetails;
|
661
|
return widgetTypeDetails;
|
652
|
} catch (Exception e) {
|
662
|
} catch (Exception e) {
|
|
@@ -658,7 +668,7 @@ public abstract class BaseController { |
|
@@ -658,7 +668,7 @@ public abstract class BaseController { |
658
|
try {
|
668
|
try {
|
659
|
validateId(dashboardId, "Incorrect dashboardId " + dashboardId);
|
669
|
validateId(dashboardId, "Incorrect dashboardId " + dashboardId);
|
660
|
Dashboard dashboard = dashboardService.findDashboardById(getCurrentUser().getTenantId(), dashboardId);
|
670
|
Dashboard dashboard = dashboardService.findDashboardById(getCurrentUser().getTenantId(), dashboardId);
|
661
|
- checkNotNull(dashboard);
|
671
|
+ checkNotNull(dashboard, "Dashboard with id [" + dashboardId + "] is not found");
|
662
|
accessControlService.checkPermission(getCurrentUser(), Resource.DASHBOARD, operation, dashboardId, dashboard);
|
672
|
accessControlService.checkPermission(getCurrentUser(), Resource.DASHBOARD, operation, dashboardId, dashboard);
|
663
|
return dashboard;
|
673
|
return dashboard;
|
664
|
} catch (Exception e) {
|
674
|
} catch (Exception e) {
|
|
@@ -670,7 +680,7 @@ public abstract class BaseController { |
|
@@ -670,7 +680,7 @@ public abstract class BaseController { |
670
|
try {
|
680
|
try {
|
671
|
validateId(edgeId, "Incorrect edgeId " + edgeId);
|
681
|
validateId(edgeId, "Incorrect edgeId " + edgeId);
|
672
|
Edge edge = edgeService.findEdgeById(getTenantId(), edgeId);
|
682
|
Edge edge = edgeService.findEdgeById(getTenantId(), edgeId);
|
673
|
- checkNotNull(edge);
|
683
|
+ checkNotNull(edge, "Edge with id [" + edgeId + "] is not found");
|
674
|
accessControlService.checkPermission(getCurrentUser(), Resource.EDGE, operation, edgeId, edge);
|
684
|
accessControlService.checkPermission(getCurrentUser(), Resource.EDGE, operation, edgeId, edge);
|
675
|
return edge;
|
685
|
return edge;
|
676
|
} catch (Exception e) {
|
686
|
} catch (Exception e) {
|
|
@@ -682,7 +692,7 @@ public abstract class BaseController { |
|
@@ -682,7 +692,7 @@ public abstract class BaseController { |
682
|
try {
|
692
|
try {
|
683
|
validateId(edgeId, "Incorrect edgeId " + edgeId);
|
693
|
validateId(edgeId, "Incorrect edgeId " + edgeId);
|
684
|
EdgeInfo edge = edgeService.findEdgeInfoById(getCurrentUser().getTenantId(), edgeId);
|
694
|
EdgeInfo edge = edgeService.findEdgeInfoById(getCurrentUser().getTenantId(), edgeId);
|
685
|
- checkNotNull(edge);
|
695
|
+ checkNotNull(edge, "Edge with id [" + edgeId + "] is not found");
|
686
|
accessControlService.checkPermission(getCurrentUser(), Resource.EDGE, operation, edgeId, edge);
|
696
|
accessControlService.checkPermission(getCurrentUser(), Resource.EDGE, operation, edgeId, edge);
|
687
|
return edge;
|
697
|
return edge;
|
688
|
} catch (Exception e) {
|
698
|
} catch (Exception e) {
|
|
@@ -694,7 +704,7 @@ public abstract class BaseController { |
|
@@ -694,7 +704,7 @@ public abstract class BaseController { |
694
|
try {
|
704
|
try {
|
695
|
validateId(dashboardId, "Incorrect dashboardId " + dashboardId);
|
705
|
validateId(dashboardId, "Incorrect dashboardId " + dashboardId);
|
696
|
DashboardInfo dashboardInfo = dashboardService.findDashboardInfoById(getCurrentUser().getTenantId(), dashboardId);
|
706
|
DashboardInfo dashboardInfo = dashboardService.findDashboardInfoById(getCurrentUser().getTenantId(), dashboardId);
|
697
|
- checkNotNull(dashboardInfo);
|
707
|
+ checkNotNull(dashboardInfo, "Dashboard with id [" + dashboardId + "] is not found");
|
698
|
accessControlService.checkPermission(getCurrentUser(), Resource.DASHBOARD, operation, dashboardId, dashboardInfo);
|
708
|
accessControlService.checkPermission(getCurrentUser(), Resource.DASHBOARD, operation, dashboardId, dashboardInfo);
|
699
|
return dashboardInfo;
|
709
|
return dashboardInfo;
|
700
|
} catch (Exception e) {
|
710
|
} catch (Exception e) {
|
|
@@ -732,7 +742,7 @@ public abstract class BaseController { |
|
@@ -732,7 +742,7 @@ public abstract class BaseController { |
732
|
protected RuleChain checkRuleChain(RuleChainId ruleChainId, Operation operation) throws ThingsboardException {
|
742
|
protected RuleChain checkRuleChain(RuleChainId ruleChainId, Operation operation) throws ThingsboardException {
|
733
|
validateId(ruleChainId, "Incorrect ruleChainId " + ruleChainId);
|
743
|
validateId(ruleChainId, "Incorrect ruleChainId " + ruleChainId);
|
734
|
RuleChain ruleChain = ruleChainService.findRuleChainById(getCurrentUser().getTenantId(), ruleChainId);
|
744
|
RuleChain ruleChain = ruleChainService.findRuleChainById(getCurrentUser().getTenantId(), ruleChainId);
|
735
|
- checkNotNull(ruleChain);
|
745
|
+ checkNotNull(ruleChain, "Rule chain with id [" + ruleChainId + "] is not found");
|
736
|
accessControlService.checkPermission(getCurrentUser(), Resource.RULE_CHAIN, operation, ruleChainId, ruleChain);
|
746
|
accessControlService.checkPermission(getCurrentUser(), Resource.RULE_CHAIN, operation, ruleChainId, ruleChain);
|
737
|
return ruleChain;
|
747
|
return ruleChain;
|
738
|
}
|
748
|
}
|
|
@@ -740,7 +750,7 @@ public abstract class BaseController { |
|
@@ -740,7 +750,7 @@ public abstract class BaseController { |
740
|
protected RuleNode checkRuleNode(RuleNodeId ruleNodeId, Operation operation) throws ThingsboardException {
|
750
|
protected RuleNode checkRuleNode(RuleNodeId ruleNodeId, Operation operation) throws ThingsboardException {
|
741
|
validateId(ruleNodeId, "Incorrect ruleNodeId " + ruleNodeId);
|
751
|
validateId(ruleNodeId, "Incorrect ruleNodeId " + ruleNodeId);
|
742
|
RuleNode ruleNode = ruleChainService.findRuleNodeById(getTenantId(), ruleNodeId);
|
752
|
RuleNode ruleNode = ruleChainService.findRuleNodeById(getTenantId(), ruleNodeId);
|
743
|
- checkNotNull(ruleNode);
|
753
|
+ checkNotNull(ruleNode, "Rule node with id [" + ruleNodeId + "] is not found");
|
744
|
checkRuleChain(ruleNode.getRuleChainId(), operation);
|
754
|
checkRuleChain(ruleNode.getRuleChainId(), operation);
|
745
|
return ruleNode;
|
755
|
return ruleNode;
|
746
|
}
|
756
|
}
|
|
@@ -749,7 +759,7 @@ public abstract class BaseController { |
|
@@ -749,7 +759,7 @@ public abstract class BaseController { |
749
|
try {
|
759
|
try {
|
750
|
validateId(resourceId, "Incorrect resourceId " + resourceId);
|
760
|
validateId(resourceId, "Incorrect resourceId " + resourceId);
|
751
|
TbResource resource = resourceService.findResourceById(getCurrentUser().getTenantId(), resourceId);
|
761
|
TbResource resource = resourceService.findResourceById(getCurrentUser().getTenantId(), resourceId);
|
752
|
- checkNotNull(resource);
|
762
|
+ checkNotNull(resource, "Resource with id [" + resourceId + "] is not found");
|
753
|
accessControlService.checkPermission(getCurrentUser(), Resource.TB_RESOURCE, operation, resourceId, resource);
|
763
|
accessControlService.checkPermission(getCurrentUser(), Resource.TB_RESOURCE, operation, resourceId, resource);
|
754
|
return resource;
|
764
|
return resource;
|
755
|
} catch (Exception e) {
|
765
|
} catch (Exception e) {
|
|
@@ -761,7 +771,7 @@ public abstract class BaseController { |
|
@@ -761,7 +771,7 @@ public abstract class BaseController { |
761
|
try {
|
771
|
try {
|
762
|
validateId(resourceId, "Incorrect resourceId " + resourceId);
|
772
|
validateId(resourceId, "Incorrect resourceId " + resourceId);
|
763
|
TbResourceInfo resourceInfo = resourceService.findResourceInfoById(getCurrentUser().getTenantId(), resourceId);
|
773
|
TbResourceInfo resourceInfo = resourceService.findResourceInfoById(getCurrentUser().getTenantId(), resourceId);
|
764
|
- checkNotNull(resourceInfo);
|
774
|
+ checkNotNull(resourceInfo, "Resource with id [" + resourceId + "] is not found");
|
765
|
accessControlService.checkPermission(getCurrentUser(), Resource.TB_RESOURCE, operation, resourceId, resourceInfo);
|
775
|
accessControlService.checkPermission(getCurrentUser(), Resource.TB_RESOURCE, operation, resourceId, resourceInfo);
|
766
|
return resourceInfo;
|
776
|
return resourceInfo;
|
767
|
} catch (Exception e) {
|
777
|
} catch (Exception e) {
|
|
@@ -773,7 +783,7 @@ public abstract class BaseController { |
|
@@ -773,7 +783,7 @@ public abstract class BaseController { |
773
|
try {
|
783
|
try {
|
774
|
validateId(otaPackageId, "Incorrect otaPackageId " + otaPackageId);
|
784
|
validateId(otaPackageId, "Incorrect otaPackageId " + otaPackageId);
|
775
|
OtaPackage otaPackage = otaPackageService.findOtaPackageById(getCurrentUser().getTenantId(), otaPackageId);
|
785
|
OtaPackage otaPackage = otaPackageService.findOtaPackageById(getCurrentUser().getTenantId(), otaPackageId);
|
776
|
- checkNotNull(otaPackage);
|
786
|
+ checkNotNull(otaPackage, "OTA package with id [" + otaPackageId + "] is not found");
|
777
|
accessControlService.checkPermission(getCurrentUser(), Resource.OTA_PACKAGE, operation, otaPackageId, otaPackage);
|
787
|
accessControlService.checkPermission(getCurrentUser(), Resource.OTA_PACKAGE, operation, otaPackageId, otaPackage);
|
778
|
return otaPackage;
|
788
|
return otaPackage;
|
779
|
} catch (Exception e) {
|
789
|
} catch (Exception e) {
|
|
@@ -785,7 +795,7 @@ public abstract class BaseController { |
|
@@ -785,7 +795,7 @@ public abstract class BaseController { |
785
|
try {
|
795
|
try {
|
786
|
validateId(otaPackageId, "Incorrect otaPackageId " + otaPackageId);
|
796
|
validateId(otaPackageId, "Incorrect otaPackageId " + otaPackageId);
|
787
|
OtaPackageInfo otaPackageIn = otaPackageService.findOtaPackageInfoById(getCurrentUser().getTenantId(), otaPackageId);
|
797
|
OtaPackageInfo otaPackageIn = otaPackageService.findOtaPackageInfoById(getCurrentUser().getTenantId(), otaPackageId);
|
788
|
- checkNotNull(otaPackageIn);
|
798
|
+ checkNotNull(otaPackageIn, "OTA package with id [" + otaPackageId + "] is not found");
|
789
|
accessControlService.checkPermission(getCurrentUser(), Resource.OTA_PACKAGE, operation, otaPackageId, otaPackageIn);
|
799
|
accessControlService.checkPermission(getCurrentUser(), Resource.OTA_PACKAGE, operation, otaPackageId, otaPackageIn);
|
790
|
return otaPackageIn;
|
800
|
return otaPackageIn;
|
791
|
} catch (Exception e) {
|
801
|
} catch (Exception e) {
|
|
@@ -797,7 +807,7 @@ public abstract class BaseController { |
|
@@ -797,7 +807,7 @@ public abstract class BaseController { |
797
|
try {
|
807
|
try {
|
798
|
validateId(rpcId, "Incorrect rpcId " + rpcId);
|
808
|
validateId(rpcId, "Incorrect rpcId " + rpcId);
|
799
|
Rpc rpc = rpcService.findById(getCurrentUser().getTenantId(), rpcId);
|
809
|
Rpc rpc = rpcService.findById(getCurrentUser().getTenantId(), rpcId);
|
800
|
- checkNotNull(rpc);
|
810
|
+ checkNotNull(rpc, "RPC with id [" + rpcId + "] is not found");
|
801
|
accessControlService.checkPermission(getCurrentUser(), Resource.RPC, operation, rpcId, rpc);
|
811
|
accessControlService.checkPermission(getCurrentUser(), Resource.RPC, operation, rpcId, rpc);
|
802
|
return rpc;
|
812
|
return rpc;
|
803
|
} catch (Exception e) {
|
813
|
} catch (Exception e) {
|