changeset 36:08ea8401f7b2

mammography plugin checking whether DICOMweb plugin is installed
author Sebastien Jodogne <s.jodogne@gmail.com>
date Sat, 22 Jun 2024 16:13:54 +0200
parents 4faec1378b89
children 14af12f73fb5
files Samples/MammographyDeepLearning/src/main/java/Main.java
diffstat 1 files changed, 14 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- a/Samples/MammographyDeepLearning/src/main/java/Main.java	Fri Jun 14 15:03:10 2024 +0200
+++ b/Samples/MammographyDeepLearning/src/main/java/Main.java	Sat Jun 22 16:13:54 2024 +0200
@@ -31,6 +31,7 @@
 import be.uclouvain.orthanc.ResourceType;
 import be.uclouvain.orthanc.RestOutput;
 import org.apache.commons.compress.utils.IOUtils;
+import org.json.JSONArray;
 import org.json.JSONObject;
 
 import java.awt.image.BufferedImage;
@@ -113,6 +114,19 @@
                             if (!connection.isOrthancVersionAbove(1, 12, 5)) {
                                 throw new RuntimeException("Your version of Orthanc must be >= 1.12.5 to run this plugin");
                             }
+
+                            JSONArray plugins = new JSONArray(connection.doGetAsString("/plugins"));
+
+                            boolean hasDicomWeb = false;
+                            for (int i = 0; i < plugins.length() && !hasDicomWeb; i++) {
+                                if (plugins.getString(i).equals("dicom-web")) {
+                                    hasDicomWeb = true;
+                                }
+                            }
+
+                            if (!hasDicomWeb) {
+                                throw new RuntimeException("The DICOMweb plugin is required, but is not installed");
+                            }
                         } catch (IOException | InterruptedException e) {
                             throw new RuntimeException(e);
                         }