@@ -360,79 +360,50 @@ private static List<SecurableObject> listSecurableObjects(RolePO po) {
360
360
.collect (Collectors .groupingBy (SecurableObjectPO ::getType ))
361
361
.forEach (
362
362
(type , objects ) -> {
363
- // If the type is Fileset, use the batch retrieval interface;
364
- // otherwise, use the single retrieval interface
365
- switch (MetadataObject .Type .valueOf (type )) {
366
- case METALAKE :
367
- case CATALOG :
368
- case FILESET :
369
- case TABLE :
370
- case MODEL :
371
- case TOPIC :
372
- List <Long > objectIds =
373
- objects .stream ()
374
- .map (SecurableObjectPO ::getMetadataObjectId )
375
- .collect (Collectors .toList ());
376
-
377
- Map <MetadataObject .Type , Function <List <Long >, Map <Long , String >>>
378
- objectFullNameGetterFnMap =
379
- ImmutableMap .of (
380
- MetadataObject .Type .METALAKE ,
381
- MetadataObjectService ::getMetalakeObjectFullNames ,
382
- MetadataObject .Type .CATALOG ,
383
- MetadataObjectService ::getCatalogObjectFullNames ,
384
- MetadataObject .Type .FILESET ,
385
- MetadataObjectService ::getFilesetObjectFullNames ,
386
- MetadataObject .Type .TABLE ,
387
- MetadataObjectService ::getTableObjectFullNames ,
388
- MetadataObject .Type .MODEL ,
389
- MetadataObjectService ::getModelObjectFullNames ,
390
- MetadataObject .Type .TOPIC ,
391
- MetadataObjectService ::getTopicObjectFullNames );
392
-
393
- // dynamically calling getter function based on type
394
- Map <Long , String > objectIdAndNameMap =
395
- Optional .of (MetadataObject .Type .valueOf (type ))
396
- .map (objectFullNameGetterFnMap ::get )
397
- .map (getter -> getter .apply (objectIds ))
398
- .orElseThrow (
399
- () ->
400
- new IllegalArgumentException (
401
- "Unsupported metadata object type: " + type ));
402
-
403
- for (SecurableObjectPO securableObjectPO : objects ) {
404
- String fullName =
405
- objectIdAndNameMap .get (securableObjectPO .getMetadataObjectId ());
406
- if (fullName != null ) {
407
- securableObjects .add (
408
- POConverters .fromSecurableObjectPO (
409
- fullName , securableObjectPO , getType (securableObjectPO .getType ())));
410
- } else {
411
- LOG .warn (
412
- "The securable object {} {} may be deleted" ,
413
- securableObjectPO .getMetadataObjectId (),
414
- securableObjectPO .getType ());
415
- }
416
- }
417
- break ;
418
- default :
419
-
420
- // todo:to get other securable object fullNames using batch retrieving
421
- for (SecurableObjectPO securableObjectPO : objects ) {
422
- String fullName =
423
- MetadataObjectService .getMetadataObjectFullName (
424
- securableObjectPO .getType (), securableObjectPO .getMetadataObjectId ());
425
- if (fullName != null ) {
426
- securableObjects .add (
427
- POConverters .fromSecurableObjectPO (
428
- fullName , securableObjectPO , getType (securableObjectPO .getType ())));
429
- } else {
430
- LOG .warn (
431
- "The securable object {} {} may be deleted" ,
432
- securableObjectPO .getMetadataObjectId (),
433
- securableObjectPO .getType ());
434
- }
435
- }
363
+ List <Long > objectIds =
364
+ objects .stream ()
365
+ .map (SecurableObjectPO ::getMetadataObjectId )
366
+ .collect (Collectors .toList ());
367
+
368
+ Map <MetadataObject .Type , Function <List <Long >, Map <Long , String >>>
369
+ objectFullNameGetterFnMap =
370
+ ImmutableMap .of (
371
+ MetadataObject .Type .METALAKE ,
372
+ MetadataObjectService ::getMetalakeObjectFullNames ,
373
+ MetadataObject .Type .CATALOG ,
374
+ MetadataObjectService ::getCatalogObjectFullNames ,
375
+ MetadataObject .Type .FILESET ,
376
+ MetadataObjectService ::getFilesetObjectFullNames ,
377
+ MetadataObject .Type .TABLE ,
378
+ MetadataObjectService ::getTableObjectFullNames ,
379
+ MetadataObject .Type .MODEL ,
380
+ MetadataObjectService ::getModelObjectFullNames ,
381
+ MetadataObject .Type .TOPIC ,
382
+ MetadataObjectService ::getTopicObjectFullNames );
383
+
384
+ // dynamically calling getter function based on type
385
+ Map <Long , String > objectIdAndNameMap =
386
+ Optional .of (MetadataObject .Type .valueOf (type ))
387
+ .map (objectFullNameGetterFnMap ::get )
388
+ .map (getter -> getter .apply (objectIds ))
389
+ .orElseThrow (
390
+ () ->
391
+ // For example: COLUMN doesn't have securable object
392
+ new IllegalArgumentException (
393
+ "Unsupported metadata object type: " + type ));
394
+
395
+ for (SecurableObjectPO securableObjectPO : objects ) {
396
+ String fullName = objectIdAndNameMap .get (securableObjectPO .getMetadataObjectId ());
397
+ if (fullName != null ) {
398
+ securableObjects .add (
399
+ POConverters .fromSecurableObjectPO (
400
+ fullName , securableObjectPO , getType (securableObjectPO .getType ())));
401
+ } else {
402
+ LOG .warn (
403
+ "The securable object {} {} may be deleted" ,
404
+ securableObjectPO .getMetadataObjectId (),
405
+ securableObjectPO .getType ());
406
+ }
436
407
}
437
408
});
438
409
0 commit comments