ranger-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ab...@apache.org
Subject ranger git commit: RANGER-2000: Create transaction log when policy priority changes
Date Fri, 23 Mar 2018 19:26:41 GMT
Repository: ranger
Updated Branches:
  refs/heads/master 98e6b6631 -> 5f6e6ce72


RANGER-2000: Create transaction log when policy priority changes


Project: http://git-wip-us.apache.org/repos/asf/ranger/repo
Commit: http://git-wip-us.apache.org/repos/asf/ranger/commit/5f6e6ce7
Tree: http://git-wip-us.apache.org/repos/asf/ranger/tree/5f6e6ce7
Diff: http://git-wip-us.apache.org/repos/asf/ranger/diff/5f6e6ce7

Branch: refs/heads/master
Commit: 5f6e6ce72e16343c47b5294b93e15b81f4ebf475
Parents: 98e6b66
Author: Abhay Kulkarni <akulkarni@hortonworks.com>
Authored: Fri Mar 23 12:04:37 2018 -0700
Committer: Abhay Kulkarni <akulkarni@hortonworks.com>
Committed: Fri Mar 23 12:04:37 2018 -0700

----------------------------------------------------------------------
 .../ranger/service/RangerPolicyService.java      | 19 ++++++++++++++++---
 1 file changed, 16 insertions(+), 3 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ranger/blob/5f6e6ce7/security-admin/src/main/java/org/apache/ranger/service/RangerPolicyService.java
----------------------------------------------------------------------
diff --git a/security-admin/src/main/java/org/apache/ranger/service/RangerPolicyService.java
b/security-admin/src/main/java/org/apache/ranger/service/RangerPolicyService.java
index 98ed9fe..519d8e9 100644
--- a/security-admin/src/main/java/org/apache/ranger/service/RangerPolicyService.java
+++ b/security-admin/src/main/java/org/apache/ranger/service/RangerPolicyService.java
@@ -71,6 +71,7 @@ public class RangerPolicyService extends RangerPolicyServiceBase<XXPolicy,
Range
 	public static final String IS_AUDIT_ENABLED_CLASS_FIELD_NAME="isAuditEnabled";
         public static final String POLICY_LABELS_CLASS_FIELD_NAME="policyLabels";
         public static final String POLICY_VALIDITYSCHEDULES_CLASS_FIELD_NAME="validitySchedules";
+        public static final String POLICY_PRIORITY_CLASS_FIELD_NAME="policyPriority";
 
 	static HashMap<String, VTrxLogAttr> trxLogAttrs = new HashMap<String, VTrxLogAttr>();
 	String actionCreate;
@@ -91,6 +92,7 @@ public class RangerPolicyService extends RangerPolicyServiceBase<XXPolicy,
Range
 		trxLogAttrs.put("isAuditEnabled", new VTrxLogAttr("isAuditEnabled", "Audit Status", false));
 		trxLogAttrs.put("policyLabels", new VTrxLogAttr("policyLabels", "Policy Labels", false));
 		trxLogAttrs.put("validitySchedules", new VTrxLogAttr("validitySchedules", "Validity Schedules",
false));
+		trxLogAttrs.put("policyPriority", new VTrxLogAttr("policyPriority", "Priority", false));
 	}
 	
 	public RangerPolicyService() {
@@ -241,7 +243,9 @@ public class RangerPolicyService extends RangerPolicyServiceBase<XXPolicy,
Range
                                 value = processPolicyLabelsClassFieldNameForTrxLog(field.get(vObj));
 			} else if (POLICY_VALIDITYSCHEDULES_CLASS_FIELD_NAME.equalsIgnoreCase(fieldName)) {
 				value = processValiditySchedulesClassFieldNameForTrxLog(field.get(vObj));
-                        } else {
+			} else if (POLICY_PRIORITY_CLASS_FIELD_NAME.equalsIgnoreCase(fieldName)) {
+				value = processPriorityClassFieldNameForTrxLog(field.get(vObj));
+			} else {
 				value = "" + field.get(vObj);
 			}
 
@@ -335,6 +339,8 @@ public class RangerPolicyService extends RangerPolicyServiceBase<XXPolicy,
Range
 					oldValue = processPolicyLabelsClassFieldNameForTrxLog(oldPolicy.getPolicyLabels());
 				} else if (POLICY_VALIDITYSCHEDULES_CLASS_FIELD_NAME.equalsIgnoreCase(fieldName)) {
 					oldValue = processValiditySchedulesClassFieldNameForTrxLog(oldPolicy.getValiditySchedules());
+				} else if (POLICY_PRIORITY_CLASS_FIELD_NAME.equalsIgnoreCase(fieldName)) {
+					oldValue = processPriorityClassFieldNameForTrxLog(oldPolicy.getPolicyPriority());
 				}
 				if (oldValue == null || oldValue.equalsIgnoreCase(value)) {
 					return null;
@@ -615,8 +621,15 @@ public class RangerPolicyService extends RangerPolicyServiceBase<XXPolicy,
Range
 		String ret = jsonUtil.readListToString(validitySchedules);
 		return ret;
 	}
-
-        @SuppressWarnings("unchecked")
+	@SuppressWarnings("unchecked")
+	private String processPriorityClassFieldNameForTrxLog(Object value) {
+		if (value == null) {
+			return "";
+		}
+		Integer policyPriority = (Integer) value;
+		return policyPriority.toString();
+	}
+	@SuppressWarnings("unchecked")
 	private String processDataMaskPolicyItemsForTrxLog(Object value) {
 		if(value == null) {
 			return "";


Mime
View raw message