public void ensureAccountAndContainerInjected(RestRequest restRequest, BlobProperties blobProperties,
      RestRequestMetricsGroup metricsGroup) throws RestServiceException {
    Account targetAccount = (Account) restRequest.getArgs().get(RestUtils.InternalKeys.TARGET_ACCOUNT_KEY);
    Container targetContainer = (Container) restRequest.getArgs().get(RestUtils.InternalKeys.TARGET_CONTAINER_KEY);
    if (targetAccount == null || targetContainer == null) {
      throw new RestServiceException("Account and container were not injected by RestRequestService",
          RestServiceErrorCode.InternalServerError);
    } else if (targetAccount.getId() == Account.UNKNOWN_ACCOUNT_ID) {
      // This should only occur for V1 blobs, where the blob ID does not contain the actual account and container IDs.
      String serviceId = blobProperties.getServiceId();
      boolean isPrivate = blobProperties.isPrivate();
      injectAccountAndContainerUsingServiceId(restRequest, serviceId, isPrivate, metricsGroup);
    }
  }
If a non-unknown {@link Account} and {@link Container} was not previously injected, inject them into the provided
{@link RestRequest}, based on the given {@link BlobProperties}' service ID and blob privacy setting. This is useful
for V1 blob IDs that do not directly encode the account/container ID.
@param restRequest The {@link RestRequest} to inject {@link Account} and {@link Container}.
@param blobProperties The {@link BlobProperties} that contains the service id and blob privacy setting.
@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 no valid account or container could be identified for re-injection.
ambry-frontend/src/main/java/com/github/ambry/frontend/AccountAndContainerInjector.java