Repository: ambari
Updated Branches:
  refs/heads/trunk a15e75c1f -> fcbde3243


AMBARI-11183 - Views : cannot load permission error when accessing the ambari 
view (tbeerbower)


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

Branch: refs/heads/trunk
Commit: fcbde3243792a49a269ded9fd8d64638d71a0b5e
Parents: a15e75c
Author: tbeerbower <[email protected]>
Authored: Sat May 16 15:26:15 2015 -0400
Committer: tbeerbower <[email protected]>
Committed: Sat May 16 15:26:42 2015 -0400

----------------------------------------------------------------------
 .../server/orm/entities/ResourceEntity.java     | 26 ++++++++++++++++++++
 .../server/orm/entities/ResourceEntityTest.java | 15 +++++++++++
 2 files changed, 41 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ambari/blob/fcbde324/ambari-server/src/main/java/org/apache/ambari/server/orm/entities/ResourceEntity.java
----------------------------------------------------------------------
diff --git 
a/ambari-server/src/main/java/org/apache/ambari/server/orm/entities/ResourceEntity.java
 
b/ambari-server/src/main/java/org/apache/ambari/server/orm/entities/ResourceEntity.java
index 04dbd76..56a86b7 100644
--- 
a/ambari-server/src/main/java/org/apache/ambari/server/orm/entities/ResourceEntity.java
+++ 
b/ambari-server/src/main/java/org/apache/ambari/server/orm/entities/ResourceEntity.java
@@ -19,6 +19,8 @@
 package org.apache.ambari.server.orm.entities;
 
 import javax.persistence.*;
+import java.util.Collection;
+import java.util.HashSet;
 
 /**
  * Represents a resource.
@@ -51,6 +53,12 @@ public class ResourceEntity {
   })
   private ResourceTypeEntity resourceType;
 
+  /**
+   * The list of privileges.
+   */
+  @OneToMany(cascade = CascadeType.ALL, mappedBy = "resource")
+  private Collection<PrivilegeEntity> privileges = new 
HashSet<PrivilegeEntity>();
+
 
   // ----- ResourceEntity ---------------------------------------------------
 
@@ -90,6 +98,24 @@ public class ResourceEntity {
     this.resourceType = resourceType;
   }
 
+  /**
+   * Get the associated privileges.
+   *
+   * @return the privileges
+   */
+  public Collection<PrivilegeEntity> getPrivileges() {
+    return privileges;
+  }
+
+  /**
+   * Set the associated privileges.
+   *
+   * @param privileges the privileges
+   */
+  public void setPrivileges(Collection<PrivilegeEntity> privileges) {
+    this.privileges = privileges;
+  }
+
 
   // ----- Object overrides --------------------------------------------------
 

http://git-wip-us.apache.org/repos/asf/ambari/blob/fcbde324/ambari-server/src/test/java/org/apache/ambari/server/orm/entities/ResourceEntityTest.java
----------------------------------------------------------------------
diff --git 
a/ambari-server/src/test/java/org/apache/ambari/server/orm/entities/ResourceEntityTest.java
 
b/ambari-server/src/test/java/org/apache/ambari/server/orm/entities/ResourceEntityTest.java
index 35724d3..358d957 100644
--- 
a/ambari-server/src/test/java/org/apache/ambari/server/orm/entities/ResourceEntityTest.java
+++ 
b/ambari-server/src/test/java/org/apache/ambari/server/orm/entities/ResourceEntityTest.java
@@ -21,6 +21,9 @@ package org.apache.ambari.server.orm.entities;
 import org.junit.Assert;
 import org.junit.Test;
 
+import java.util.Collection;
+import java.util.Collections;
+
 /**
  * ResourceEntity tests.
  */
@@ -44,4 +47,16 @@ public class ResourceEntityTest {
     entity.setResourceType(typeEntity);
     Assert.assertEquals(typeEntity, entity.getResourceType());
   }
+
+  @Test
+  public void testSetGetPrivileges() throws Exception {
+    ResourceEntity entity = new ResourceEntity();
+    PrivilegeEntity privilegeEntity = new PrivilegeEntity();
+    Collection<PrivilegeEntity> privileges = 
Collections.singleton(privilegeEntity);
+
+    Assert.assertNull(entity.getResourceType());
+
+    entity.setPrivileges(privileges);
+    Assert.assertEquals(privileges, entity.getPrivileges());
+  }
 }

Reply via email to