ranger-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mad...@apache.org
Subject [10/16] incubator-ranger git commit: RANGER-485: Provide user friendly text for HTTP response code in Audit->Plugins
Date Mon, 18 May 2015 04:53:08 GMT
RANGER-485: Provide user friendly text for HTTP response code in Audit->Plugins

Signed-off-by: sneethiraj <sneethir@apache.org>


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

Branch: refs/heads/tag-policy
Commit: 82743e2a49de5cd7a25f226a285c65be79bdc215
Parents: 5b98513
Author: Velmurugan Periasamy <vel@apache.org>
Authored: Sun May 17 17:23:20 2015 -0400
Committer: sneethiraj <sneethir@apache.org>
Committed: Sun May 17 17:55:16 2015 -0400

----------------------------------------------------------------------
 .../java/org/apache/ranger/common/MapUtil.java  | 58 ++++++++++++++++++++
 .../service/XPolicyExportAuditServiceBase.java  |  2 +
 .../apache/ranger/view/VXPolicyExportAudit.java | 12 ++++
 .../webapp/scripts/views/reports/AuditLayout.js |  8 ++-
 4 files changed, 79 insertions(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-ranger/blob/82743e2a/security-admin/src/main/java/org/apache/ranger/common/MapUtil.java
----------------------------------------------------------------------
diff --git a/security-admin/src/main/java/org/apache/ranger/common/MapUtil.java b/security-admin/src/main/java/org/apache/ranger/common/MapUtil.java
new file mode 100644
index 0000000..3520450
--- /dev/null
+++ b/security-admin/src/main/java/org/apache/ranger/common/MapUtil.java
@@ -0,0 +1,58 @@
+/*
+ * 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.ranger.common;
+
+import java.io.Serializable;
+import java.util.HashMap;
+import java.util.Map;
+
+import org.springframework.context.annotation.Scope;
+import org.springframework.stereotype.Service;
+
+@Service
+@Scope("singleton")
+public class MapUtil implements Serializable{
+    static Map<Integer, String> policyExportAuditSyncStatusMessageMap=new HashMap<Integer,
String>();
+
+    public static void init() {
+    	policyExportAuditSyncStatusMessageMap=new HashMap<Integer, String>();
+    	policyExportAuditSyncStatusMessageMap.put(new Integer(200), "Policies synced to plugin");
+    	policyExportAuditSyncStatusMessageMap.put(new Integer(202), "Error syncing policies");
+    	policyExportAuditSyncStatusMessageMap.put(new Integer(400), "Error syncing policies");
+    	policyExportAuditSyncStatusMessageMap.put(new Integer(401), "Bad Credentials");
+    	policyExportAuditSyncStatusMessageMap.put(new Integer(403), "Error syncing policies");
+    	policyExportAuditSyncStatusMessageMap.put(new Integer(404), "Error syncing policies");
+    	policyExportAuditSyncStatusMessageMap.put(new Integer(500), "Error syncing policies");
+    }
+
+    public static String getPolicyExportAuditSyncStatus(int key) {
+    	String status="";
+    	if(policyExportAuditSyncStatusMessageMap==null || policyExportAuditSyncStatusMessageMap.size()==0){
+    		init();
+    	}
+    	if(policyExportAuditSyncStatusMessageMap!=null && policyExportAuditSyncStatusMessageMap.containsKey(key)){
+    		status=policyExportAuditSyncStatusMessageMap.get(key);
+    	}
+    	return status;
+    }
+}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/incubator-ranger/blob/82743e2a/security-admin/src/main/java/org/apache/ranger/service/XPolicyExportAuditServiceBase.java
----------------------------------------------------------------------
diff --git a/security-admin/src/main/java/org/apache/ranger/service/XPolicyExportAuditServiceBase.java
b/security-admin/src/main/java/org/apache/ranger/service/XPolicyExportAuditServiceBase.java
index af58706..e8b0c50 100644
--- a/security-admin/src/main/java/org/apache/ranger/service/XPolicyExportAuditServiceBase.java
+++ b/security-admin/src/main/java/org/apache/ranger/service/XPolicyExportAuditServiceBase.java
@@ -26,6 +26,7 @@
 import java.util.ArrayList;
 import java.util.List;
 
+import org.apache.ranger.common.MapUtil;
 import org.apache.ranger.common.SearchCriteria;
 import org.apache.ranger.entity.XXPolicyExportAudit;
 import org.apache.ranger.view.VXPolicyExportAudit;
@@ -62,6 +63,7 @@ public abstract class XPolicyExportAuditServiceBase<T extends XXPolicyExportAudi
 		vObj.setRepositoryName( mObj.getRepositoryName());
 		vObj.setExportedJson( mObj.getExportedJson());
 		vObj.setHttpRetCode( mObj.getHttpRetCode());
+		vObj.setSyncStatus( MapUtil.getPolicyExportAuditSyncStatus(mObj.getHttpRetCode()));
 		return vObj;
 	}
 

http://git-wip-us.apache.org/repos/asf/incubator-ranger/blob/82743e2a/security-admin/src/main/java/org/apache/ranger/view/VXPolicyExportAudit.java
----------------------------------------------------------------------
diff --git a/security-admin/src/main/java/org/apache/ranger/view/VXPolicyExportAudit.java
b/security-admin/src/main/java/org/apache/ranger/view/VXPolicyExportAudit.java
index 9ac3fa1..6e34754 100644
--- a/security-admin/src/main/java/org/apache/ranger/view/VXPolicyExportAudit.java
+++ b/security-admin/src/main/java/org/apache/ranger/view/VXPolicyExportAudit.java
@@ -73,6 +73,8 @@ public class VXPolicyExportAudit extends VXDataObject implements java.io.Seriali
 	 */
 	protected int httpRetCode;
 
+	protected String syncStatus;
+
 	/**
 	 * Default constructor. This will set all the attributes to default value.
 	 */
@@ -198,6 +200,15 @@ public class VXPolicyExportAudit extends VXDataObject implements java.io.Seriali
 		return this.httpRetCode;
 	}
 
+	
+	public String getSyncStatus() {
+		return syncStatus;
+	}
+
+	public void setSyncStatus(String syncStatus) {
+		this.syncStatus = syncStatus;
+	}
+
 	@Override
 	public int getMyClassType( ) {
 	    return AppConstants.CLASS_TYPE_XA_POLICY_EXPORT_AUDIT;
@@ -217,6 +228,7 @@ public class VXPolicyExportAudit extends VXDataObject implements java.io.Seriali
 		str += "repositoryName={" + repositoryName + "} ";
 		str += "exportedJson={" + exportedJson + "} ";
 		str += "httpRetCode={" + httpRetCode + "} ";
+		str += "syncStatus={" + syncStatus + "} ";
 		str += "}";
 		return str;
 	}

http://git-wip-us.apache.org/repos/asf/incubator-ranger/blob/82743e2a/security-admin/src/main/webapp/scripts/views/reports/AuditLayout.js
----------------------------------------------------------------------
diff --git a/security-admin/src/main/webapp/scripts/views/reports/AuditLayout.js b/security-admin/src/main/webapp/scripts/views/reports/AuditLayout.js
index a41c4c5..25d6d7e 100644
--- a/security-admin/src/main/webapp/scripts/views/reports/AuditLayout.js
+++ b/security-admin/src/main/webapp/scripts/views/reports/AuditLayout.js
@@ -1110,7 +1110,13 @@ define(function(require) {
 								return html;
 							}
 						})
-					}
+					},
+					syncStatus : {
+						cell : 'string',
+						label	: 'Status',
+						editable:false,
+						sortable:false
+					},
 			};
 			return this.policyExportAuditList.constructor.getTableCols(cols, this.policyExportAuditList);
 		},


Mime
View raw message