From 571c842252ffdded44f78f49cd4c71ac6f260708 Mon Sep 17 00:00:00 2001 From: Nicolas Roduit Date: Thu, 9 Sep 2021 09:46:08 +0200 Subject: [PATCH] Fix minor issues --- src/main/java/org/weasis/dicom/web/ContentType.java | 5 ++--- src/main/java/org/weasis/dicom/web/DicomStowRS.java | 13 +++---------- 2 files changed, 5 insertions(+), 13 deletions(-) diff --git a/src/main/java/org/weasis/dicom/web/ContentType.java b/src/main/java/org/weasis/dicom/web/ContentType.java index 3d8420c..7c55023 100644 --- a/src/main/java/org/weasis/dicom/web/ContentType.java +++ b/src/main/java/org/weasis/dicom/web/ContentType.java @@ -32,9 +32,8 @@ static ContentType probe(Path path) { throw new IOException( String.format("failed to determine content type of file: '%s'", path)); } - switch (type.toLowerCase()) { - case "application/dicom": - return ContentType.APPLICATION_DICOM; + if ("application/dicom".equalsIgnoreCase(type)) { + return ContentType.APPLICATION_DICOM; } throw new UnsupportedOperationException( String.format("unsupported content type: '%s' of file: '%s'", type, path)); diff --git a/src/main/java/org/weasis/dicom/web/DicomStowRS.java b/src/main/java/org/weasis/dicom/web/DicomStowRS.java index 63fb49e..80a0f35 100644 --- a/src/main/java/org/weasis/dicom/web/DicomStowRS.java +++ b/src/main/java/org/weasis/dicom/web/DicomStowRS.java @@ -15,6 +15,7 @@ import java.io.InputStream; import java.io.SequenceInputStream; import java.net.URI; +import java.net.URISyntaxException; import java.net.http.HttpClient; import java.net.http.HttpHeaders; import java.net.http.HttpRequest; @@ -72,7 +73,6 @@ public String toString() { private final String requestURL; private final String agentName; private final Map headers; - private boolean photo = false; private final HttpContentType type = HttpContentType.XML; private final HttpClient client; private final ExecutorService executorService; @@ -82,7 +82,6 @@ public String toString() { * @param contentType the value of the type in the Content-Type HTTP property * @param agentName the value of the User-Agent HTTP property * @param headers some additional header properties. - * @throws IOException Exception during the POST initialization */ public DicomStowRS( String requestURL, ContentType contentType, String agentName, Map headers) { @@ -112,7 +111,7 @@ private String getFinalUrl(String requestURL) { } protected HttpRequest buildConnection(Flow.Publisher multipartSubscriber) - throws Exception { + throws URISyntaxException { ContentType partType = ContentType.APPLICATION_DICOM; HttpRequest.Builder builder = buidDefaultConnection(); @@ -193,9 +192,7 @@ HttpResponse send( } private static void promptHeaders(String prefix, HttpHeaders headers) { - headers - .map() - .forEach((k, v) -> v.stream().forEach(v1 -> LOGGER.debug("{} {}: {}", prefix, k, v1))); + headers.map().forEach((k, v) -> v.forEach(v1 -> LOGGER.debug("{} {}: {}", prefix, k, v1))); LOGGER.debug(prefix); } @@ -214,10 +211,6 @@ public Map getHeaders() { return headers; } - public boolean isPhoto() { - return photo; - } - public void uploadDicom(Path path) throws HttpException { Payload playload = new Payload() {