@Test public void testDicomWebClient_StowError() throws Exception { fakeDicomWebServer.addResponseWithStatusCode(404); assertThrows( IDicomWebClient.DicomWebException.class, () -> client.stowRs(new ByteArrayInputStream(new byte[0]))); }
public void stowRs(InputStream in) throws IDicomWebClient.DicomWebException { GenericUrl url = new GenericUrl(StringUtil.joinPath(serviceUrlPrefix, this.stowPath)); MultipartContent content = new MultipartContent(); content.setMediaType(new HttpMediaType("multipart/related; type=\"application/dicom\"")); content.setBoundary(UUID.randomUUID().toString()); InputStreamContent dicomStream = new InputStreamContent("application/dicom", in); content.addPart(new MultipartContent.Part(dicomStream)); try { HttpRequest httpRequest = requestFactory.buildPostRequest(url, content); httpRequest.execute(); } catch (HttpResponseException e) { throw new DicomWebException( String.format("StowRs: %d, %s", e.getStatusCode(), e.getStatusMessage()), e, e.getStatusCode(), Status.ProcessingFailure); } catch (IOException e) { throw new IDicomWebClient.DicomWebException(e); } }
DicomWebClient implements IDicomWebClient { public void stowRs(InputStream in) throws IDicomWebClient.DicomWebException { GenericUrl url = new GenericUrl(StringUtil.joinPath(serviceUrlPrefix, this.stowPath)); MultipartContent content = new MultipartContent(); content.setMediaType(new HttpMediaType("multipart/related; type=\"application/dicom\"")); content.setBoundary(UUID.randomUUID().toString()); InputStreamContent dicomStream = new InputStreamContent("application/dicom", in); content.addPart(new MultipartContent.Part(dicomStream)); try { HttpRequest httpRequest = requestFactory.buildPostRequest(url, content); httpRequest.execute(); } catch (HttpResponseException e) { throw new DicomWebException( String.format("StowRs: %d, %s", e.getStatusCode(), e.getStatusMessage()), e, e.getStatusCode(), Status.ProcessingFailure); } catch (IOException e) { throw new IDicomWebClient.DicomWebException(e); } } }
DicomWebClient implements IDicomWebClient { public void stowRs(InputStream in) throws IDicomWebClient.DicomWebException { GenericUrl url = new GenericUrl(StringUtil.joinPath(serviceUrlPrefix, this.stowPath)); MultipartContent content = new MultipartContent(); content.setMediaType(new HttpMediaType("multipart/related; type=\"application/dicom\"")); content.setBoundary(UUID.randomUUID().toString()); InputStreamContent dicomStream = new InputStreamContent("application/dicom", in); content.addPart(new MultipartContent.Part(dicomStream)); try { HttpRequest httpRequest = requestFactory.buildPostRequest(url, content); httpRequest.execute(); } catch (HttpResponseException e) { throw new DicomWebException( String.format("StowRs: %d, %s", e.getStatusCode(), e.getStatusMessage()), e, e.getStatusCode(), Status.ProcessingFailure); } catch (IOException e) { throw new IDicomWebClient.DicomWebException(e); } } @Inject  DicomWebClient(
      HttpRequestFactory requestFactory,
      @Annotations.DicomwebAddr String serviceUrlPrefix,
      String stowPath); }
DicomWebClient implements IDicomWebClient { public void stowRs(InputStream in) throws IDicomWebClient.DicomWebException { GenericUrl url = new GenericUrl(StringUtil.joinPath(serviceUrlPrefix, this.stowPath)); MultipartContent content = new MultipartContent(); content.setMediaType(new HttpMediaType("multipart/related; type=\"application/dicom\"")); content.setBoundary(UUID.randomUUID().toString()); InputStreamContent dicomStream = new InputStreamContent("application/dicom", in); content.addPart(new MultipartContent.Part(dicomStream)); try { HttpRequest httpRequest = requestFactory.buildPostRequest(url, content); httpRequest.execute(); } catch (HttpResponseException e) { throw new DicomWebException( String.format("StowRs: %d, %s", e.getStatusCode(), e.getStatusMessage()), e, e.getStatusCode(), Status.ProcessingFailure); } catch (IOException e) { throw new IDicomWebClient.DicomWebException(e); } } @Inject  DicomWebClient(
      HttpRequestFactory requestFactory,
      @Annotations.DicomwebAddr String serviceUrlPrefix,
      String stowPath); InputStream wadoRs(String path); JSONArray qidoRs(String path); void stowRs(InputStream in); }
DicomWebClient implements IDicomWebClient { public void stowRs(InputStream in) throws IDicomWebClient.DicomWebException { GenericUrl url = new GenericUrl(StringUtil.joinPath(serviceUrlPrefix, this.stowPath)); MultipartContent content = new MultipartContent(); content.setMediaType(new HttpMediaType("multipart/related; type=\"application/dicom\"")); content.setBoundary(UUID.randomUUID().toString()); InputStreamContent dicomStream = new InputStreamContent("application/dicom", in); content.addPart(new MultipartContent.Part(dicomStream)); try { HttpRequest httpRequest = requestFactory.buildPostRequest(url, content); httpRequest.execute(); } catch (HttpResponseException e) { throw new DicomWebException( String.format("StowRs: %d, %s", e.getStatusCode(), e.getStatusMessage()), e, e.getStatusCode(), Status.ProcessingFailure); } catch (IOException e) { throw new IDicomWebClient.DicomWebException(e); } } @Inject  DicomWebClient(
      HttpRequestFactory requestFactory,
      @Annotations.DicomwebAddr String serviceUrlPrefix,
      String stowPath); InputStream wadoRs(String path); JSONArray qidoRs(String path); void stowRs(InputStream in);  }