public String[] getActiveIPs(String cartridgeType, String domain, String subDomain) {
    List<String> publicIps = new ArrayList<String>();

    if (domain == null || subDomain == null) {
      return new String[0];
    }

    if (data.getServiceConfigs() != null) {
      List<ServiceConfiguration> serviceConfigs = data.getServiceConfigs().get(cartridgeType);
      if (serviceConfigs != null) {

        for (ServiceConfiguration serviceConfiguration : serviceConfigs) {

          if (domain.equals(serviceConfiguration.getDomain())
              && subDomain.equals(serviceConfiguration.getSubDomain())) {

            String ipStr = serviceConfiguration.getPublicIp();
            if (ipStr != null && !ipStr.isEmpty()) {
              for (String ip : ipStr.split(",")) {
                if (!publicIps.contains(ip)) {
                  publicIps.add(ip);
                }
              }
            }
          }
        }
      }
    }
    return publicIps.toArray(new String[publicIps.size()]);
  }
  public String[] getDomains(String cartridgeType, int tenantId) {
    List<String> domains = new ArrayList<String>();
    if (data.getServiceConfigs() != null) {
      List<ServiceConfiguration> serviceConfigs = data.getServiceConfigs().get(cartridgeType);
      if (serviceConfigs != null) {

        for (ServiceConfiguration serviceConfiguration : serviceConfigs) {

          List<Integer> tenantIds =
              LoadBalancerConfigUtil.getTenantIds(serviceConfiguration.getTenantRange());
          if (!tenantIds.isEmpty() && (tenantIds.contains(tenantId) || tenantIds.contains(0))) {
            if (!domains.contains(serviceConfiguration.getDomain())) {
              domains.add(serviceConfiguration.getDomain());
            }
          }
        }
      }
    }
    return domains.toArray(new String[domains.size()]);
  }
  /* (non-Javadoc)
   * @see org.wso2.carbon.stratos.topology.mgt.service.TopologyManagementService#getDomainsAndSubdomains(java.lang.String, int)
   */
  public DomainContext[] getDomainsAndSubdomains(String cartridgeType, int tenantId) {
    List<DomainContext> domainContexts = new ArrayList<DomainContext>();

    if (data.getServiceConfigs() != null) {
      List<ServiceConfiguration> serviceConfigs = data.getServiceConfigs().get(cartridgeType);
      if (serviceConfigs != null) {

        for (ServiceConfiguration serviceConfiguration : serviceConfigs) {

          List<Integer> tenantIds =
              LoadBalancerConfigUtil.getTenantIds(serviceConfiguration.getTenantRange());
          if (!tenantIds.isEmpty() && (tenantIds.contains(tenantId) || tenantIds.contains(0))) {
            DomainContext domainCtx =
                new DomainContext(
                    serviceConfiguration.getDomain(), serviceConfiguration.getSubDomain());
            if (!domainContexts.contains(domainCtx)) {
              domainContexts.add(domainCtx);
            }
          }
        }
      }
    }
    return domainContexts.toArray(new DomainContext[domainContexts.size()]);
  }