public static Map<String, CapacityUnit> getCUQuotasFromJson(String resourceCUQuotaInJson,
      AccountService accountService) throws IOException {
    Map<String, CapacityUnit> quota = new HashMap<>();
    ObjectMapper objectMapper = new ObjectMapper();
    if (resourceCUQuotaInJson != null && !resourceCUQuotaInJson.trim().isEmpty()) {
      Map<String, MapOrQuota> tempQuotas =
          objectMapper.readValue(resourceCUQuotaInJson, new TypeReference<Map<String, MapOrQuota>>() {
          });
      for (Map.Entry<String, MapOrQuota> entry : tempQuotas.entrySet()) {
        final Account account = accountService.getAccountById(Short.parseShort(entry.getKey()));
        if (account == null) {
          throw new IllegalStateException("No account id " + entry.getKey() + " is found in the account service");
        }
        if (account.getQuotaResourceType() == QuotaResourceType.ACCOUNT && !entry.getValue().isQuota
            || account.getQuotaResourceType() != QuotaResourceType.ACCOUNT && entry.getValue().isQuota) {
          throw new IllegalStateException(
              "Account " + entry.getKey() + " quota enforcement type is different from account metadata: "
                  + account.getQuotaResourceType());
        }
        if (entry.getValue().isQuota()) {
          quota.put(QuotaResource.fromAccount(account).getResourceId(), entry.getValue().getQuota());
        } else {
          for (Map.Entry<String, CapacityUnit> containerQuotaEntry : entry.getValue().getContainerQuotas().entrySet()) {
            String containerIdStr = containerQuotaEntry.getKey();
            Container container = account.getContainerById(Short.parseShort(containerIdStr));
            if (container == null) {
              throw new IllegalStateException(
                  "No container id " + containerIdStr + " is found in the account service under account "
                      + entry.getKey());
            }
            quota.put(QuotaResource.fromContainer(container).getResourceId(), containerQuotaEntry.getValue());
          }
        }
      }
    }
    return quota;
  }
Util to parse the provided json string into resource quotas and create a {@link Map} of QuotaResource id and
{@link CapacityUnit} from json configs.
@param resourceCUQuotaInJson Json string containing resource quota values.
@param accountService The {@link AccountService} to use.
@throws IOException in case of any exception.
ambry-quota/src/main/java/com/github/ambry/quota/capacityunit/JsonCUQuotaDataProviderUtil.java