ambari-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From rle...@apache.org
Subject ambari git commit: AMBARI-13976. Add permission label to to the dataset returned by the privilege resource provider (rlevas)
Date Thu, 19 Nov 2015 23:52:00 GMT
Repository: ambari
Updated Branches:
  refs/heads/trunk e8cc76e6e -> f3e5523c7


AMBARI-13976. Add permission label to to the dataset returned by the privilege resource provider
(rlevas)


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

Branch: refs/heads/trunk
Commit: f3e5523c7d2dc9d11cdf189ae3b2b347cacb7bed
Parents: e8cc76e
Author: Robert Levas <rlevas@hortonworks.com>
Authored: Thu Nov 19 18:51:52 2015 -0500
Committer: Robert Levas <rlevas@hortonworks.com>
Committed: Thu Nov 19 18:51:52 2015 -0500

----------------------------------------------------------------------
 .../internal/AmbariPrivilegeResourceProvider.java     |  1 +
 .../internal/ClusterPrivilegeResourceProvider.java    |  2 ++
 .../internal/PrivilegeResourceProvider.java           |  3 +++
 .../internal/UserPrivilegeResourceProvider.java       |  3 +++
 .../internal/ViewPrivilegeResourceProvider.java       |  1 +
 .../internal/AmbariPrivilegeResourceProviderTest.java | 14 +++++++++++---
 .../ClusterPrivilegeResourceProviderTest.java         |  2 ++
 .../internal/ViewPrivilegeResourceProviderTest.java   |  2 ++
 8 files changed, 25 insertions(+), 3 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ambari/blob/f3e5523c/ambari-server/src/main/java/org/apache/ambari/server/controller/internal/AmbariPrivilegeResourceProvider.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/java/org/apache/ambari/server/controller/internal/AmbariPrivilegeResourceProvider.java
b/ambari-server/src/main/java/org/apache/ambari/server/controller/internal/AmbariPrivilegeResourceProvider.java
index f4839e9..66d20b3 100644
--- a/ambari-server/src/main/java/org/apache/ambari/server/controller/internal/AmbariPrivilegeResourceProvider.java
+++ b/ambari-server/src/main/java/org/apache/ambari/server/controller/internal/AmbariPrivilegeResourceProvider.java
@@ -60,6 +60,7 @@ public class AmbariPrivilegeResourceProvider extends PrivilegeResourceProvider<O
   static {
     propertyIds.add(PRIVILEGE_ID_PROPERTY_ID);
     propertyIds.add(PERMISSION_NAME_PROPERTY_ID);
+    propertyIds.add(PERMISSION_LABEL_PROPERTY_ID);
     propertyIds.add(PRINCIPAL_NAME_PROPERTY_ID);
     propertyIds.add(PRINCIPAL_TYPE_PROPERTY_ID);
     propertyIds.add(PRIVILEGE_VIEW_NAME_PROPERTY_ID);

http://git-wip-us.apache.org/repos/asf/ambari/blob/f3e5523c/ambari-server/src/main/java/org/apache/ambari/server/controller/internal/ClusterPrivilegeResourceProvider.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/java/org/apache/ambari/server/controller/internal/ClusterPrivilegeResourceProvider.java
b/ambari-server/src/main/java/org/apache/ambari/server/controller/internal/ClusterPrivilegeResourceProvider.java
index b2d8018..bbcd4a1 100644
--- a/ambari-server/src/main/java/org/apache/ambari/server/controller/internal/ClusterPrivilegeResourceProvider.java
+++ b/ambari-server/src/main/java/org/apache/ambari/server/controller/internal/ClusterPrivilegeResourceProvider.java
@@ -59,6 +59,8 @@ public class ClusterPrivilegeResourceProvider extends PrivilegeResourceProvider<
     propertyIds.add(PRIVILEGE_CLUSTER_NAME_PROPERTY_ID);
     propertyIds.add(PRIVILEGE_ID_PROPERTY_ID);
     propertyIds.add(PERMISSION_NAME_PROPERTY_ID);
+    propertyIds.add(PERMISSION_NAME_PROPERTY_ID);
+    propertyIds.add(PERMISSION_LABEL_PROPERTY_ID);
     propertyIds.add(PRINCIPAL_NAME_PROPERTY_ID);
     propertyIds.add(PRINCIPAL_TYPE_PROPERTY_ID);
   }

http://git-wip-us.apache.org/repos/asf/ambari/blob/f3e5523c/ambari-server/src/main/java/org/apache/ambari/server/controller/internal/PrivilegeResourceProvider.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/java/org/apache/ambari/server/controller/internal/PrivilegeResourceProvider.java
b/ambari-server/src/main/java/org/apache/ambari/server/controller/internal/PrivilegeResourceProvider.java
index 154229a..88e9906 100644
--- a/ambari-server/src/main/java/org/apache/ambari/server/controller/internal/PrivilegeResourceProvider.java
+++ b/ambari-server/src/main/java/org/apache/ambari/server/controller/internal/PrivilegeResourceProvider.java
@@ -92,6 +92,7 @@ public abstract class PrivilegeResourceProvider<T> extends AbstractResourceProvi
    */
   public static final String PRIVILEGE_ID_PROPERTY_ID    = "PrivilegeInfo/privilege_id";
   public static final String PERMISSION_NAME_PROPERTY_ID = "PrivilegeInfo/permission_name";
+  public static final String PERMISSION_LABEL_PROPERTY_ID = "PrivilegeInfo/permission_label";
   public static final String PRINCIPAL_NAME_PROPERTY_ID  = "PrivilegeInfo/principal_name";
   public static final String PRINCIPAL_TYPE_PROPERTY_ID  = "PrivilegeInfo/principal_type";
 
@@ -295,6 +296,8 @@ public abstract class PrivilegeResourceProvider<T> extends AbstractResourceProvi
         privilegeEntity.getId(), requestedIds);
     setResourceProperty(resource, PERMISSION_NAME_PROPERTY_ID,
         privilegeEntity.getPermission().getPermissionName(), requestedIds);
+    setResourceProperty(resource, PERMISSION_LABEL_PROPERTY_ID,
+        privilegeEntity.getPermission().getPermissionLabel(), requestedIds);
 
     PrincipalEntity principal   = privilegeEntity.getPrincipal();
     Long            principalId = principal.getId();

http://git-wip-us.apache.org/repos/asf/ambari/blob/f3e5523c/ambari-server/src/main/java/org/apache/ambari/server/controller/internal/UserPrivilegeResourceProvider.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/java/org/apache/ambari/server/controller/internal/UserPrivilegeResourceProvider.java
b/ambari-server/src/main/java/org/apache/ambari/server/controller/internal/UserPrivilegeResourceProvider.java
index 0621286..5e0e4bd 100644
--- a/ambari-server/src/main/java/org/apache/ambari/server/controller/internal/UserPrivilegeResourceProvider.java
+++ b/ambari-server/src/main/java/org/apache/ambari/server/controller/internal/UserPrivilegeResourceProvider.java
@@ -51,6 +51,7 @@ public class UserPrivilegeResourceProvider extends ReadOnlyResourceProvider
{
 
   protected static final String PRIVILEGE_PRIVILEGE_ID_PROPERTY_ID    = PrivilegeResourceProvider.PRIVILEGE_ID_PROPERTY_ID;
   protected static final String PRIVILEGE_PERMISSION_NAME_PROPERTY_ID = PrivilegeResourceProvider.PERMISSION_NAME_PROPERTY_ID;
+  protected static final String PRIVILEGE_PERMISSION_LABEL_PROPERTY_ID = PrivilegeResourceProvider.PERMISSION_LABEL_PROPERTY_ID;
   protected static final String PRIVILEGE_PRINCIPAL_NAME_PROPERTY_ID  = PrivilegeResourceProvider.PRINCIPAL_NAME_PROPERTY_ID;
   protected static final String PRIVILEGE_PRINCIPAL_TYPE_PROPERTY_ID  = PrivilegeResourceProvider.PRINCIPAL_TYPE_PROPERTY_ID;
   protected static final String PRIVILEGE_VIEW_NAME_PROPERTY_ID       = ViewPrivilegeResourceProvider.PRIVILEGE_VIEW_NAME_PROPERTY_ID;
@@ -87,6 +88,7 @@ public class UserPrivilegeResourceProvider extends ReadOnlyResourceProvider
{
   static {
     propertyIds.add(PRIVILEGE_PRIVILEGE_ID_PROPERTY_ID);
     propertyIds.add(PRIVILEGE_PERMISSION_NAME_PROPERTY_ID);
+    propertyIds.add(PRIVILEGE_PERMISSION_LABEL_PROPERTY_ID);
     propertyIds.add(PRIVILEGE_PRINCIPAL_NAME_PROPERTY_ID);
     propertyIds.add(PRIVILEGE_PRINCIPAL_TYPE_PROPERTY_ID);
     propertyIds.add(PRIVILEGE_VIEW_NAME_PROPERTY_ID);
@@ -177,6 +179,7 @@ public class UserPrivilegeResourceProvider extends ReadOnlyResourceProvider
{
           setResourceProperty(resource, PRIVILEGE_USER_NAME_PROPERTY_ID, userName, requestedIds);
           setResourceProperty(resource, PRIVILEGE_PRIVILEGE_ID_PROPERTY_ID, privilegeEntity.getId(),
requestedIds);
           setResourceProperty(resource, PRIVILEGE_PERMISSION_NAME_PROPERTY_ID, privilegeEntity.getPermission().getPermissionName(),
requestedIds);
+          setResourceProperty(resource, PRIVILEGE_PERMISSION_LABEL_PROPERTY_ID, privilegeEntity.getPermission().getPermissionLabel(),
requestedIds);
           setResourceProperty(resource, PRIVILEGE_PRINCIPAL_TYPE_PROPERTY_ID, privilegeEntity.getPrincipal().getPrincipalType().getName(),
requestedIds);
 
           final String principalTypeName = privilegeEntity.getPrincipal().getPrincipalType().getName();

http://git-wip-us.apache.org/repos/asf/ambari/blob/f3e5523c/ambari-server/src/main/java/org/apache/ambari/server/controller/internal/ViewPrivilegeResourceProvider.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/java/org/apache/ambari/server/controller/internal/ViewPrivilegeResourceProvider.java
b/ambari-server/src/main/java/org/apache/ambari/server/controller/internal/ViewPrivilegeResourceProvider.java
index 090805e..408a747 100644
--- a/ambari-server/src/main/java/org/apache/ambari/server/controller/internal/ViewPrivilegeResourceProvider.java
+++ b/ambari-server/src/main/java/org/apache/ambari/server/controller/internal/ViewPrivilegeResourceProvider.java
@@ -58,6 +58,7 @@ public class ViewPrivilegeResourceProvider extends PrivilegeResourceProvider<Vie
     propertyIds.add(PRIVILEGE_INSTANCE_NAME_PROPERTY_ID);
     propertyIds.add(PRIVILEGE_ID_PROPERTY_ID);
     propertyIds.add(PERMISSION_NAME_PROPERTY_ID);
+    propertyIds.add(PERMISSION_LABEL_PROPERTY_ID);
     propertyIds.add(PRINCIPAL_NAME_PROPERTY_ID);
     propertyIds.add(PRINCIPAL_TYPE_PROPERTY_ID);
   }

http://git-wip-us.apache.org/repos/asf/ambari/blob/f3e5523c/ambari-server/src/test/java/org/apache/ambari/server/controller/internal/AmbariPrivilegeResourceProviderTest.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/test/java/org/apache/ambari/server/controller/internal/AmbariPrivilegeResourceProviderTest.java
b/ambari-server/src/test/java/org/apache/ambari/server/controller/internal/AmbariPrivilegeResourceProviderTest.java
index 6286aea..4c35d53 100644
--- a/ambari-server/src/test/java/org/apache/ambari/server/controller/internal/AmbariPrivilegeResourceProviderTest.java
+++ b/ambari-server/src/test/java/org/apache/ambari/server/controller/internal/AmbariPrivilegeResourceProviderTest.java
@@ -134,6 +134,7 @@ public class AmbariPrivilegeResourceProviderTest {
     expect(userEntity.getPrincipal()).andReturn(principalEntity).anyTimes();
     expect(userEntity.getUserName()).andReturn("joe").anyTimes();
     expect(permissionEntity.getPermissionName()).andReturn("AMBARI.ADMINISTRATOR").anyTimes();
+    expect(permissionEntity.getPermissionLabel()).andReturn("Administrator").anyTimes();
     expect(principalEntity.getPrincipalType()).andReturn(principalTypeEntity).anyTimes();
     expect(principalTypeEntity.getName()).andReturn("USER").anyTimes();
 
@@ -153,6 +154,7 @@ public class AmbariPrivilegeResourceProviderTest {
     Resource resource = resources.iterator().next();
 
     Assert.assertEquals("AMBARI.ADMINISTRATOR", resource.getPropertyValue(AmbariPrivilegeResourceProvider.PERMISSION_NAME_PROPERTY_ID));
+    Assert.assertEquals("Administrator", resource.getPropertyValue(AmbariPrivilegeResourceProvider.PERMISSION_LABEL_PROPERTY_ID));
     Assert.assertEquals("joe", resource.getPropertyValue(AmbariPrivilegeResourceProvider.PRINCIPAL_NAME_PROPERTY_ID));
     Assert.assertEquals("USER", resource.getPropertyValue(AmbariPrivilegeResourceProvider.PRINCIPAL_TYPE_PROPERTY_ID));
 
@@ -180,6 +182,7 @@ public class AmbariPrivilegeResourceProviderTest {
     expect(ambariUserEntity.getPrincipal()).andReturn(ambariPrincipalEntity).anyTimes();
     expect(ambariUserEntity.getUserName()).andReturn("joe").anyTimes();
     expect(ambariPermissionEntity.getPermissionName()).andReturn("AMBARI.ADMINISTRATOR").anyTimes();
+    expect(ambariPermissionEntity.getPermissionLabel()).andReturn("Administrator").anyTimes();
     expect(ambariPrincipalEntity.getPrincipalType()).andReturn(ambariPrincipalTypeEntity).anyTimes();
     expect(ambariPrincipalTypeEntity.getName()).andReturn("USER").anyTimes();
 
@@ -209,6 +212,7 @@ public class AmbariPrivilegeResourceProviderTest {
     expect(viewUserEntity.getPrincipal()).andReturn(viewPrincipalEntity).anyTimes();
     expect(viewUserEntity.getUserName()).andReturn("bob").anyTimes();
     expect(viewPermissionEntity.getPermissionName()).andReturn("VIEW.USER").anyTimes();
+    expect(viewPermissionEntity.getPermissionLabel()).andReturn("View User").anyTimes();
     expect(viewPrincipalEntity.getPrincipalType()).andReturn(viewPrincipalTypeEntity).anyTimes();
     expect(viewPrincipalTypeEntity.getName()).andReturn("USER").anyTimes();
 
@@ -231,6 +235,7 @@ public class AmbariPrivilegeResourceProviderTest {
     expect(clusterUserEntity.getPrincipal()).andReturn(clusterPrincipalEntity).anyTimes();
     expect(clusterUserEntity.getUserName()).andReturn("jeff").anyTimes();
     expect(clusterPermissionEntity.getPermissionName()).andReturn("CLUSTER.USER").anyTimes();
+    expect(clusterPermissionEntity.getPermissionLabel()).andReturn("Cluster User").anyTimes();
     expect(clusterPrincipalEntity.getPrincipalType()).andReturn(clusterPrincipalTypeEntity).anyTimes();
     expect(clusterPrincipalTypeEntity.getName()).andReturn("USER").anyTimes();
     expect(clusterEntity.getResource()).andReturn(clusterResourceEntity).anyTimes();
@@ -274,8 +279,9 @@ public class AmbariPrivilegeResourceProviderTest {
 
     Resource resource1 = resourceMap.get(31);
 
-    Assert.assertEquals(5, resource1.getPropertiesMap().get("PrivilegeInfo").size());
+    Assert.assertEquals(6, resource1.getPropertiesMap().get("PrivilegeInfo").size());
     Assert.assertEquals("AMBARI.ADMINISTRATOR", resource1.getPropertyValue(AmbariPrivilegeResourceProvider.PERMISSION_NAME_PROPERTY_ID));
+    Assert.assertEquals("Administrator", resource1.getPropertyValue(AmbariPrivilegeResourceProvider.PERMISSION_LABEL_PROPERTY_ID));
     Assert.assertEquals("joe", resource1.getPropertyValue(AmbariPrivilegeResourceProvider.PRINCIPAL_NAME_PROPERTY_ID));
     Assert.assertEquals("USER", resource1.getPropertyValue(AmbariPrivilegeResourceProvider.PRINCIPAL_TYPE_PROPERTY_ID));
     Assert.assertEquals(31, resource1.getPropertyValue(AmbariPrivilegeResourceProvider.PRIVILEGE_ID_PROPERTY_ID));
@@ -283,8 +289,9 @@ public class AmbariPrivilegeResourceProviderTest {
 
     Resource resource2 = resourceMap.get(32);
 
-    Assert.assertEquals(6, resource2.getPropertiesMap().get("PrivilegeInfo").size());
+    Assert.assertEquals(7, resource2.getPropertiesMap().get("PrivilegeInfo").size());
     Assert.assertEquals("CLUSTER.USER", resource2.getPropertyValue(AmbariPrivilegeResourceProvider.PERMISSION_NAME_PROPERTY_ID));
+    Assert.assertEquals("Cluster User", resource2.getPropertyValue(AmbariPrivilegeResourceProvider.PERMISSION_LABEL_PROPERTY_ID));
     Assert.assertEquals("jeff", resource2.getPropertyValue(AmbariPrivilegeResourceProvider.PRINCIPAL_NAME_PROPERTY_ID));
     Assert.assertEquals("USER", resource2.getPropertyValue(AmbariPrivilegeResourceProvider.PRINCIPAL_TYPE_PROPERTY_ID));
     Assert.assertEquals(32, resource2.getPropertyValue(AmbariPrivilegeResourceProvider.PRIVILEGE_ID_PROPERTY_ID));
@@ -293,8 +300,9 @@ public class AmbariPrivilegeResourceProviderTest {
 
     Resource resource3 = resourceMap.get(33);
 
-    Assert.assertEquals(8, resource3.getPropertiesMap().get("PrivilegeInfo").size());
+    Assert.assertEquals(9, resource3.getPropertiesMap().get("PrivilegeInfo").size());
     Assert.assertEquals("VIEW.USER", resource3.getPropertyValue(AmbariPrivilegeResourceProvider.PERMISSION_NAME_PROPERTY_ID));
+    Assert.assertEquals("View User", resource3.getPropertyValue(AmbariPrivilegeResourceProvider.PERMISSION_LABEL_PROPERTY_ID));
     Assert.assertEquals("bob", resource3.getPropertyValue(AmbariPrivilegeResourceProvider.PRINCIPAL_NAME_PROPERTY_ID));
     Assert.assertEquals("USER", resource3.getPropertyValue(AmbariPrivilegeResourceProvider.PRINCIPAL_TYPE_PROPERTY_ID));
     Assert.assertEquals(33, resource3.getPropertyValue(AmbariPrivilegeResourceProvider.PRIVILEGE_ID_PROPERTY_ID));

http://git-wip-us.apache.org/repos/asf/ambari/blob/f3e5523c/ambari-server/src/test/java/org/apache/ambari/server/controller/internal/ClusterPrivilegeResourceProviderTest.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/test/java/org/apache/ambari/server/controller/internal/ClusterPrivilegeResourceProviderTest.java
b/ambari-server/src/test/java/org/apache/ambari/server/controller/internal/ClusterPrivilegeResourceProviderTest.java
index 62ff60d..1412470 100644
--- a/ambari-server/src/test/java/org/apache/ambari/server/controller/internal/ClusterPrivilegeResourceProviderTest.java
+++ b/ambari-server/src/test/java/org/apache/ambari/server/controller/internal/ClusterPrivilegeResourceProviderTest.java
@@ -106,6 +106,7 @@ public class ClusterPrivilegeResourceProviderTest {
     expect(userEntity.getPrincipal()).andReturn(principalEntity).anyTimes();
     expect(userEntity.getUserName()).andReturn("joe").anyTimes();
     expect(permissionEntity.getPermissionName()).andReturn("CLUSTER.ADMINISTRATOR").anyTimes();
+    expect(permissionEntity.getPermissionLabel()).andReturn("Cluster Administrator").anyTimes();
     expect(principalEntity.getPrincipalType()).andReturn(principalTypeEntity).anyTimes();
     expect(principalTypeEntity.getName()).andReturn("USER").anyTimes();
     expect(clusterEntity.getResource()).andReturn(resourceEntity);
@@ -132,6 +133,7 @@ public class ClusterPrivilegeResourceProviderTest {
     Resource resource = resources.iterator().next();
 
     Assert.assertEquals("CLUSTER.ADMINISTRATOR", resource.getPropertyValue(AmbariPrivilegeResourceProvider.PERMISSION_NAME_PROPERTY_ID));
+    Assert.assertEquals("Cluster Administrator", resource.getPropertyValue(AmbariPrivilegeResourceProvider.PERMISSION_LABEL_PROPERTY_ID));
     Assert.assertEquals("joe", resource.getPropertyValue(AmbariPrivilegeResourceProvider.PRINCIPAL_NAME_PROPERTY_ID));
     Assert.assertEquals("USER", resource.getPropertyValue(AmbariPrivilegeResourceProvider.PRINCIPAL_TYPE_PROPERTY_ID));
 

http://git-wip-us.apache.org/repos/asf/ambari/blob/f3e5523c/ambari-server/src/test/java/org/apache/ambari/server/controller/internal/ViewPrivilegeResourceProviderTest.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/test/java/org/apache/ambari/server/controller/internal/ViewPrivilegeResourceProviderTest.java
b/ambari-server/src/test/java/org/apache/ambari/server/controller/internal/ViewPrivilegeResourceProviderTest.java
index c156a38..8400efd 100644
--- a/ambari-server/src/test/java/org/apache/ambari/server/controller/internal/ViewPrivilegeResourceProviderTest.java
+++ b/ambari-server/src/test/java/org/apache/ambari/server/controller/internal/ViewPrivilegeResourceProviderTest.java
@@ -137,6 +137,7 @@ public class ViewPrivilegeResourceProviderTest {
     expect(userEntity.getPrincipal()).andReturn(principalEntity).anyTimes();
     expect(userEntity.getUserName()).andReturn("joe").anyTimes();
     expect(permissionEntity.getPermissionName()).andReturn("VIEW.USER").anyTimes();
+    expect(permissionEntity.getPermissionLabel()).andReturn("View User").anyTimes();
     expect(principalEntity.getPrincipalType()).andReturn(principalTypeEntity).anyTimes();
     expect(principalTypeEntity.getName()).andReturn("USER").anyTimes();
 
@@ -156,6 +157,7 @@ public class ViewPrivilegeResourceProviderTest {
     Resource resource = resources.iterator().next();
 
     Assert.assertEquals("VIEW.USER", resource.getPropertyValue(AmbariPrivilegeResourceProvider.PERMISSION_NAME_PROPERTY_ID));
+    Assert.assertEquals("View User", resource.getPropertyValue(AmbariPrivilegeResourceProvider.PERMISSION_LABEL_PROPERTY_ID));
     Assert.assertEquals("joe", resource.getPropertyValue(AmbariPrivilegeResourceProvider.PRINCIPAL_NAME_PROPERTY_ID));
     Assert.assertEquals("USER", resource.getPropertyValue(AmbariPrivilegeResourceProvider.PRINCIPAL_TYPE_PROPERTY_ID));
 


Mime
View raw message