public static void getVcenterTenantOptions(String id) {
    List<TenantOrgRestRep> vCenterTenantOptions = new ArrayList<TenantOrgRestRep>();
    if (StringUtils.isBlank(id) || id.equalsIgnoreCase("null")) {
      renderJSON(vCenterTenantOptions);
      return;
    }

    List<ACLEntry> vcenterAcls = VCenterUtils.getAcl(uri(id));
    if (CollectionUtils.isEmpty(vcenterAcls)) {
      renderJSON(vCenterTenantOptions);
      return;
    }

    addNoneTenantOption(id, vCenterTenantOptions);

    Iterator<ACLEntry> aclEntryIterator = vcenterAcls.iterator();
    while (aclEntryIterator.hasNext()) {
      ACLEntry aclEntry = aclEntryIterator.next();
      if (aclEntry == null) {
        continue;
      }

      TenantOrgRestRep tenantOrgRestRep = TenantUtils.getTenant(aclEntry.getTenant());
      if (tenantOrgRestRep != null) {
        vCenterTenantOptions.add(tenantOrgRestRep);
      }
    }
    renderJSON(vCenterTenantOptions);
  }
 public static void itemDetails(String id) {
   VcenterRestRep vcenter = VCenterUtils.getVCenter(uri(id));
   List<VcenterDataCenterRestRep> dataCenters =
       VCenterUtils.getDataCentersInVCenter(
           vcenter, TenantUtils.getTenantFilter(Models.currentAdminTenantForVcenter()));
   render(vcenter, dataCenters);
 }
 public static void listJson() {
   URI tenantId = TenantUtils.getTenantFilter(Models.currentAdminTenantForVcenter());
   List<VcenterRestRep> vcenters = VCenterUtils.getVCenters(tenantId);
   List<VCenterInfo> vcenterInfos = Lists.newArrayList();
   for (VcenterRestRep vcenter : vcenters) {
     vcenterInfos.add(new VCenterInfo(vcenter));
   }
   renderJSON(DataTablesSupport.createJSON(vcenterInfos, params));
 }
  private static void renderTenantOptions() {
    if (TenantUtils.canReadAllTenantsForVcenters() && VCenterUtils.canUpdateACLs()) {
      List<StringOption> tenantOptions = dataObjectOptions(await(new TenantsCall().asPromise()));
      renderArgs.put("tenantOptions", tenantOptions);

      List<StringOption> tenantOptionsWithNone = new ArrayList<StringOption>();

      tenantOptionsWithNone.add(
          new StringOption(NullColumnValueGetter.getNullStr().toString(), "None"));
      tenantOptionsWithNone.addAll(tenantOptions);
      renderArgs.put("tenantOptionsWithNone", tenantOptionsWithNone);
    }
  }
 public void setTenantsForCreation() {
   this.tenants = new HashSet<String>();
   if (StringUtils.isNotBlank(Models.currentAdminTenantForVcenter())
       && Models.currentAdminTenantForVcenter()
           .equalsIgnoreCase(TenantUtils.getNoTenantSelector())) {
     List<TenantOrgRestRep> allTenants = TenantUtils.getAllTenants();
     Iterator<TenantOrgRestRep> tenantsIterator = allTenants.iterator();
     while (tenantsIterator.hasNext()) {
       TenantOrgRestRep tenant = tenantsIterator.next();
       if (tenant == null) {
         continue;
       }
       this.tenants.add(tenant.getId().toString());
       this.cascadeTenancy = Boolean.FALSE;
     }
   } else if (StringUtils.isNotBlank(Models.currentAdminTenantForVcenter())
       && !Models.currentAdminTenantForVcenter()
           .equalsIgnoreCase(TenantUtils.getTenantSelectorForUnassigned())) {
     this.tenants.clear();
     this.tenant = Models.currentAdminTenantForVcenter();
     this.cascadeTenancy = Boolean.TRUE;
   }
 }
    protected Task<VcenterRestRep> createVCenter(boolean validateConnection) {
      VcenterCreateParam vcenterCreateParam = new VcenterCreateParam();
      doWriteTo(vcenterCreateParam);

      if (Security.isSystemAdmin()) {
        return VCenterUtils.createVCenter(
            vcenterCreateParam, validateConnection, getAclAssignmentChanges());
      }

      return VCenterUtils.createVCenter(
          TenantUtils.getTenantFilter(Models.currentAdminTenantForVcenter()),
          vcenterCreateParam,
          validateConnection);
    }