changeset 4791:656784ac6759 proto-filter-instance-returning-error-code

wip: returning OutOfResources when an instance is filtered out by ReceivedInstanceFilter. Ideally, we should implement a ReceivedInstanceFilter2 that would return the C-Store error code
author Alain Mazy <am@osimis.io>
date Wed, 29 Sep 2021 10:32:23 +0200
parents 9754d5f2f38a
children 3ab57510f6dd
files OrthancFramework/Sources/DicomNetworking/IStoreRequestHandler.h OrthancFramework/Sources/DicomNetworking/Internals/StoreScp.cpp OrthancServer/Sources/main.cpp
diffstat 3 files changed, 16 insertions(+), 4 deletions(-) [+]
line wrap: on
line diff
--- a/OrthancFramework/Sources/DicomNetworking/IStoreRequestHandler.h	Tue Sep 14 14:51:12 2021 +0200
+++ b/OrthancFramework/Sources/DicomNetworking/IStoreRequestHandler.h	Wed Sep 29 10:32:23 2021 +0200
@@ -39,7 +39,7 @@
     {
     }
 
-    virtual void Handle(DcmDataset& dicom,
+    virtual int  Handle(DcmDataset& dicom,
                         const std::string& remoteIp,
                         const std::string& remoteAet,
                         const std::string& calledAet) = 0;
--- a/OrthancFramework/Sources/DicomNetworking/Internals/StoreScp.cpp	Tue Sep 14 14:51:12 2021 +0200
+++ b/OrthancFramework/Sources/DicomNetworking/Internals/StoreScp.cpp	Wed Sep 29 10:32:23 2021 +0200
@@ -182,7 +182,12 @@
               {
                 try
                 {
-                  cbdata->handler->Handle(**imageDataSet, *cbdata->remoteIp, cbdata->remoteAET, cbdata->calledAET);
+                  int status = cbdata->handler->Handle(**imageDataSet, *cbdata->remoteIp, cbdata->remoteAET, cbdata->calledAET);
+
+                  if (status != 0)
+                  {
+                    rsp->DimseStatus = static_cast<DIC_US>(status);  
+                  }
                 }
                 catch (OrthancException& e)
                 {
--- a/OrthancServer/Sources/main.cpp	Tue Sep 14 14:51:12 2021 +0200
+++ b/OrthancServer/Sources/main.cpp	Wed Sep 29 10:32:23 2021 +0200
@@ -84,7 +84,7 @@
   }
 
 
-  virtual void Handle(DcmDataset& dicom,
+  virtual int  Handle(DcmDataset& dicom,
                       const std::string& remoteIp,
                       const std::string& remoteAet,
                       const std::string& calledAet) ORTHANC_OVERRIDE 
@@ -97,8 +97,15 @@
                          (remoteIp.c_str(), remoteAet.c_str(), calledAet.c_str()));
 
       std::string id;
-      context_.Store(id, *toStore, StoreInstanceMode_Default);
+      StoreStatus res = context_.Store(id, *toStore, StoreInstanceMode_Default);
+      if (res == StoreStatus_FilteredOut)
+      {
+        return 0xA700; // C-Store "Out of Resources" error code
+      }
+      return 0x0000;
     }
+
+    return 0xC000;  // C-Store "Cannot understand" error code
   }
 };