sentry-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From vam...@apache.org
Subject sentry git commit: SENTRY-1582: Additional comments to clarify the intent of string manipulation methods in SentryStore.java (Vamsee Yarlagadda, Reviewed by: Hao Hao, Kalyan Kalvagadda, Alexander Kolbasov)
Date Tue, 03 Jan 2017 20:20:44 GMT
Repository: sentry
Updated Branches:
  refs/heads/sentry-ha-redesign 3d8877906 -> 31cd4d0d4


SENTRY-1582: Additional comments to clarify the intent of string manipulation methods in SentryStore.java
(Vamsee Yarlagadda, Reviewed by: Hao Hao, Kalyan Kalvagadda, Alexander Kolbasov)


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

Branch: refs/heads/sentry-ha-redesign
Commit: 31cd4d0d44230d304f51e22ff7b3fd3d27b5a602
Parents: 3d88779
Author: Vamsee Yarlagadda <vamsee@cloudera.com>
Authored: Tue Jan 3 11:03:44 2017 -0800
Committer: Vamsee Yarlagadda <vamsee@cloudera.com>
Committed: Tue Jan 3 12:18:23 2017 -0800

----------------------------------------------------------------------
 .../db/service/persistent/SentryStore.java      | 41 ++++++++++++++++++++
 1 file changed, 41 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/sentry/blob/31cd4d0d/sentry-provider/sentry-provider-db/src/main/java/org/apache/sentry/provider/db/service/persistent/SentryStore.java
----------------------------------------------------------------------
diff --git a/sentry-provider/sentry-provider-db/src/main/java/org/apache/sentry/provider/db/service/persistent/SentryStore.java
b/sentry-provider/sentry-provider-db/src/main/java/org/apache/sentry/provider/db/service/persistent/SentryStore.java
index 849aace..3f3afb7 100644
--- a/sentry-provider/sentry-provider-db/src/main/java/org/apache/sentry/provider/db/service/persistent/SentryStore.java
+++ b/sentry-provider/sentry-provider-db/src/main/java/org/apache/sentry/provider/db/service/persistent/SentryStore.java
@@ -1717,14 +1717,55 @@ public class SentryStore {
     return tSentryPrivilege;
   }
 
+  /**
+   * <p>
+   * Convert different forms of empty strings to @NULL_COL and return all other input strings
unmodified.
+   * <p>
+   * Possible empty strings:
+   * <ul>
+   *   <li>null</li>
+   *   <li>empty string ("")</li>
+   * </ul>
+   * <p>
+   * This function is used to create proper MSentryPrivilege objects that are saved in the
Sentry database from the user
+   * supplied privileges (TSentryPrivilege). This function will ensure that the data we are
putting into the database is
+   * always consistent for various types of input from the user. Without this one can save
a column as an empty string
+   * or null or @NULL_COLL specifier.
+   * <p>
+   * @param s string input, and can be null.
+   * @return original string if it is non-empty and @NULL_COL for empty strings.
+   */
   public static String toNULLCol(String s) {
     return Strings.isNullOrEmpty(s) ? NULL_COL : s;
   }
 
+  /**
+   * <p>
+   * Convert different forms of empty strings to an empty string("") and return all other
input strings unmodified.
+   * <p>
+   * Possible empty strings:
+   * <ul>
+   *   <li>null</li>
+   *   <li>empty string ("")</li>
+   *   <li>@NULL_COLL</li>
+   * </ul>
+   * <p>
+   * This function is used to create TSentryPrivilege objects and is essential in maintaining
backward compatibility
+   * for reading the data that is saved in the sentry database. And also to ensure the backward
compatibility of read the
+   * user passed column data (@see TSentryAuthorizable conversion to TSentryPrivilege)
+   * <p>
+   * @param s string input, and can be null.
+   * @return original string if it is non-empty and "" for empty strings.
+   */
   private static String fromNULLCol(String s) {
     return isNULL(s) ? "" : s;
   }
 
+  /**
+   * Function to check if a string is null, empty or @NULL_COLL specifier
+   * @param s string input, and can be null.
+   * @return True if the input string represents a NULL string - when it is null, empty or
equals @NULL_COL
+   */
   public static boolean isNULL(String s) {
     return Strings.isNullOrEmpty(s) || s.equals(NULL_COL);
   }


Mime
View raw message