plusplusjiajia commented on code in PR #9393:
URL: https://github.com/apache/paimon/pull/9393#discussion_r3859615445


##########
paimon-api/src/main/java/org/apache/paimon/management/ListPermissionsRequest.java:
##########
@@ -0,0 +1,144 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.paimon.management;
+
+import org.apache.paimon.annotation.Experimental;
+
+import javax.annotation.Nullable;
+
+import static org.apache.paimon.utils.Preconditions.checkArgument;
+import static org.apache.paimon.utils.Preconditions.checkNotNull;
+
+/** Exact resource or scope, principal, and pagination filters for permission 
assignments. */
+@Experimental
+public class ListPermissionsRequest {
+
+    public static final int MAX_PAGE_SIZE = 1000;
+
+    private final PermissionResource resource;
+    @Nullable private final String principal;
+    @Nullable private final String access;
+    @Nullable private final String pageToken;
+    @Nullable private final Integer maxResults;
+
+    public ListPermissionsRequest(
+            ResourceType resourceType,
+            @Nullable String database,
+            @Nullable String table,
+            @Nullable String function,
+            @Nullable String view,
+            @Nullable String principal,
+            @Nullable String access,
+            @Nullable String pageToken,
+            @Nullable Integer maxResults) {
+        this.resource = exactResource(resourceType, database, table, function, 
view);
+        if (!isBlank(principal)) {
+            PermissionAssignment.validatePrincipal(principal);
+        }
+        checkArgument(maxResults == null || maxResults > 0, "maxResults must 
be greater than 0.");
+        checkArgument(
+                maxResults == null || maxResults <= MAX_PAGE_SIZE,
+                "maxResults must be at most %s.",
+                MAX_PAGE_SIZE);
+        this.principal = isBlank(principal) ? null : principal;
+        this.access = isBlank(access) ? null : 
PermissionAccess.canonicalize(resource, access);
+        this.pageToken = isBlank(pageToken) ? null : pageToken;

Review Comment:
   When a server emits a nonempty whitespace-only continuation token, 
withPageToken routes it through this constructor and converts it to null; the 
next GET then omits pageToken and fetches the first page again, and 
PagedList.listAllFromPagedApi can loop indefinitely if that page keeps 
returning the token. Page tokens are
   opaque and the paging API uses null as the first-page marker, so retain the 
returned token unchanged.



-- 
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]

Reply via email to