diff OrthancServer/OrthancRestApi/OrthancRestModalities.cpp @ 3611:0ce9c1c6474f storage-commitment

test route in REST API for storage commitment
author Sebastien Jodogne <s.jodogne@gmail.com>
date Tue, 21 Jan 2020 12:53:03 +0100
parents 085283445db0
children c1e2b91c2ab4
line wrap: on
line diff
--- a/OrthancServer/OrthancRestApi/OrthancRestModalities.cpp	Mon Jan 20 19:09:49 2020 +0100
+++ b/OrthancServer/OrthancRestApi/OrthancRestModalities.cpp	Tue Jan 21 12:53:03 2020 +0100
@@ -1273,7 +1273,7 @@
     if (call.ParseJsonRequest(json))
     {
       const std::string& localAet = context.GetDefaultLocalApplicationEntityTitle();
-      RemoteModalityParameters remote =
+      const RemoteModalityParameters remote =
         MyGetModalityUsingSymbolicName(call.GetUriComponent("id", ""));
 
       std::auto_ptr<ParsedDicomFile> query
@@ -1298,6 +1298,38 @@
   }
 
 
+  static void TestStorageCommitment(RestApiPostCall& call)
+  {
+    ServerContext& context = OrthancRestApi::GetContext(call);
+
+    Json::Value json;
+    if (call.ParseJsonRequest(json))
+    {
+      const std::string& localAet = context.GetDefaultLocalApplicationEntityTitle();
+      const RemoteModalityParameters remote =
+        MyGetModalityUsingSymbolicName(call.GetUriComponent("id", ""));
+
+      {
+        DicomUserConnection scu(localAet, remote);
+
+        std::vector<std::string> sopClassUids, sopInstanceUids;
+        sopClassUids.push_back("a");
+        sopInstanceUids.push_back("b");
+
+        std::string t = Toolbox::GenerateDicomPrivateUniqueIdentifier();
+        scu.RequestStorageCommitment(t, sopClassUids, sopInstanceUids);
+      }
+
+      Json::Value result;
+      call.GetOutput().AnswerJson(result);
+    }
+    else
+    {
+      throw OrthancException(ErrorCode_BadFileFormat, "Must provide a JSON object");
+    }
+  }
+
+
   void OrthancRestApi::RegisterModalities()
   {
     Register("/modalities", ListModalities);
@@ -1341,5 +1373,7 @@
     Register("/peers/{id}/system", PeerSystem);
 
     Register("/modalities/{id}/find-worklist", DicomFindWorklist);
+
+    Register("/modalities/{id}/storage-commitment", TestStorageCommitment);
   }
 }