FANNG1 commented on code in PR #5584:
URL: https://github.com/apache/gravitino/pull/5584#discussion_r1843323671


##########
iceberg/iceberg-rest-server/src/main/java/org/apache/gravitino/iceberg/service/rest/IcebergViewRenameOperations.java:
##########
@@ -30,33 +31,49 @@
 import javax.ws.rs.core.Context;
 import javax.ws.rs.core.MediaType;
 import javax.ws.rs.core.Response;
-import org.apache.gravitino.iceberg.service.IcebergCatalogWrapperManager;
 import org.apache.gravitino.iceberg.service.IcebergRestUtils;
+import 
org.apache.gravitino.iceberg.service.dispatcher.IcebergViewOperationDispatcher;
+import org.apache.gravitino.listener.api.event.IcebergRequestContext;
 import org.apache.gravitino.metrics.MetricNames;
 import org.apache.iceberg.rest.requests.RenameTableRequest;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
 
 @Path("/v1/{prefix:([^/]*/)?}views/rename")
 @Consumes(MediaType.APPLICATION_JSON)
 @Produces(MediaType.APPLICATION_JSON)
 public class IcebergViewRenameOperations {
+  private static final Logger LOG = 
LoggerFactory.getLogger(IcebergViewRenameOperations.class);
 
-  @SuppressWarnings("UnusedVariable")
-  @Context
-  private HttpServletRequest httpRequest;
+  @Context private HttpServletRequest httpRequest;
 
-  private IcebergCatalogWrapperManager icebergCatalogWrapperManager;
+  private IcebergViewOperationDispatcher viewOperationDispatcher;
 
   @Inject
-  public IcebergViewRenameOperations(IcebergCatalogWrapperManager 
icebergCatalogWrapperManager) {
-    this.icebergCatalogWrapperManager = icebergCatalogWrapperManager;
+  public IcebergViewRenameOperations(IcebergViewOperationDispatcher 
viewOperationDispatcher) {
+    this.viewOperationDispatcher = viewOperationDispatcher;
   }
 
   @POST
   @Produces(MediaType.APPLICATION_JSON)
   @Timed(name = "rename-view." + MetricNames.HTTP_PROCESS_DURATION, absolute = 
true)
   @ResponseMetered(name = "rename-view", absolute = true)
-  public Response renameView(@PathParam("prefix") String prefix, 
RenameTableRequest request) {
-    icebergCatalogWrapperManager.getOps(prefix).renameView(request);
-    return IcebergRestUtils.noContent();
+  public Response renameView(
+      @PathParam("prefix") String prefix, RenameTableRequest 
renameViewRequest) {
+    String catalogName = IcebergRestUtils.getCatalogName(prefix);
+    LOG.info(
+        "Rename Iceberg view, catalog: {}, source: {}, destination: {}.",
+        catalogName,
+        renameViewRequest.source(),
+        renameViewRequest.destination());
+    IcebergRequestContext context = new 
IcebergRequestContext(httpServletRequest(), catalogName);
+    viewOperationDispatcher.renameView(context, renameViewRequest);
+    return IcebergRestUtils.okWithoutContent();

Review Comment:
   According to  
https://github.com/apache/iceberg/blob/main/open-api/rest-catalog-open-api.yaml#L1737,
  we should return 204 not 200.



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