Package org.exoplatform.services.organization

Examples of org.exoplatform.services.organization.Group


      List<Membership> memberships = new LinkedList<Membership>();

      for (Role role : roles)
      {
         MembershipImpl m = new MembershipImpl();
         Group g = ((GroupDAOImpl)orgService.getGroupHandler()).convertGroup(role.getGroup());
         m.setGroupId(g.getId());
         m.setUserName(role.getUser().getId());
         m.setMembershipType(role.getRoleType().getName());
         memberships.add(m);
      }
View Full Code Here


   /**
    * Find group by id.
    */
   public void testFindGroupById() throws Exception
   {
      Group g = gHandler.findGroupById("/platform/administrators");
      assertNotNull(g);
      assertEquals(g.getDescription(), "the /platform/administrators group");
      assertEquals(g.getGroupName(), "administrators");
      assertEquals(g.getId(), "/platform/administrators");
      assertEquals(g.getLabel(), "Administrators");
      assertEquals(g.getParentId(), "/platform");

      // try to find not existed group. We are supposed to get "null" instead of Exception
      try
      {
         assertNull(gHandler.findGroupById("/not-existed-group"));
View Full Code Here

      catch (Exception e)
      {
      }

      gHandler.removeGroup(gHandler.findGroupById("/organization/group1/group2"), true);
      Group group = gHandler.removeGroup(gHandler.findGroupById("/organization/group1"), true);

      assertNull(gHandler.findGroupById("/organization/group1"));
      assertNull(gHandler.findGroupById("/organization/group1/group2"));

      gHandler.removeGroup(gHandler.findGroupById("/" + groupName2), true);
View Full Code Here

   /**
    * Add child.
    */
   public void testAddChild() throws Exception
   {
      Group parent = createGroupInstance(null, groupName1, "lable", "desc");
      Group child = createGroupInstance(null, groupName2, "lable", "desc");

      // try to add child to not existed parent group
      try
      {
         gHandler.addChild(parent, child, false);
View Full Code Here

   /**
    * Create group.
    */
   public void testCreateGroup() throws Exception
   {
      Group group = gHandler.createGroupInstance();
      group.setGroupName(groupName1);
      group.setLabel("label");
      gHandler.createGroup(group, true);

      assertNotNull(gHandler.findGroupById("/" + groupName1));
   }
View Full Code Here

   public void testSaveGroup() throws Exception
   {
      createGroup(null, groupName1, "label", "desc");

      // set new description
      Group g = gHandler.findGroupById("/" + groupName1);
      g.setDescription("newDesc");
      gHandler.saveGroup(g, true);

      // check if group has new description
      g = gHandler.findGroupById("/" + groupName1);
      assertEquals(g.getDescription(), "newDesc");
   }
View Full Code Here

   /**
    * Create new group.
    */
   protected void createGroup(String parentId, String name, String label, String desc) throws Exception
   {
      Group parent = parentId == null ? null : gHandler.findGroupById(parentId);

      Group child = gHandler.createGroupInstance();
      child.setGroupName(name);
      child.setLabel(label);
      child.setDescription(desc);
      gHandler.addChild(parent, child, true);
     
      groups.add((parent == null ? "" : parentId) + "/" + name);
   }
View Full Code Here

      super.tearDown();
   }

   private void removeGroups(String parentIdthrows Exception
   {
      Group group = gHandler.findGroupById(parentId);
      if (group != null)
      {

         Collection<Group> childs = gHandler.findGroups(group);
         for (Group child : childs)
View Full Code Here

   /**
    * Find membership by group.
    */
   public void testFindMembershipsByGroup() throws Exception
   {
      Group g = gHandler.findGroupById("/platform/users");
      assertEquals(mHandler.findMembershipsByGroup(g).size(), 4);

      // try to find for non-existing group
      g = gHandler.createGroupInstance();
      g.setGroupName(groupName1);
      g.setLabel("label");
      gHandler.addChild(null, g, false);
      assertEquals(g.getId(), gHandler.findGroupById("/" + groupName1).getId());
      g = gHandler.removeGroup(g, false);
      assertEquals(mHandler.findMembershipsByGroup(g).size(), 0);

   }
View Full Code Here

   /**
    * Find membership by group.
    */
   public void testFindAllMembershipsByGroup() throws Exception
   {
      Group g = gHandler.findGroupById("/platform/users");
      ListAccess<Membership> memberships = mHandler.findAllMembershipsByGroup(g);
      assertEquals(memberships.getSize(), 4);

      try
      {
         Membership[] m = memberships.load(0, 4);
         assertEquals(4, m.length);
      }
      catch (Exception e)
      {
         fail("Exception should not be thrown");
      }

      try
      {
         Membership[] m = memberships.load(1, 2);
         assertEquals(2, m.length);
      }
      catch (Exception e)
      {
         fail("Exception should not be thrown");
      }

      try
      {
         Membership[] m = memberships.load(1, 4);
         fail("Exception should be thrown");
      }
      catch (Exception e)
      {
      }

      // try to find for non-existing group
      g = gHandler.createGroupInstance();
      g.setGroupName(groupName1);
      g.setLabel("label");
      gHandler.addChild(null, g, false);
      assertEquals(g.getId(), gHandler.findGroupById("/" + groupName1).getId());
      g = gHandler.removeGroup(g, false);
      assertEquals(mHandler.findMembershipsByGroup(g).size(), 0);

   }
View Full Code Here

TOP

Related Classes of org.exoplatform.services.organization.Group

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.