shaofengshi commented on code in PR #5292: URL: https://github.com/apache/gravitino/pull/5292#discussion_r1840335573
########## clients/cli/src/main/java/org/apache/gravitino/cli/commands/SetOwner.java: ########## @@ -0,0 +1,100 @@ +/* + * 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.cli.commands; + +import org.apache.gravitino.MetadataObject; +import org.apache.gravitino.MetadataObjects; +import org.apache.gravitino.authorization.Owner; +import org.apache.gravitino.cli.CommandEntities; +import org.apache.gravitino.cli.ErrorMessages; +import org.apache.gravitino.client.GravitinoClient; +import org.apache.gravitino.exceptions.NoSuchMetadataObjectException; +import org.apache.gravitino.exceptions.NoSuchMetalakeException; + +public class SetOwner extends Command { + + protected final String metalake; + protected final String entity; + protected final MetadataObject.Type entityType; + protected final String owner; + protected final boolean isGroup; + + /** + * Sets the owner of an entity. + * + * @param url The URL of the Gravitino server. + * @param ignoreVersions If true don't check the client/server versions match. + * @param metalake The name of the metalake. + * @param entity The name of the entity. + * @param entityType The type entity. + * @param owner The name of the new owner. + * @param isGroup True if the owner is a group, false if it is not. + */ + public SetOwner( + String url, + boolean ignoreVersions, + String metalake, + String entity, + String entityType, + String owner, + boolean isGroup) { + super(url, ignoreVersions); + this.metalake = metalake; + this.entity = entity; + this.owner = owner; + this.isGroup = isGroup; + + if (entityType.equals(CommandEntities.METALAKE)) { + this.entityType = MetadataObject.Type.METALAKE; + } else if (entityType.equals(CommandEntities.CATALOG)) { + this.entityType = MetadataObject.Type.CATALOG; + } else if (entityType.equals(CommandEntities.SCHEMA)) { + this.entityType = MetadataObject.Type.SCHEMA; + } else if (entityType.equals(CommandEntities.TABLE)) { + this.entityType = MetadataObject.Type.TABLE; + } else if (entityType.equals(CommandEntities.COLUMN)) { + this.entityType = MetadataObject.Type.COLUMN; + } else { + this.entityType = null; + } + } + + /** Sets the owner of an entity. */ + public void handle() { Review Comment: it's minor but need to be consistent, add the @override for handle() method. ########## clients/cli/src/main/java/org/apache/gravitino/cli/commands/AddRoleToUser.java: ########## @@ -0,0 +1,76 @@ +/* + * 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.cli.commands; + +import java.util.ArrayList; +import org.apache.gravitino.cli.ErrorMessages; +import org.apache.gravitino.client.GravitinoClient; +import org.apache.gravitino.exceptions.NoSuchMetalakeException; +import org.apache.gravitino.exceptions.NoSuchRoleException; +import org.apache.gravitino.exceptions.NoSuchUserException; + +/** Adds a role to a user. */ +public class AddRoleToUser extends Command { + + protected String metalake; + protected String user; + protected String role; + + /** + * Adds a role to a user. + * + * @param url The URL of the Gravitino server. + * @param ignoreVersions If true don't check the client/server versions match. + * @param metalake The name of the metalake. + * @param user The name of the user. + * @param role The name of the role. + */ + public AddRoleToUser( + String url, boolean ignoreVersions, String metalake, String user, String role) { + super(url, ignoreVersions); + this.metalake = metalake; + this.user = user; + this.role = role; + } + + /** Adds a role to a user. */ + public void handle() { Review Comment: also here. ########## clients/cli/src/main/java/org/apache/gravitino/cli/commands/SetOwner.java: ########## @@ -0,0 +1,100 @@ +/* + * 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.cli.commands; + +import org.apache.gravitino.MetadataObject; +import org.apache.gravitino.MetadataObjects; +import org.apache.gravitino.authorization.Owner; +import org.apache.gravitino.cli.CommandEntities; +import org.apache.gravitino.cli.ErrorMessages; +import org.apache.gravitino.client.GravitinoClient; +import org.apache.gravitino.exceptions.NoSuchMetadataObjectException; +import org.apache.gravitino.exceptions.NoSuchMetalakeException; + +public class SetOwner extends Command { Review Comment: This file seems not related with this issue and PR. -- 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]
