@ -319,17 +319,25 @@ public abstract class BaseController {
}
}
< T > T checkNotNull ( T reference ) throws ThingsboardException {
< T > T checkNotNull ( T reference ) throws ThingsboardException {
return checkNotNull ( reference , "Requested item wasn't found!" ) ;
}
< T > T checkNotNull ( T reference , String notFoundMessage ) throws ThingsboardException {
if ( reference = = null ) {
if ( reference = = null ) {
throw new ThingsboardException ( "Requested item wasn't found!" , ThingsboardErrorCode . ITEM_NOT_FOUND ) ;
throw new ThingsboardException ( notFoundMessage , ThingsboardErrorCode . ITEM_NOT_FOUND ) ;
}
}
return reference ;
return reference ;
}
}
< T > T checkNotNull ( Optional < T > reference ) throws ThingsboardException {
< T > T checkNotNull ( Optional < T > reference ) throws ThingsboardException {
return checkNotNull ( reference , "Requested item wasn't found!" ) ;
}
< T > T checkNotNull ( Optional < T > reference , String notFoundMessage ) throws ThingsboardException {
if ( reference . isPresent ( ) ) {
if ( reference . isPresent ( ) ) {
return reference . get ( ) ;
return reference . get ( ) ;
} else {
} else {
throw new ThingsboardException ( "Requested item wasn't found!" , ThingsboardErrorCode . ITEM_NOT_FOUND ) ;
throw new ThingsboardException ( notFoundMessage , ThingsboardErrorCode . ITEM_NOT_FOUND ) ;
}
}
}
}
@ -389,7 +397,7 @@ public abstract class BaseController {
try {
try {
validateId ( tenantId , INCORRECT_TENANT_ID + tenantId ) ;
validateId ( tenantId , INCORRECT_TENANT_ID + tenantId ) ;
Tenant tenant = tenantService . findTenantById ( tenantId ) ;
Tenant tenant = tenantService . findTenantById ( tenantId ) ;
checkNotNull ( tenant ) ;
checkNotNull ( tenant , "Tenant with id [" + tenantId + "] is not found" ) ;
accessControlService . checkPermission ( getCurrentUser ( ) , Resource . TENANT , operation , tenantId , tenant ) ;
accessControlService . checkPermission ( getCurrentUser ( ) , Resource . TENANT , operation , tenantId , tenant ) ;
return tenant ;
return tenant ;
} catch ( Exception e ) {
} catch ( Exception e ) {
@ -401,7 +409,7 @@ public abstract class BaseController {
try {
try {
validateId ( tenantId , INCORRECT_TENANT_ID + tenantId ) ;
validateId ( tenantId , INCORRECT_TENANT_ID + tenantId ) ;
TenantInfo tenant = tenantService . findTenantInfoById ( tenantId ) ;
TenantInfo tenant = tenantService . findTenantInfoById ( tenantId ) ;
checkNotNull ( tenant ) ;
checkNotNull ( tenant , "Tenant with id [" + tenantId + "] is not found" ) ;
accessControlService . checkPermission ( getCurrentUser ( ) , Resource . TENANT , operation , tenantId , tenant ) ;
accessControlService . checkPermission ( getCurrentUser ( ) , Resource . TENANT , operation , tenantId , tenant ) ;
return tenant ;
return tenant ;
} catch ( Exception e ) {
} catch ( Exception e ) {
@ -413,7 +421,7 @@ public abstract class BaseController {
try {
try {
validateId ( tenantProfileId , "Incorrect tenantProfileId " + tenantProfileId ) ;
validateId ( tenantProfileId , "Incorrect tenantProfileId " + tenantProfileId ) ;
TenantProfile tenantProfile = tenantProfileService . findTenantProfileById ( getTenantId ( ) , tenantProfileId ) ;
TenantProfile tenantProfile = tenantProfileService . findTenantProfileById ( getTenantId ( ) , tenantProfileId ) ;
checkNotNull ( tenantProfile ) ;
checkNotNull ( tenantProfile , "Tenant profile with id [" + tenantProfileId + "] is not found" ) ;
accessControlService . checkPermission ( getCurrentUser ( ) , Resource . TENANT_PROFILE , operation ) ;
accessControlService . checkPermission ( getCurrentUser ( ) , Resource . TENANT_PROFILE , operation ) ;
return tenantProfile ;
return tenantProfile ;
} catch ( Exception e ) {
} catch ( Exception e ) {
@ -429,7 +437,7 @@ public abstract class BaseController {
try {
try {
validateId ( customerId , "Incorrect customerId " + customerId ) ;
validateId ( customerId , "Incorrect customerId " + customerId ) ;
Customer customer = customerService . findCustomerById ( getTenantId ( ) , customerId ) ;
Customer customer = customerService . findCustomerById ( getTenantId ( ) , customerId ) ;
checkNotNull ( customer ) ;
checkNotNull ( customer , "Customer with id [" + customerId + "] is not found" ) ;
accessControlService . checkPermission ( getCurrentUser ( ) , Resource . CUSTOMER , operation , customerId , customer ) ;
accessControlService . checkPermission ( getCurrentUser ( ) , Resource . CUSTOMER , operation , customerId , customer ) ;
return customer ;
return customer ;
} catch ( Exception e ) {
} catch ( Exception e ) {
@ -441,7 +449,7 @@ public abstract class BaseController {
try {
try {
validateId ( userId , "Incorrect userId " + userId ) ;
validateId ( userId , "Incorrect userId " + userId ) ;
User user = userService . findUserById ( getCurrentUser ( ) . getTenantId ( ) , userId ) ;
User user = userService . findUserById ( getCurrentUser ( ) . getTenantId ( ) , userId ) ;
checkNotNull ( user ) ;
checkNotNull ( user , "User with id [" + userId + "] is not found" ) ;
accessControlService . checkPermission ( getCurrentUser ( ) , Resource . USER , operation , userId , user ) ;
accessControlService . checkPermission ( getCurrentUser ( ) , Resource . USER , operation , userId , user ) ;
return user ;
return user ;
} catch ( Exception e ) {
} catch ( Exception e ) {
@ -460,7 +468,9 @@ public abstract class BaseController {
protected void checkEntityId ( EntityId entityId , Operation operation ) throws ThingsboardException {
protected void checkEntityId ( EntityId entityId , Operation operation ) throws ThingsboardException {
try {
try {
checkNotNull ( entityId ) ;
if ( entityId = = null ) {
throw new ThingsboardException ( "Parameter entityId can't be empty!" , ThingsboardErrorCode . BAD_REQUEST_PARAMS ) ;
}
validateId ( entityId . getId ( ) , "Incorrect entityId " + entityId ) ;
validateId ( entityId . getId ( ) , "Incorrect entityId " + entityId ) ;
switch ( entityId . getEntityType ( ) ) {
switch ( entityId . getEntityType ( ) ) {
case ALARM :
case ALARM :
@ -526,7 +536,7 @@ public abstract class BaseController {
try {
try {
validateId ( deviceId , "Incorrect deviceId " + deviceId ) ;
validateId ( deviceId , "Incorrect deviceId " + deviceId ) ;
Device device = deviceService . findDeviceById ( getCurrentUser ( ) . getTenantId ( ) , deviceId ) ;
Device device = deviceService . findDeviceById ( getCurrentUser ( ) . getTenantId ( ) , deviceId ) ;
checkNotNull ( device ) ;
checkNotNull ( device , "Device with id [" + deviceId + "] is not found" ) ;
accessControlService . checkPermission ( getCurrentUser ( ) , Resource . DEVICE , operation , deviceId , device ) ;
accessControlService . checkPermission ( getCurrentUser ( ) , Resource . DEVICE , operation , deviceId , device ) ;
return device ;
return device ;
} catch ( Exception e ) {
} catch ( Exception e ) {
@ -538,7 +548,7 @@ public abstract class BaseController {
try {
try {
validateId ( deviceId , "Incorrect deviceId " + deviceId ) ;
validateId ( deviceId , "Incorrect deviceId " + deviceId ) ;
DeviceInfo device = deviceService . findDeviceInfoById ( getCurrentUser ( ) . getTenantId ( ) , deviceId ) ;
DeviceInfo device = deviceService . findDeviceInfoById ( getCurrentUser ( ) . getTenantId ( ) , deviceId ) ;
checkNotNull ( device ) ;
checkNotNull ( device , "Device with id [" + deviceId + "] is not found" ) ;
accessControlService . checkPermission ( getCurrentUser ( ) , Resource . DEVICE , operation , deviceId , device ) ;
accessControlService . checkPermission ( getCurrentUser ( ) , Resource . DEVICE , operation , deviceId , device ) ;
return device ;
return device ;
} catch ( Exception e ) {
} catch ( Exception e ) {
@ -550,7 +560,7 @@ public abstract class BaseController {
try {
try {
validateId ( deviceProfileId , "Incorrect deviceProfileId " + deviceProfileId ) ;
validateId ( deviceProfileId , "Incorrect deviceProfileId " + deviceProfileId ) ;
DeviceProfile deviceProfile = deviceProfileService . findDeviceProfileById ( getCurrentUser ( ) . getTenantId ( ) , deviceProfileId ) ;
DeviceProfile deviceProfile = deviceProfileService . findDeviceProfileById ( getCurrentUser ( ) . getTenantId ( ) , deviceProfileId ) ;
checkNotNull ( deviceProfile ) ;
checkNotNull ( deviceProfile , "Device profile with id [" + deviceProfileId + "] is not found" ) ;
accessControlService . checkPermission ( getCurrentUser ( ) , Resource . DEVICE_PROFILE , operation , deviceProfileId , deviceProfile ) ;
accessControlService . checkPermission ( getCurrentUser ( ) , Resource . DEVICE_PROFILE , operation , deviceProfileId , deviceProfile ) ;
return deviceProfile ;
return deviceProfile ;
} catch ( Exception e ) {
} catch ( Exception e ) {
@ -562,7 +572,7 @@ public abstract class BaseController {
try {
try {
validateId ( entityViewId , "Incorrect entityViewId " + entityViewId ) ;
validateId ( entityViewId , "Incorrect entityViewId " + entityViewId ) ;
EntityView entityView = entityViewService . findEntityViewById ( getCurrentUser ( ) . getTenantId ( ) , entityViewId ) ;
EntityView entityView = entityViewService . findEntityViewById ( getCurrentUser ( ) . getTenantId ( ) , entityViewId ) ;
checkNotNull ( entityView ) ;
checkNotNull ( entityView , "Entity view with id [" + entityViewId + "] is not found" ) ;
accessControlService . checkPermission ( getCurrentUser ( ) , Resource . ENTITY_VIEW , operation , entityViewId , entityView ) ;
accessControlService . checkPermission ( getCurrentUser ( ) , Resource . ENTITY_VIEW , operation , entityViewId , entityView ) ;
return entityView ;
return entityView ;
} catch ( Exception e ) {
} catch ( Exception e ) {
@ -574,7 +584,7 @@ public abstract class BaseController {
try {
try {
validateId ( entityViewId , "Incorrect entityViewId " + entityViewId ) ;
validateId ( entityViewId , "Incorrect entityViewId " + entityViewId ) ;
EntityViewInfo entityView = entityViewService . findEntityViewInfoById ( getCurrentUser ( ) . getTenantId ( ) , entityViewId ) ;
EntityViewInfo entityView = entityViewService . findEntityViewInfoById ( getCurrentUser ( ) . getTenantId ( ) , entityViewId ) ;
checkNotNull ( entityView ) ;
checkNotNull ( entityView , "Entity view with id [" + entityViewId + "] is not found" ) ;
accessControlService . checkPermission ( getCurrentUser ( ) , Resource . ENTITY_VIEW , operation , entityViewId , entityView ) ;
accessControlService . checkPermission ( getCurrentUser ( ) , Resource . ENTITY_VIEW , operation , entityViewId , entityView ) ;
return entityView ;
return entityView ;
} catch ( Exception e ) {
} catch ( Exception e ) {
@ -586,7 +596,7 @@ public abstract class BaseController {
try {
try {
validateId ( assetId , "Incorrect assetId " + assetId ) ;
validateId ( assetId , "Incorrect assetId " + assetId ) ;
Asset asset = assetService . findAssetById ( getCurrentUser ( ) . getTenantId ( ) , assetId ) ;
Asset asset = assetService . findAssetById ( getCurrentUser ( ) . getTenantId ( ) , assetId ) ;
checkNotNull ( asset ) ;
checkNotNull ( asset , "Asset with id [" + assetId + "] is not found" ) ;
accessControlService . checkPermission ( getCurrentUser ( ) , Resource . ASSET , operation , assetId , asset ) ;
accessControlService . checkPermission ( getCurrentUser ( ) , Resource . ASSET , operation , assetId , asset ) ;
return asset ;
return asset ;
} catch ( Exception e ) {
} catch ( Exception e ) {
@ -598,7 +608,7 @@ public abstract class BaseController {
try {
try {
validateId ( assetId , "Incorrect assetId " + assetId ) ;
validateId ( assetId , "Incorrect assetId " + assetId ) ;
AssetInfo asset = assetService . findAssetInfoById ( getCurrentUser ( ) . getTenantId ( ) , assetId ) ;
AssetInfo asset = assetService . findAssetInfoById ( getCurrentUser ( ) . getTenantId ( ) , assetId ) ;
checkNotNull ( asset ) ;
checkNotNull ( asset , "Asset with id [" + assetId + "] is not found" ) ;
accessControlService . checkPermission ( getCurrentUser ( ) , Resource . ASSET , operation , assetId , asset ) ;
accessControlService . checkPermission ( getCurrentUser ( ) , Resource . ASSET , operation , assetId , asset ) ;
return asset ;
return asset ;
} catch ( Exception e ) {
} catch ( Exception e ) {
@ -610,7 +620,7 @@ public abstract class BaseController {
try {
try {
validateId ( alarmId , "Incorrect alarmId " + alarmId ) ;
validateId ( alarmId , "Incorrect alarmId " + alarmId ) ;
Alarm alarm = alarmService . findAlarmByIdAsync ( getCurrentUser ( ) . getTenantId ( ) , alarmId ) . get ( ) ;
Alarm alarm = alarmService . findAlarmByIdAsync ( getCurrentUser ( ) . getTenantId ( ) , alarmId ) . get ( ) ;
checkNotNull ( alarm ) ;
checkNotNull ( alarm , "Alarm with id [" + alarmId + "] is not found" ) ;
accessControlService . checkPermission ( getCurrentUser ( ) , Resource . ALARM , operation , alarmId , alarm ) ;
accessControlService . checkPermission ( getCurrentUser ( ) , Resource . ALARM , operation , alarmId , alarm ) ;
return alarm ;
return alarm ;
} catch ( Exception e ) {
} catch ( Exception e ) {
@ -622,7 +632,7 @@ public abstract class BaseController {
try {
try {
validateId ( alarmId , "Incorrect alarmId " + alarmId ) ;
validateId ( alarmId , "Incorrect alarmId " + alarmId ) ;
AlarmInfo alarmInfo = alarmService . findAlarmInfoByIdAsync ( getCurrentUser ( ) . getTenantId ( ) , alarmId ) . get ( ) ;
AlarmInfo alarmInfo = alarmService . findAlarmInfoByIdAsync ( getCurrentUser ( ) . getTenantId ( ) , alarmId ) . get ( ) ;
checkNotNull ( alarmInfo ) ;
checkNotNull ( alarmInfo , "Alarm with id [" + alarmId + "] is not found" ) ;
accessControlService . checkPermission ( getCurrentUser ( ) , Resource . ALARM , operation , alarmId , alarmInfo ) ;
accessControlService . checkPermission ( getCurrentUser ( ) , Resource . ALARM , operation , alarmId , alarmInfo ) ;
return alarmInfo ;
return alarmInfo ;
} catch ( Exception e ) {
} catch ( Exception e ) {
@ -634,7 +644,7 @@ public abstract class BaseController {
try {
try {
validateId ( widgetsBundleId , "Incorrect widgetsBundleId " + widgetsBundleId ) ;
validateId ( widgetsBundleId , "Incorrect widgetsBundleId " + widgetsBundleId ) ;
WidgetsBundle widgetsBundle = widgetsBundleService . findWidgetsBundleById ( getCurrentUser ( ) . getTenantId ( ) , widgetsBundleId ) ;
WidgetsBundle widgetsBundle = widgetsBundleService . findWidgetsBundleById ( getCurrentUser ( ) . getTenantId ( ) , widgetsBundleId ) ;
checkNotNull ( widgetsBundle ) ;
checkNotNull ( widgetsBundle , "Widgets bundle with id [" + widgetsBundleId + "] is not found" ) ;
accessControlService . checkPermission ( getCurrentUser ( ) , Resource . WIDGETS_BUNDLE , operation , widgetsBundleId , widgetsBundle ) ;
accessControlService . checkPermission ( getCurrentUser ( ) , Resource . WIDGETS_BUNDLE , operation , widgetsBundleId , widgetsBundle ) ;
return widgetsBundle ;
return widgetsBundle ;
} catch ( Exception e ) {
} catch ( Exception e ) {
@ -646,7 +656,7 @@ public abstract class BaseController {
try {
try {
validateId ( widgetTypeId , "Incorrect widgetTypeId " + widgetTypeId ) ;
validateId ( widgetTypeId , "Incorrect widgetTypeId " + widgetTypeId ) ;
WidgetTypeDetails widgetTypeDetails = widgetTypeService . findWidgetTypeDetailsById ( getCurrentUser ( ) . getTenantId ( ) , widgetTypeId ) ;
WidgetTypeDetails widgetTypeDetails = widgetTypeService . findWidgetTypeDetailsById ( getCurrentUser ( ) . getTenantId ( ) , widgetTypeId ) ;
checkNotNull ( widgetTypeDetails ) ;
checkNotNull ( widgetTypeDetails , "Widget type with id [" + widgetTypeId + "] is not found" ) ;
accessControlService . checkPermission ( getCurrentUser ( ) , Resource . WIDGET_TYPE , operation , widgetTypeId , widgetTypeDetails ) ;
accessControlService . checkPermission ( getCurrentUser ( ) , Resource . WIDGET_TYPE , operation , widgetTypeId , widgetTypeDetails ) ;
return widgetTypeDetails ;
return widgetTypeDetails ;
} catch ( Exception e ) {
} catch ( Exception e ) {
@ -658,7 +668,7 @@ public abstract class BaseController {
try {
try {
validateId ( dashboardId , "Incorrect dashboardId " + dashboardId ) ;
validateId ( dashboardId , "Incorrect dashboardId " + dashboardId ) ;
Dashboard dashboard = dashboardService . findDashboardById ( getCurrentUser ( ) . getTenantId ( ) , dashboardId ) ;
Dashboard dashboard = dashboardService . findDashboardById ( getCurrentUser ( ) . getTenantId ( ) , dashboardId ) ;
checkNotNull ( dashboard ) ;
checkNotNull ( dashboard , "Dashboard with id [" + dashboardId + "] is not found" ) ;
accessControlService . checkPermission ( getCurrentUser ( ) , Resource . DASHBOARD , operation , dashboardId , dashboard ) ;
accessControlService . checkPermission ( getCurrentUser ( ) , Resource . DASHBOARD , operation , dashboardId , dashboard ) ;
return dashboard ;
return dashboard ;
} catch ( Exception e ) {
} catch ( Exception e ) {
@ -670,7 +680,7 @@ public abstract class BaseController {
try {
try {
validateId ( edgeId , "Incorrect edgeId " + edgeId ) ;
validateId ( edgeId , "Incorrect edgeId " + edgeId ) ;
Edge edge = edgeService . findEdgeById ( getTenantId ( ) , edgeId ) ;
Edge edge = edgeService . findEdgeById ( getTenantId ( ) , edgeId ) ;
checkNotNull ( edge ) ;
checkNotNull ( edge , "Edge with id [" + edgeId + "] is not found" ) ;
accessControlService . checkPermission ( getCurrentUser ( ) , Resource . EDGE , operation , edgeId , edge ) ;
accessControlService . checkPermission ( getCurrentUser ( ) , Resource . EDGE , operation , edgeId , edge ) ;
return edge ;
return edge ;
} catch ( Exception e ) {
} catch ( Exception e ) {
@ -682,7 +692,7 @@ public abstract class BaseController {
try {
try {
validateId ( edgeId , "Incorrect edgeId " + edgeId ) ;
validateId ( edgeId , "Incorrect edgeId " + edgeId ) ;
EdgeInfo edge = edgeService . findEdgeInfoById ( getCurrentUser ( ) . getTenantId ( ) , edgeId ) ;
EdgeInfo edge = edgeService . findEdgeInfoById ( getCurrentUser ( ) . getTenantId ( ) , edgeId ) ;
checkNotNull ( edge ) ;
checkNotNull ( edge , "Edge with id [" + edgeId + "] is not found" ) ;
accessControlService . checkPermission ( getCurrentUser ( ) , Resource . EDGE , operation , edgeId , edge ) ;
accessControlService . checkPermission ( getCurrentUser ( ) , Resource . EDGE , operation , edgeId , edge ) ;
return edge ;
return edge ;
} catch ( Exception e ) {
} catch ( Exception e ) {
@ -694,7 +704,7 @@ public abstract class BaseController {
try {
try {
validateId ( dashboardId , "Incorrect dashboardId " + dashboardId ) ;
validateId ( dashboardId , "Incorrect dashboardId " + dashboardId ) ;
DashboardInfo dashboardInfo = dashboardService . findDashboardInfoById ( getCurrentUser ( ) . getTenantId ( ) , dashboardId ) ;
DashboardInfo dashboardInfo = dashboardService . findDashboardInfoById ( getCurrentUser ( ) . getTenantId ( ) , dashboardId ) ;
checkNotNull ( dashboardInfo ) ;
checkNotNull ( dashboardInfo , "Dashboard with id [" + dashboardId + "] is not found" ) ;
accessControlService . checkPermission ( getCurrentUser ( ) , Resource . DASHBOARD , operation , dashboardId , dashboardInfo ) ;
accessControlService . checkPermission ( getCurrentUser ( ) , Resource . DASHBOARD , operation , dashboardId , dashboardInfo ) ;
return dashboardInfo ;
return dashboardInfo ;
} catch ( Exception e ) {
} catch ( Exception e ) {
@ -732,7 +742,7 @@ public abstract class BaseController {
protected RuleChain checkRuleChain ( RuleChainId ruleChainId , Operation operation ) throws ThingsboardException {
protected RuleChain checkRuleChain ( RuleChainId ruleChainId , Operation operation ) throws ThingsboardException {
validateId ( ruleChainId , "Incorrect ruleChainId " + ruleChainId ) ;
validateId ( ruleChainId , "Incorrect ruleChainId " + ruleChainId ) ;
RuleChain ruleChain = ruleChainService . findRuleChainById ( getCurrentUser ( ) . getTenantId ( ) , ruleChainId ) ;
RuleChain ruleChain = ruleChainService . findRuleChainById ( getCurrentUser ( ) . getTenantId ( ) , ruleChainId ) ;
checkNotNull ( ruleChain ) ;
checkNotNull ( ruleChain , "Rule chain with id [" + ruleChainId + "] is not found" ) ;
accessControlService . checkPermission ( getCurrentUser ( ) , Resource . RULE_CHAIN , operation , ruleChainId , ruleChain ) ;
accessControlService . checkPermission ( getCurrentUser ( ) , Resource . RULE_CHAIN , operation , ruleChainId , ruleChain ) ;
return ruleChain ;
return ruleChain ;
}
}
@ -740,7 +750,7 @@ public abstract class BaseController {
protected RuleNode checkRuleNode ( RuleNodeId ruleNodeId , Operation operation ) throws ThingsboardException {
protected RuleNode checkRuleNode ( RuleNodeId ruleNodeId , Operation operation ) throws ThingsboardException {
validateId ( ruleNodeId , "Incorrect ruleNodeId " + ruleNodeId ) ;
validateId ( ruleNodeId , "Incorrect ruleNodeId " + ruleNodeId ) ;
RuleNode ruleNode = ruleChainService . findRuleNodeById ( getTenantId ( ) , ruleNodeId ) ;
RuleNode ruleNode = ruleChainService . findRuleNodeById ( getTenantId ( ) , ruleNodeId ) ;
checkNotNull ( ruleNode ) ;
checkNotNull ( ruleNode , "Rule node with id [" + ruleNodeId + "] is not found" ) ;
checkRuleChain ( ruleNode . getRuleChainId ( ) , operation ) ;
checkRuleChain ( ruleNode . getRuleChainId ( ) , operation ) ;
return ruleNode ;
return ruleNode ;
}
}
@ -749,7 +759,7 @@ public abstract class BaseController {
try {
try {
validateId ( resourceId , "Incorrect resourceId " + resourceId ) ;
validateId ( resourceId , "Incorrect resourceId " + resourceId ) ;
TbResource resource = resourceService . findResourceById ( getCurrentUser ( ) . getTenantId ( ) , resourceId ) ;
TbResource resource = resourceService . findResourceById ( getCurrentUser ( ) . getTenantId ( ) , resourceId ) ;
checkNotNull ( resource ) ;
checkNotNull ( resource , "Resource with id [" + resourceId + "] is not found" ) ;
accessControlService . checkPermission ( getCurrentUser ( ) , Resource . TB_RESOURCE , operation , resourceId , resource ) ;
accessControlService . checkPermission ( getCurrentUser ( ) , Resource . TB_RESOURCE , operation , resourceId , resource ) ;
return resource ;
return resource ;
} catch ( Exception e ) {
} catch ( Exception e ) {
@ -761,7 +771,7 @@ public abstract class BaseController {
try {
try {
validateId ( resourceId , "Incorrect resourceId " + resourceId ) ;
validateId ( resourceId , "Incorrect resourceId " + resourceId ) ;
TbResourceInfo resourceInfo = resourceService . findResourceInfoById ( getCurrentUser ( ) . getTenantId ( ) , resourceId ) ;
TbResourceInfo resourceInfo = resourceService . findResourceInfoById ( getCurrentUser ( ) . getTenantId ( ) , resourceId ) ;
checkNotNull ( resourceInfo ) ;
checkNotNull ( resourceInfo , "Resource with id [" + resourceId + "] is not found" ) ;
accessControlService . checkPermission ( getCurrentUser ( ) , Resource . TB_RESOURCE , operation , resourceId , resourceInfo ) ;
accessControlService . checkPermission ( getCurrentUser ( ) , Resource . TB_RESOURCE , operation , resourceId , resourceInfo ) ;
return resourceInfo ;
return resourceInfo ;
} catch ( Exception e ) {
} catch ( Exception e ) {
@ -773,7 +783,7 @@ public abstract class BaseController {
try {
try {
validateId ( otaPackageId , "Incorrect otaPackageId " + otaPackageId ) ;
validateId ( otaPackageId , "Incorrect otaPackageId " + otaPackageId ) ;
OtaPackage otaPackage = otaPackageService . findOtaPackageById ( getCurrentUser ( ) . getTenantId ( ) , otaPackageId ) ;
OtaPackage otaPackage = otaPackageService . findOtaPackageById ( getCurrentUser ( ) . getTenantId ( ) , otaPackageId ) ;
checkNotNull ( otaPackage ) ;
checkNotNull ( otaPackage , "OTA package with id [" + otaPackageId + "] is not found" ) ;
accessControlService . checkPermission ( getCurrentUser ( ) , Resource . OTA_PACKAGE , operation , otaPackageId , otaPackage ) ;
accessControlService . checkPermission ( getCurrentUser ( ) , Resource . OTA_PACKAGE , operation , otaPackageId , otaPackage ) ;
return otaPackage ;
return otaPackage ;
} catch ( Exception e ) {
} catch ( Exception e ) {
@ -785,7 +795,7 @@ public abstract class BaseController {
try {
try {
validateId ( otaPackageId , "Incorrect otaPackageId " + otaPackageId ) ;
validateId ( otaPackageId , "Incorrect otaPackageId " + otaPackageId ) ;
OtaPackageInfo otaPackageIn = otaPackageService . findOtaPackageInfoById ( getCurrentUser ( ) . getTenantId ( ) , otaPackageId ) ;
OtaPackageInfo otaPackageIn = otaPackageService . findOtaPackageInfoById ( getCurrentUser ( ) . getTenantId ( ) , otaPackageId ) ;
checkNotNull ( otaPackageIn ) ;
checkNotNull ( otaPackageIn , "OTA package with id [" + otaPackageId + "] is not found" ) ;
accessControlService . checkPermission ( getCurrentUser ( ) , Resource . OTA_PACKAGE , operation , otaPackageId , otaPackageIn ) ;
accessControlService . checkPermission ( getCurrentUser ( ) , Resource . OTA_PACKAGE , operation , otaPackageId , otaPackageIn ) ;
return otaPackageIn ;
return otaPackageIn ;
} catch ( Exception e ) {
} catch ( Exception e ) {
@ -797,7 +807,7 @@ public abstract class BaseController {
try {
try {
validateId ( rpcId , "Incorrect rpcId " + rpcId ) ;
validateId ( rpcId , "Incorrect rpcId " + rpcId ) ;
Rpc rpc = rpcService . findById ( getCurrentUser ( ) . getTenantId ( ) , rpcId ) ;
Rpc rpc = rpcService . findById ( getCurrentUser ( ) . getTenantId ( ) , rpcId ) ;
checkNotNull ( rpc ) ;
checkNotNull ( rpc , "RPC with id [" + rpcId + "] is not found" ) ;
accessControlService . checkPermission ( getCurrentUser ( ) , Resource . RPC , operation , rpcId , rpc ) ;
accessControlService . checkPermission ( getCurrentUser ( ) , Resource . RPC , operation , rpcId , rpc ) ;
return rpc ;
return rpc ;
} catch ( Exception e ) {
} catch ( Exception e ) {