Copilot commented on code in PR #14772:
URL: https://github.com/apache/gravitino/pull/14772#discussion_r4533627510


##########
clients/client-java/src/main/java/org/apache/gravitino/client/GravitinoMetalake.java:
##########
@@ -1011,6 +1022,111 @@ public PolicyTagAssociation[] 
listTagAssociationsForPolicy(String policyName) {
         .toArray(PolicyTagAssociation[]::new);
   }
 
+  /** {@inheritDoc} */
+  @Override
+  public String[] listDomains() {
+    NameListResponse response =
+        restClient.get(
+            String.format(API_METALAKES_DOMAINS_PATH, 
RESTUtils.encodeString(name())),
+            NameListResponse.class,
+            Collections.emptyMap(),
+            ErrorHandlers.domainErrorHandler());
+    response.validate();
+    return response.getNames();
+  }
+
+  /** {@inheritDoc} */
+  @Override
+  public Domain[] listDomainsInfo() {
+    DomainListResponse response =
+        restClient.get(
+            String.format(API_METALAKES_DOMAINS_PATH, 
RESTUtils.encodeString(name())),
+            ImmutableMap.of("details", "true"),
+            DomainListResponse.class,
+            Collections.emptyMap(),
+            ErrorHandlers.domainErrorHandler());
+    response.validate();
+    return Arrays.stream(response.getDomains())
+        .map(dto -> new GenericDomain(dto, restClient, name()))
+        .toArray(Domain[]::new);
+  }
+
+  /** {@inheritDoc} */
+  @Override
+  public Domain getDomain(String name) {
+    DomainResponse response =
+        restClient.get(
+            GenericDomain.domainPath(name(), name),
+            DomainResponse.class,
+            Collections.emptyMap(),
+            ErrorHandlers.domainErrorHandler());
+    response.validate();
+    return new GenericDomain(response.getDomain(), restClient, name());
+  }
+
+  /** {@inheritDoc} */
+  @Override
+  public Domain createDomain(
+      String name,
+      @Nullable String comment,
+      @Nullable Map<String, String> properties,
+      TagValue backingTag,
+      boolean createBackingTag) {
+    Preconditions.checkArgument(backingTag != null, "backingTag must not be 
null");
+    DomainCreateRequest request =
+        new DomainCreateRequest(
+            name,
+            comment,
+            properties,
+            null,
+            new DomainCreateRequest.BackingTag(
+                backingTag.name(), backingTag.value().orElse(null), 
createBackingTag));
+    request.validate();

Review Comment:
   Creation and rename accept `.` and `..`, but `GenericDomain.domainPath()` 
rejects all subsequent name-addressed operations, including deletion. Validate 
new names before sending requests, while retaining the path-safety guard. Apply 
the same validation in `GenericDomain.createSubdomain()` and 
`DTOConverters.toDomainUpdateRequest()`.



##########
clients/client-java/src/main/java/org/apache/gravitino/client/MetadataObjectDomainOperations.java:
##########
@@ -0,0 +1,77 @@
+/*
+ * 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.gravitino.client;
+
+import com.google.common.collect.ImmutableMap;
+import java.util.Arrays;
+import java.util.Collections;
+import java.util.Locale;
+import org.apache.gravitino.MetadataObject;
+import org.apache.gravitino.domain.Domain;
+import org.apache.gravitino.domain.SupportsDomains;
+import org.apache.gravitino.dto.responses.DomainListResponse;
+import org.apache.gravitino.dto.responses.NameListResponse;
+import org.apache.gravitino.rest.RESTUtils;
+
+/** Domain lookup for a leaf metadata object. */
+class MetadataObjectDomainOperations implements SupportsDomains {
+  private final RESTClient restClient;
+  private final String metalake;
+  private final String path;
+
+  MetadataObjectDomainOperations(String metalake, MetadataObject object, 
RESTClient restClient) {
+    this.restClient = restClient;
+    this.metalake = metalake;
+    this.path =
+        String.format(
+            "api/metalakes/%s/objects/%s/%s/domains",
+            RESTUtils.encodeString(metalake),
+            object.type().name().toLowerCase(Locale.ROOT),
+            RESTUtils.encodeString(object.fullName()));

Review Comment:
   For a leaf named `asset/a. b`, this sends `cat.db.asset/a. b`; the server 
splits it on every dot and rejects the four-part identifier, so both domain 
lookup methods fail with HTTP 400. URL encoding cannot preserve those component 
boundaries after decoding. Use an address format that preserves identifier 
components, coordinate it with the server, and add an endpoint regression test.



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