public void injectAccountContainerForNamedBlob(RestRequest restRequest, RestRequestMetricsGroup metricsGroup)
      throws RestServiceException {
    accountAndContainerSanityCheck(restRequest);
    NamedBlobPath namedBlobPath = NamedBlobPath.parse(getRequestPath(restRequest), restRequest.getArgs());
    String accountName = namedBlobPath.getAccountName();
    Account targetAccount = accountService.getAccountByName(accountName);
    if (targetAccount == null) {
      frontendMetrics.unrecognizedAccountNameCount.inc();
      throw new RestServiceException("Account cannot be found for accountName=" + accountName
          + " in put request with account and container headers.", RestServiceErrorCode.InvalidAccount);
    }
    ensureAccountNameMatch(targetAccount, restRequest);
    String containerName = namedBlobPath.getContainerName();
    Container targetContainer;
    try {
      targetContainer = accountService.getContainerByName(accountName, containerName);
    } catch (AccountServiceException e) {
      throw new RestServiceException("Failed to get container " + containerName + " from account " + accountName
          + " in put request with account and container headers.",
          RestServiceErrorCode.getRestServiceErrorCode(e.getErrorCode()));
    }
    if (targetContainer == null) {
      frontendMetrics.unrecognizedContainerNameCount.inc();
      throw new RestServiceException(
          "Container cannot be found for accountName=" + accountName + " and containerName=" + containerName
              + " in put request with account and container headers.", RestServiceErrorCode.InvalidContainer);
    }
    if (targetContainer.getNamedBlobMode() == Container.NamedBlobMode.DISABLED) {
      throw new RestServiceException(
          "Named blob APIs disabled for this container. account=" + accountName + ", container=" + containerName,
          RestServiceErrorCode.BadRequest);
    }
    if (targetContainer.getNamedBlobMode() == Container.NamedBlobMode.NO_UPDATE &&
        RestUtils.isUpsertForNamedBlob(restRequest.getArgs())) {
      throw new RestServiceException(
          "Named blob APIs Upsert disabled for this container. account=" + accountName + ", container=" + containerName,
          RestServiceErrorCode.BadRequest);
    }
    setTargetAccountAndContainerInRestRequest(restRequest, targetAccount, targetContainer, metricsGroup);
  }
Injects target {@link Account}, {@link Container} for named blob requests.
Injects target {@link Dataset} for named blob request if it's dataset upload.
This will treat the request path as a named blob path that includes the account and container names.
@param restRequest The Put {@link RestRequest}.
@param metricsGroup The {@link RestRequestMetricsGroup} to use to set up {@link ContainerMetrics}, or {@code null}
                    if {@link ContainerMetrics} instantiation is not needed.
@throws RestServiceException
ambry-frontend/src/main/java/com/github/ambry/frontend/AccountAndContainerInjector.java