public static DatasetVersionPath 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");
    boolean isListRequest = RestUtils.getBooleanHeader(args, ENABLE_DATASET_VERSION_LISTING, false);
    boolean isRenameRequest = "RENAME".equals(RestUtils.getHeader(args, OP, false));
    path = path.startsWith("/") ? path.substring(1) : path;
    String[] splitPath = path.split("/");
    int expectedMinimumSegments = isListRequest ? 4 : 5;
    if (splitPath.length < expectedMinimumSegments) {
      throw new RestServiceException(String.format(
          "Blob name must have format '/named/<account_name>/<container_name>/<dataset_name>%s'.  Received path='%s'",
          isListRequest ? "" : "/<version>'", path), RestServiceErrorCode.BadRequest);
    }
    String accountName = splitPath[1];
    String containerName = splitPath[2];
    String datasetName;
    //if isListRequest == true, the path format should be /named/<account_name>/<container_name>/<dataset_name>
    //if isListRequest == false, the path format should be /named/<account_name>/<container_name>/<dataset_name>/<version>
    if (isListRequest) {
      datasetName = String.join("/", Arrays.copyOfRange(splitPath, 3, splitPath.length));
      return new DatasetVersionPath(accountName, containerName, datasetName, null, null);
    }
    String targetVersion = null;
    if (isRenameRequest) {
      targetVersion = RestUtils.getHeader(args, TARGET_VERSION, true);
    }
    datasetName = String.join("/", Arrays.copyOfRange(splitPath, 3, splitPath.length - 1));
    String version = splitPath[splitPath.length - 1];
    return new DatasetVersionPath(accountName, containerName, datasetName, version, targetVersion);
  }
Parse the input path if it's a dataset 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 com.github.ambry.rest.RestRequest} implementation.
@param args a map containing any query parameters from the request.
@return the {@link DatasetVersionPath} that indicates the parsing result from blobUrl.
@throws RestServiceException
ambry-api/src/main/java/com/github/ambry/frontend/DatasetVersionPath.java