roryqi commented on code in PR #9785:
URL: https://github.com/apache/gravitino/pull/9785#discussion_r2797488227
##########
server-common/src/main/java/org/apache/gravitino/server/authorization/MetadataAuthzHelper.java:
##########
@@ -256,6 +256,142 @@ public static <E> E[] filterByExpression(
(unused) -> null);
}
+ /**
+ * Partitions an array of entities into two arrays based on two
authorization expressions. An
+ * entity that satisfies the first expression goes into the first array. An
entity that does not
+ * satisfy the first expression but satisfies the second expression goes
into the second array.
+ * Entities that satisfy neither expression are excluded from both arrays.
+ *
+ * @param metalake metalake name
+ * @param firstExpression authorization expression for the first array
+ * @param secondExpression authorization expression for the second array
+ * @param entityType entity type
+ * @param entities array of metadata entities to partition
+ * @param toNameIdentifier function to convert entity to NameIdentifier
+ * @return A FilterResult containing both partitioned arrays
+ * @param <E> Entity class
+ */
+ public static <E> FilterResult<E, E> partitionByTwoExpressions(
+ String metalake,
+ String firstExpression,
+ String secondExpression,
+ Entity.EntityType entityType,
+ E[] entities,
+ Function<E, NameIdentifier> toNameIdentifier) {
+ Class<?> componentType = entities.getClass().getComponentType();
+ if (!enableAuthorization()) {
+ E[] emptyArray = createArray(componentType, 0);
+ return new FilterResult<>(entities, emptyArray);
+ }
+ checkExecutor();
+
+ Principal currentPrincipal = PrincipalUtils.getCurrentPrincipal();
+ GravitinoAuthorizer authorizer =
+ GravitinoAuthorizerProvider.getInstance().getGravitinoAuthorizer();
+ AuthorizationRequestContext authorizationRequestContext = new
AuthorizationRequestContext();
+ List<CompletableFuture<int[]>> futures = new ArrayList<>();
Review Comment:
OK, thanks.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]