sentry-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ak...@apache.org
Subject [01/13] sentry git commit: General cleanup
Date Thu, 11 May 2017 06:45:06 GMT
Repository: sentry
Updated Branches:
  refs/heads/akolb-ha-cli [created] 00747e94f


General cleanup


Project: http://git-wip-us.apache.org/repos/asf/sentry/repo
Commit: http://git-wip-us.apache.org/repos/asf/sentry/commit/12f2ed56
Tree: http://git-wip-us.apache.org/repos/asf/sentry/tree/12f2ed56
Diff: http://git-wip-us.apache.org/repos/asf/sentry/diff/12f2ed56

Branch: refs/heads/akolb-ha-cli
Commit: 12f2ed5652e02e10271e2d65b91395020761c598
Parents: 6031849
Author: Alexander Kolbasov <akolb@cloudera.com>
Authored: Thu Dec 15 18:03:50 2016 -0800
Committer: Alexander Kolbasov <akolb@cloudera.com>
Committed: Wed May 10 23:28:29 2017 -0700

----------------------------------------------------------------------
 .../org/apache/sentry/shell/GroupShell.java     |  4 +--
 .../org/apache/sentry/shell/PrivsShell.java     |  4 +--
 .../org/apache/sentry/shell/RolesShell.java     |  2 +-
 .../java/org/apache/sentry/shell/SentryCli.java | 26 +++-----------------
 .../java/org/apache/sentry/shell/ShellUtil.java |  8 ++----
 .../org/apache/sentry/shell/TopLevelShell.java  |  2 +-
 6 files changed, 11 insertions(+), 35 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/sentry/blob/12f2ed56/sentry-tools/src/main/java/org/apache/sentry/shell/GroupShell.java
----------------------------------------------------------------------
diff --git a/sentry-tools/src/main/java/org/apache/sentry/shell/GroupShell.java b/sentry-tools/src/main/java/org/apache/sentry/shell/GroupShell.java
index 246509c..a69557b 100644
--- a/sentry-tools/src/main/java/org/apache/sentry/shell/GroupShell.java
+++ b/sentry-tools/src/main/java/org/apache/sentry/shell/GroupShell.java
@@ -56,10 +56,10 @@ public class GroupShell implements ShellDependent {
     }
 
     private final ShellUtil tools;
-    Shell shell;
+    private Shell shell;
 
 
-    public GroupShell(SentryPolicyServiceClient sentryClient, String authUser) {
+    GroupShell(SentryPolicyServiceClient sentryClient, String authUser) {
         this.tools = new ShellUtil(sentryClient, authUser);
     }
 

http://git-wip-us.apache.org/repos/asf/sentry/blob/12f2ed56/sentry-tools/src/main/java/org/apache/sentry/shell/PrivsShell.java
----------------------------------------------------------------------
diff --git a/sentry-tools/src/main/java/org/apache/sentry/shell/PrivsShell.java b/sentry-tools/src/main/java/org/apache/sentry/shell/PrivsShell.java
index 2e12be8..9b6bf9b 100644
--- a/sentry-tools/src/main/java/org/apache/sentry/shell/PrivsShell.java
+++ b/sentry-tools/src/main/java/org/apache/sentry/shell/PrivsShell.java
@@ -28,7 +28,7 @@ import java.util.List;
 
 public class PrivsShell implements ShellDependent {
     private final ShellUtil tools;
-    Shell shell;
+    private Shell shell;
 
     @Command(description = "Grant privilege to role")
     public void grant(
@@ -60,7 +60,7 @@ public class PrivsShell implements ShellDependent {
         tools.revokePrivilegeFromRole(roleName, privilege);
     }
 
-    public PrivsShell(SentryPolicyServiceClient sentryClient, String authUser) {
+    PrivsShell(SentryPolicyServiceClient sentryClient, String authUser) {
         this.tools = new ShellUtil(sentryClient, authUser);
     }
 

http://git-wip-us.apache.org/repos/asf/sentry/blob/12f2ed56/sentry-tools/src/main/java/org/apache/sentry/shell/RolesShell.java
----------------------------------------------------------------------
diff --git a/sentry-tools/src/main/java/org/apache/sentry/shell/RolesShell.java b/sentry-tools/src/main/java/org/apache/sentry/shell/RolesShell.java
index 9ac6637..dc72382 100644
--- a/sentry-tools/src/main/java/org/apache/sentry/shell/RolesShell.java
+++ b/sentry-tools/src/main/java/org/apache/sentry/shell/RolesShell.java
@@ -65,7 +65,7 @@ public class RolesShell implements ShellDependent {
     private final ShellUtil tools;
     Shell shell;
 
-    public RolesShell(SentryPolicyServiceClient sentryClient, String authUser) {
+    RolesShell(SentryPolicyServiceClient sentryClient, String authUser) {
         this.tools = new ShellUtil(sentryClient, authUser);
     }
 

http://git-wip-us.apache.org/repos/asf/sentry/blob/12f2ed56/sentry-tools/src/main/java/org/apache/sentry/shell/SentryCli.java
----------------------------------------------------------------------
diff --git a/sentry-tools/src/main/java/org/apache/sentry/shell/SentryCli.java b/sentry-tools/src/main/java/org/apache/sentry/shell/SentryCli.java
index 36833c8..ea5415d 100644
--- a/sentry-tools/src/main/java/org/apache/sentry/shell/SentryCli.java
+++ b/sentry-tools/src/main/java/org/apache/sentry/shell/SentryCli.java
@@ -25,8 +25,6 @@ import org.apache.hadoop.security.UserGroupInformation;
 import org.apache.log4j.PropertyConfigurator;
 import org.apache.sentry.provider.db.service.thrift.SentryPolicyServiceClient;
 import org.apache.sentry.service.thrift.SentryServiceClientFactory;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
 
 import java.io.FileInputStream;
 import java.io.FileNotFoundException;
@@ -42,7 +40,6 @@ import static org.apache.sentry.service.thrift.ServiceConstants.ServerConfig.SEC
  * Sentry interactive tool
  */
 public class SentryCli {
-    private static final Logger log = LoggerFactory.getLogger(SentryCli.class.getName());
     private static final String LOG4J_CONF = "log4jConf";
     private final String[] args;
     private Options options = new Options();
@@ -63,11 +60,11 @@ public class SentryCli {
 
     private SentryPolicyServiceClient sentryClient;
 
-    public SentryPolicyServiceClient getSentryClient() {
+    private SentryPolicyServiceClient getSentryClient() {
         return sentryClient;
     }
 
-    public String getRequestorName() {
+    private String getRequestorName() {
         return requestorName;
     }
 
@@ -85,7 +82,7 @@ public class SentryCli {
      * Construct SentryCli from arguments
      * @param args command-line arguments
      */
-    public SentryCli(String[] args) {
+    private SentryCli(String[] args) {
         this.args = args;
         options.addOption("h", "help", false, "show help");
         // file path of sentry-site
@@ -106,23 +103,6 @@ public class SentryCli {
     }
 
     /**
-     * Parse command-line arguments.
-     */
-    public void parse() {
-        CommandLineParser parser = new GnuParser();
-        try {
-            cmd = parser.parse(options, args);
-            if (cmd.hasOption("h")) {
-                help();
-            }
-        } catch (ParseException e) {
-            log.warn("error in parsing expression", e);
-            help();
-            System.exit(1);
-        }
-    }
-
-    /**
      * Initialize CLI
      */
     private void init() {

http://git-wip-us.apache.org/repos/asf/sentry/blob/12f2ed56/sentry-tools/src/main/java/org/apache/sentry/shell/ShellUtil.java
----------------------------------------------------------------------
diff --git a/sentry-tools/src/main/java/org/apache/sentry/shell/ShellUtil.java b/sentry-tools/src/main/java/org/apache/sentry/shell/ShellUtil.java
index 007975c..2b08684 100644
--- a/sentry-tools/src/main/java/org/apache/sentry/shell/ShellUtil.java
+++ b/sentry-tools/src/main/java/org/apache/sentry/shell/ShellUtil.java
@@ -35,7 +35,6 @@ import static org.apache.sentry.service.thrift.SentryServiceUtil.convertToTSentr
 class ShellUtil {
 
     List<String> listRoles() {
-        List<String> roles = null;
         try {
             return getRoles();
         } catch (SentryUserException e) {
@@ -213,7 +212,6 @@ class ShellUtil {
             if (ServiceConstants.PrivilegeScope.URI.toString().equals(tPriv.getPrivilegeScope()))
{
                 sentryClient.grantURIPrivilege(authUser, roleName, tPriv.getServerName(),
                         tPriv.getURI(), grantOption);
-                return;
             }
         } catch (SentryUserException e) {
             System.out.println("Error granting privilege: " + e.toString());
@@ -275,7 +273,7 @@ class ShellUtil {
 
     void revokePrivilegeFromRole(String roleName, String privilegeStr) {
         TSentryPrivilege tSentryPrivilege = convertToTSentryPrivilege(privilegeStr);
-        boolean grantOption = tSentryPrivilege.getGrantOption().equals(TSentryGrantOption.TRUE)
? true : false;
+        boolean grantOption = tSentryPrivilege.getGrantOption().equals(TSentryGrantOption.TRUE);
 
         try {
             if (ServiceConstants.PrivilegeScope.SERVER.toString().equals(tSentryPrivilege.getPrivilegeScope()))
{
@@ -303,7 +301,6 @@ class ShellUtil {
             if (ServiceConstants.PrivilegeScope.URI.toString().equals(tSentryPrivilege.getPrivilegeScope()))
{
                 sentryClient.revokeURIPrivilege(authUser, roleName, tSentryPrivilege.getServerName(),
                         tSentryPrivilege.getURI(), grantOption);
-                return;
             }
         } catch (SentryUserException e) {
             System.out.println("failed to revoke privilege: " + e.toString());
@@ -313,8 +310,7 @@ class ShellUtil {
 
     private List<String>getRoles() throws SentryUserException {
         // Collect role names
-        Set<TSentryRole> roles = null;
-        roles = sentryClient.listRoles(authUser);
+        final Set<TSentryRole> roles = sentryClient.listRoles(authUser);
         List<String> roleNames = new ArrayList<>();
         for(TSentryRole role: roles) {
             roleNames.add(role.getRoleName());

http://git-wip-us.apache.org/repos/asf/sentry/blob/12f2ed56/sentry-tools/src/main/java/org/apache/sentry/shell/TopLevelShell.java
----------------------------------------------------------------------
diff --git a/sentry-tools/src/main/java/org/apache/sentry/shell/TopLevelShell.java b/sentry-tools/src/main/java/org/apache/sentry/shell/TopLevelShell.java
index 047f11c..e004776 100644
--- a/sentry-tools/src/main/java/org/apache/sentry/shell/TopLevelShell.java
+++ b/sentry-tools/src/main/java/org/apache/sentry/shell/TopLevelShell.java
@@ -1,4 +1,4 @@
-/**
+/*
  * 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


Mime
View raw message