|
|
|
@ -48,8 +48,8 @@ import org.thingsboard.server.service.security.permission.Operation; |
|
|
|
import org.thingsboard.server.service.security.permission.Resource; |
|
|
|
|
|
|
|
import java.util.ArrayList; |
|
|
|
import java.util.Collections; |
|
|
|
import java.util.List; |
|
|
|
import java.util.Objects; |
|
|
|
import java.util.concurrent.ExecutionException; |
|
|
|
|
|
|
|
import static org.thingsboard.server.controller.ControllerConstants.ASSET_PROFILE_ID; |
|
|
|
@ -236,7 +236,9 @@ public class AssetProfileController extends BaseController { |
|
|
|
@Parameter(description = "A list of asset profile ids, separated by comma ','", array = @ArraySchema(schema = @Schema(type = "string")), required = true) |
|
|
|
@RequestParam("assetProfileIds") String[] strAssetProfileIds) throws ThingsboardException, ExecutionException, InterruptedException { |
|
|
|
checkArrayParameter("assetProfileIds", strAssetProfileIds); |
|
|
|
|
|
|
|
if (!accessControlService.hasPermission(getCurrentUser(), Resource.ASSET_PROFILE, Operation.READ)) { |
|
|
|
return Collections.emptyList(); |
|
|
|
} |
|
|
|
SecurityUser user = getCurrentUser(); |
|
|
|
TenantId tenantId = user.getTenantId(); |
|
|
|
List<AssetProfileId> assetProfileIds = new ArrayList<>(); |
|
|
|
@ -244,16 +246,7 @@ public class AssetProfileController extends BaseController { |
|
|
|
assetProfileIds.add(new AssetProfileId(toUUID(strAssetProfileId))); |
|
|
|
} |
|
|
|
|
|
|
|
return Objects.requireNonNull(checkNotNull(assetProfileService.findAssetProfilesByIdsAsync(tenantId, assetProfileIds).get())) |
|
|
|
.stream() |
|
|
|
.filter(e -> { |
|
|
|
try { |
|
|
|
return accessControlService.hasPermission(user, Resource.ASSET_PROFILE, Operation.READ, e.getId(), e); |
|
|
|
} catch (ThingsboardException ex) { |
|
|
|
return false; |
|
|
|
} |
|
|
|
}) |
|
|
|
.toList(); |
|
|
|
return checkNotNull(assetProfileService.findAssetProfilesByIdsAsync(tenantId, assetProfileIds).get()); |
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|