public DicomWebPath parseDicomWebpath(String unparsedWebpath) throws IOException {
    String[] webPathSplit = unparsedWebpath.split("/dicomWeb/");

    if (webPathSplit.length != 2) {
      throw new IOException("Invalid DICOM web path");
    }

    DicomWebPath dicomWebPath = new DicomWebPath();

    dicomWebPath.dicomStorePath = webPathSplit[0];
    String[] storePathElements = dicomWebPath.dicomStorePath.split("/");
    dicomWebPath.project = storePathElements[1];
    dicomWebPath.location = storePathElements[3];
    dicomWebPath.dataset = storePathElements[5];
    dicomWebPath.storeId = storePathElements[7];

    String[] searchParameters;
    searchParameters = webPathSplit[1].split("/");
    if (searchParameters.length < 2) {
      throw new IOException("Invalid DICOM web path");
    }
    dicomWebPath.studyId = searchParameters[1];
    dicomWebPath.seriesId = searchParameters[3];
    dicomWebPath.instanceId = searchParameters[5];

    return dicomWebPath;
  }
@Test
  public void test_parsedAllElements() throws IOException {
    String webpathStr =
        "projects/foo/location/earth/datasets/bar/dicomStores/fee/dicomWeb/studies/abc/series/xyz/instances/123";

    WebPathParser parser = new WebPathParser();
    WebPathParser.DicomWebPath dicomWebPath = parser.parseDicomWebpath(webpathStr);

    Assert.assertNotNull(dicomWebPath);
    Assert.assertEquals("foo", dicomWebPath.project);
    Assert.assertEquals("earth", dicomWebPath.location);
    Assert.assertEquals("bar", dicomWebPath.dataset);
    Assert.assertEquals("fee", dicomWebPath.storeId);
    Assert.assertEquals("abc", dicomWebPath.studyId);
    Assert.assertEquals("xyz", dicomWebPath.seriesId);
    Assert.assertEquals("123", dicomWebPath.instanceId);
    Assert.assertEquals(
        "projects/foo/location/earth/datasets/bar/dicomStores/fee", dicomWebPath.dicomStorePath);
  }