public static NamedBlobPath parse(String path, Map<String, Object> args) throws RestServiceException {
    Objects.requireNonNull(path, "path should not be null");
    Objects.requireNonNull(args, "args should not be null");
    if (RestUtils.isS3Request(args)) {
      return parseS3(path, args);
    }
    path = path.startsWith("/") ? path.substring(1) : path;
    String[] splitPath = path.split("/", 4);
    String blobNamePrefix = RestUtils.getHeader(args, PREFIX_PARAM, false);
    boolean isListRequest = blobNamePrefix != null;
    int expectedSegments = isListRequest ? 3 : 4;
    if (splitPath.length != expectedSegments || !Operations.NAMED_BLOB.equalsIgnoreCase(splitPath[0])) {
      throw new RestServiceException(String.format(
          "Path must have format '/named/<account_name>/<container_name>%s.  Received path='%s', blobNamePrefix='%s'",
          isListRequest ? "" : "/<blob_name>'", path, blobNamePrefix), RestServiceErrorCode.BadRequest);
    }
    String accountName = splitPath[1];
    String containerName = splitPath[2];
    if (isListRequest) {
      String pageToken = RestUtils.getHeader(args, PAGE_PARAM, false);
      return new NamedBlobPath(accountName, containerName, null, blobNamePrefix, pageToken);
    } else {
      String blobName = splitPath[3];
      if (blobName.length() > MAX_BLOB_NAME_LENGTH) {
        throw new RestServiceException(
            String.format("Blob name maximum length should be less than %s", MAX_BLOB_NAME_LENGTH),
            RestServiceErrorCode.BadRequest);
      }
      return new NamedBlobPath(accountName, containerName, blobName, null, null);
    }
  }
Parse the input path if it's a named blob request.
@param path the URI path that needs to be parsed. This path should already be URL decoded and have query paramaters
            removed. In the request handling path, this would be done by the {@link RestRequest} implementation.
@param args a map containing any query parameters from the request.
@return the {@link NamedBlobPath} that indicates the parsing result from blobUrl.
@throws RestServiceException on parsing errors.
ambry-api/src/main/java/com/github/ambry/frontend/NamedBlobPath.java