You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@sentry.apache.org by va...@apache.org on 2017/01/03 20:17:47 UTC

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)

Repository: sentry
Updated Branches:
  refs/heads/master 55d2721c8 -> 3c11bb2dd


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/3c11bb2d
Tree: http://git-wip-us.apache.org/repos/asf/sentry/tree/3c11bb2d
Diff: http://git-wip-us.apache.org/repos/asf/sentry/diff/3c11bb2d

Branch: refs/heads/master
Commit: 3c11bb2dd7704bee0c2376958031abea6bfea53f
Parents: 55d2721
Author: Vamsee Yarlagadda <va...@cloudera.com>
Authored: Tue Jan 3 11:03:44 2017 -0800
Committer: Vamsee Yarlagadda <va...@cloudera.com>
Committed: Tue Jan 3 12:15:43 2017 -0800

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


http://git-wip-us.apache.org/repos/asf/sentry/blob/3c11bb2d/sentry-service/sentry-service-server/src/main/java/org/apache/sentry/provider/db/service/persistent/SentryStore.java
----------------------------------------------------------------------
diff --git a/sentry-service/sentry-service-server/src/main/java/org/apache/sentry/provider/db/service/persistent/SentryStore.java b/sentry-service/sentry-service-server/src/main/java/org/apache/sentry/provider/db/service/persistent/SentryStore.java
index 868e677..f83d721 100644
--- a/sentry-service/sentry-service-server/src/main/java/org/apache/sentry/provider/db/service/persistent/SentryStore.java
+++ b/sentry-service/sentry-service-server/src/main/java/org/apache/sentry/provider/db/service/persistent/SentryStore.java
@@ -1716,14 +1716,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);
   }