changeset 3602:085283445db0 storage-commitment

AllowNAction in remote modality parameters
author Sebastien Jodogne <s.jodogne@gmail.com>
date Thu, 16 Jan 2020 15:28:32 +0100
parents a77e7839012a
children 7e303ba837d9
files Core/DicomNetworking/RemoteModalityParameters.cpp Core/DicomNetworking/RemoteModalityParameters.h Core/Enumerations.cpp Core/Enumerations.h OrthancServer/OrthancRestApi/OrthancRestModalities.cpp Resources/Configuration.json UnitTestsSources/MultiThreadingTests.cpp
diffstat 7 files changed, 30 insertions(+), 6 deletions(-) [+]
line wrap: on
line diff
--- a/Core/DicomNetworking/RemoteModalityParameters.cpp	Thu Jan 16 12:50:06 2020 +0100
+++ b/Core/DicomNetworking/RemoteModalityParameters.cpp	Thu Jan 16 15:28:32 2020 +0100
@@ -48,6 +48,7 @@
 static const char* KEY_ALLOW_GET = "AllowGet";
 static const char* KEY_ALLOW_MOVE = "AllowMove";
 static const char* KEY_ALLOW_STORE = "AllowStore";
+static const char* KEY_ALLOW_N_ACTION = "AllowNAction";
 static const char* KEY_HOST = "Host";
 static const char* KEY_MANUFACTURER = "Manufacturer";
 static const char* KEY_PORT = "Port";
@@ -66,6 +67,7 @@
     allowFind_ = true;
     allowMove_ = true;
     allowGet_ = true;
+    allowNAction_ = true;  // For storage commitment
   }
 
 
@@ -211,6 +213,11 @@
     {
       allowMove_ = SerializationToolbox::ReadBoolean(serialized, KEY_ALLOW_MOVE);
     }
+
+    if (serialized.isMember(KEY_ALLOW_N_ACTION))
+    {
+      allowNAction_ = SerializationToolbox::ReadBoolean(serialized, KEY_ALLOW_N_ACTION);
+    }
   }
 
 
@@ -233,6 +240,9 @@
       case DicomRequestType_Store:
         return allowStore_;
 
+      case DicomRequestType_NAction:
+        return allowNAction_;
+
       default:
         throw OrthancException(ErrorCode_ParameterOutOfRange);
     }
@@ -264,6 +274,10 @@
         allowStore_ = allowed;
         break;
 
+      case DicomRequestType_NAction:
+        allowNAction_ = allowed;
+        break;
+
       default:
         throw OrthancException(ErrorCode_ParameterOutOfRange);
     }
@@ -276,7 +290,8 @@
             !allowStore_ ||
             !allowFind_ ||
             !allowGet_ ||
-            !allowMove_);
+            !allowMove_ ||
+            !allowNAction_);
   }
 
   
@@ -296,6 +311,7 @@
       target[KEY_ALLOW_FIND] = allowFind_;
       target[KEY_ALLOW_GET] = allowGet_;
       target[KEY_ALLOW_MOVE] = allowMove_;
+      target[KEY_ALLOW_N_ACTION] = allowNAction_;
     }
     else
     {
--- a/Core/DicomNetworking/RemoteModalityParameters.h	Thu Jan 16 12:50:06 2020 +0100
+++ b/Core/DicomNetworking/RemoteModalityParameters.h	Thu Jan 16 15:28:32 2020 +0100
@@ -53,6 +53,7 @@
     bool                  allowFind_;
     bool                  allowMove_;
     bool                  allowGet_;
+    bool                  allowNAction_;
 
     void Clear();
 
--- a/Core/Enumerations.cpp	Thu Jan 16 12:50:06 2020 +0100
+++ b/Core/Enumerations.cpp	Thu Jan 16 15:28:32 2020 +0100
@@ -860,6 +860,10 @@
         return "Store";
         break;
 
+      case DicomRequestType_NAction:
+        return "N-Action";
+        break;
+
       default: 
         throw OrthancException(ErrorCode_ParameterOutOfRange);
     }
--- a/Core/Enumerations.h	Thu Jan 16 12:50:06 2020 +0100
+++ b/Core/Enumerations.h	Thu Jan 16 15:28:32 2020 +0100
@@ -622,7 +622,8 @@
     DicomRequestType_Find,
     DicomRequestType_Get,
     DicomRequestType_Move,
-    DicomRequestType_Store
+    DicomRequestType_Store,
+    DicomRequestType_NAction
   };
 
   enum TransferSyntax
--- a/OrthancServer/OrthancRestApi/OrthancRestModalities.cpp	Thu Jan 16 12:50:06 2020 +0100
+++ b/OrthancServer/OrthancRestApi/OrthancRestModalities.cpp	Thu Jan 16 15:28:32 2020 +0100
@@ -1106,8 +1106,6 @@
 
   static void PeerSystem(RestApiGetCall& call)
   {
-    ServerContext& context = OrthancRestApi::GetContext(call);
-
     std::string remote = call.GetUriComponent("id", "");
 
     OrthancConfiguration::ReaderLock lock;
--- a/Resources/Configuration.json	Thu Jan 16 12:50:06 2020 +0100
+++ b/Resources/Configuration.json	Thu Jan 16 15:28:32 2020 +0100
@@ -219,7 +219,8 @@
     //  "AllowEcho" : false,
     //  "AllowFind" : false,
     //  "AllowMove" : false,
-    //  "AllowStore" : true
+    //  "AllowStore" : true,
+    //  "AllowNAction" : false  // Allow storage commitment (new in 1.6.0)
     //}
   },
 
--- a/UnitTestsSources/MultiThreadingTests.cpp	Thu Jan 16 12:50:06 2020 +0100
+++ b/UnitTestsSources/MultiThreadingTests.cpp	Thu Jan 16 15:28:32 2020 +0100
@@ -1897,6 +1897,7 @@
     ASSERT_TRUE(modality.IsRequestAllowed(DicomRequestType_Get));
     ASSERT_TRUE(modality.IsRequestAllowed(DicomRequestType_Store));
     ASSERT_TRUE(modality.IsRequestAllowed(DicomRequestType_Move));
+    ASSERT_TRUE(modality.IsRequestAllowed(DicomRequestType_NAction));
   }
 
   s = Json::nullValue;
@@ -1925,6 +1926,7 @@
     ASSERT_TRUE(modality.IsRequestAllowed(DicomRequestType_Get));
     ASSERT_TRUE(modality.IsRequestAllowed(DicomRequestType_Store));
     ASSERT_TRUE(modality.IsRequestAllowed(DicomRequestType_Move));
+    ASSERT_TRUE(modality.IsRequestAllowed(DicomRequestType_NAction));
   }
 
   s["Port"] = "46";
@@ -1944,8 +1946,9 @@
   operations.insert(DicomRequestType_Get);
   operations.insert(DicomRequestType_Move);
   operations.insert(DicomRequestType_Store);
+  operations.insert(DicomRequestType_NAction);
 
-  ASSERT_EQ(5u, operations.size());
+  ASSERT_EQ(6u, operations.size());
 
   for (std::set<DicomRequestType>::const_iterator 
          it = operations.begin(); it != operations.end(); ++it)