Ejemplo n.º 1
0
  // See BZ: 191007
  public void testCreateWithCustomGroups() throws Exception {
    Server s =
        ServerFactoryTest.createTestServer(
            user, true, ServerConstants.getServerGroupTypeEnterpriseEntitled());
    ServerGroup testGroup = ServerGroupTestUtils.createManaged(user);
    s.getManagedGroups().add((ManagedServerGroup) testGroup);

    // Three, one for the server entitlement, one for the user permission to the
    // server, one as the testGroup.
    assertEquals(1, s.getManagedGroups().size());
    ActivationKey key = createTestActivationKey(user, s);
    assertNotNull(key);
    key = (ActivationKey) reload(key);
    assertNotNull(key.getId());
  }
Ejemplo n.º 2
0
  /** {@inheritDoc} */
  public DataResult<ManagedServerGroup> getResult(RequestContext context) {

    Server server = context.lookupAndBindServer();
    ServerGroupManager manager = ServerGroupManager.getInstance();
    List<ManagedServerGroup> serverGroups = server.getManagedGroups();
    List<ManagedServerGroup> all = context.getCurrentUser().getOrg().getManagedServerGroups();
    List<ManagedServerGroup> ret = new LinkedList<ManagedServerGroup>();
    for (ManagedServerGroup group : all) {
      if (!serverGroups.contains(group) && manager.canAccess(context.getCurrentUser(), group)) {
        ret.add(group);
      }
    }
    return new DataResult<ManagedServerGroup>(ret);
  }