-
Notifications
You must be signed in to change notification settings - Fork 337
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'CLI_VIIIa' into CLI_VIXb
- Loading branch information
Showing
43 changed files
with
2,039 additions
and
77 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
77 changes: 77 additions & 0 deletions
77
clients/cli/src/main/java/org/apache/gravitino/cli/commands/AddRoleToGroup.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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.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 group. */ | ||
public class AddRoleToGroup extends Command { | ||
|
||
protected String metalake; | ||
protected String group; | ||
protected String role; | ||
|
||
/** | ||
* Adds a role to a group. | ||
* | ||
* @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 group The name of the group. | ||
* @param role The name of the role. | ||
*/ | ||
public AddRoleToGroup( | ||
String url, boolean ignoreVersions, String metalake, String group, String role) { | ||
super(url, ignoreVersions); | ||
this.metalake = metalake; | ||
this.group = group; | ||
this.role = role; | ||
} | ||
|
||
/** Adds a role to a group. */ | ||
@Override | ||
public void handle() { | ||
try { | ||
GravitinoClient client = buildClient(metalake); | ||
ArrayList<String> roles = new ArrayList<>(); | ||
roles.add(role); | ||
client.grantRolesToGroup(roles, group); | ||
} catch (NoSuchMetalakeException err) { | ||
System.err.println(ErrorMessages.UNKNOWN_METALAKE); | ||
return; | ||
} catch (NoSuchRoleException err) { | ||
System.err.println(ErrorMessages.UNKNOWN_ROLE); | ||
return; | ||
} catch (NoSuchUserException err) { | ||
System.err.println(ErrorMessages.UNKNOWN_USER); | ||
return; | ||
} catch (Exception exp) { | ||
System.err.println(exp.getMessage()); | ||
return; | ||
} | ||
|
||
System.out.println(role + " added to " + group); | ||
} | ||
} |
Oops, something went wrong.