public void injectTargetAccountAndContainerFromBlobId(BlobId blobId, RestRequest restRequest,
      RestRequestMetricsGroup metricsGroup) throws RestServiceException {
    Account targetAccount = accountService.getAccountById(blobId.getAccountId());
    if (targetAccount == null) {
      frontendMetrics.getHeadDeleteUnrecognizedAccountCount.inc();
      // @todo The check can be removed once HelixAccountService is running with UNKNOWN_ACCOUNT created.
      if (blobId.getAccountId() != Account.UNKNOWN_ACCOUNT_ID) {
        throw new RestServiceException(
            "Account from blobId=" + blobId.getID() + "with accountId=" + blobId.getAccountId()
                + " cannot be recognized", RestServiceErrorCode.InvalidAccount);
      } else {
        logger.debug(
            "Account cannot be found for blobId={} with accountId={}. Setting targetAccount to UNKNOWN_ACCOUNT",
            blobId.getID(), blobId.getAccountId());
        targetAccount = accountService.getAccountById(Account.UNKNOWN_ACCOUNT_ID);
      }
    }
    Container targetContainer;
    try {
      targetContainer = accountService.getContainerById(blobId.getAccountId(), blobId.getContainerId());
    } catch (AccountServiceException e) {
      throw new RestServiceException(
          "Failed to get container with Id= " + blobId.getContainerId() + " from account " + targetAccount.getName()
              + "for blobId=" + blobId.getID(), RestServiceErrorCode.getRestServiceErrorCode(e.getErrorCode()));
    }
    if (targetContainer == null) {
      frontendMetrics.getHeadDeleteUnrecognizedContainerCount.inc();
      throw new RestServiceException(
          "Container from blobId=" + blobId.getID() + "with accountId=" + blobId.getAccountId() + " containerId="
              + blobId.getContainerId() + " cannot be recognized", RestServiceErrorCode.InvalidContainer);
    }
    setTargetAccountAndContainerInRestRequest(restRequest, targetAccount, targetContainer, metricsGroup);
  }
Obtains the target {@link Account} and {@link Container} id from the blobId string, queries the {@link AccountService}
to get the corresponding {@link Account} and {@link Container}, and injects the target {@link Account} and
{@link Container} into the {@link RestRequest}.
@param blobId The blobId to get the target {@link Account} and {@link Container} id.
@param restRequest The rest request to insert the target {@link Account} and {@link Container}.
@param metricsGroup The {@link RestRequestMetricsGroup} to use to set up {@link ContainerMetrics}, or {@code null}
                    if {@link ContainerMetrics} instantiation is not needed.
@throws RestServiceException if 1) either {@link Account} or {@link Container} could not be found; or 2)
                             either {@link Account} or {@link Container} IDs were explicitly specified as
                             {@link Account#UNKNOWN_ACCOUNT_ID} or {@link Container#UNKNOWN_CONTAINER_ID}.
ambry-frontend/src/main/java/com/github/ambry/frontend/AccountAndContainerInjector.java