changeset 1574:0c29ebe80ac9

give access to full request origin in ReceivedInstanceFilter (Lua)
author Sebastien Jodogne <s.jodogne@gmail.com>
date Tue, 25 Aug 2015 13:37:57 +0200
parents 3309878b3e16
children f8aae45011c9
files NEWS OrthancServer/IServerListener.h OrthancServer/LuaScripting.cpp OrthancServer/LuaScripting.h OrthancServer/ServerContext.cpp Plugins/Engine/OrthancPlugins.h
diffstat 6 files changed, 19 insertions(+), 14 deletions(-) [+]
line wrap: on
line diff
--- a/NEWS	Tue Aug 25 13:05:22 2015 +0200
+++ b/NEWS	Tue Aug 25 13:37:57 2015 +0200
@@ -11,7 +11,9 @@
 Lua
 ---
 
-* More information about the origin request in "OnStoredInstance()" callbacks
+* More information about the origin request in the "OnStoredInstance()" and
+  "ReceivedInstanceFilter()" callbacks. WARNING: This can result in
+  incompatibilities wrt. previous versions of Orthanc.
 
 Plugins
 -------
--- a/OrthancServer/IServerListener.h	Tue Aug 25 13:05:22 2015 +0200
+++ b/OrthancServer/IServerListener.h	Tue Aug 25 13:37:57 2015 +0200
@@ -52,7 +52,7 @@
 
     virtual void SignalChange(const ServerIndexChange& change) = 0;
 
-    virtual bool FilterIncomingInstance(const Json::Value& simplified,
-                                        const std::string& remoteAet) = 0;
+    virtual bool FilterIncomingInstance(const DicomInstanceToStore& instance,
+                                        const Json::Value& simplified) = 0;
   };
 }
--- a/OrthancServer/LuaScripting.cpp	Tue Aug 25 13:05:22 2015 +0200
+++ b/OrthancServer/LuaScripting.cpp	Tue Aug 25 13:37:57 2015 +0200
@@ -470,8 +470,8 @@
   }
 
 
-  bool LuaScripting::FilterIncomingInstance(const Json::Value& simplified,
-                                            const std::string& remoteAet)
+  bool LuaScripting::FilterIncomingInstance(const DicomInstanceToStore& instance,
+                                            const Json::Value& simplified)
   {
     static const char* NAME = "ReceivedInstanceFilter";
 
@@ -481,7 +481,10 @@
     {
       LuaFunctionCall call(lua_, NAME);
       call.PushJson(simplified);
-      call.PushString(remoteAet);
+
+      Json::Value origin;
+      instance.GetOriginInformation(origin);
+      call.PushJson(origin);
 
       if (!call.ExecutePredicate())
       {
--- a/OrthancServer/LuaScripting.h	Tue Aug 25 13:05:22 2015 +0200
+++ b/OrthancServer/LuaScripting.h	Tue Aug 25 13:37:57 2015 +0200
@@ -98,8 +98,8 @@
 
     virtual void SignalChange(const ServerIndexChange& change);
 
-    virtual bool FilterIncomingInstance(const Json::Value& simplified,
-                                        const std::string& remoteAet);
+    virtual bool FilterIncomingInstance(const DicomInstanceToStore& instance,
+                                        const Json::Value& simplifiedTags);
 
     void Execute(const std::string& command);
   };
--- a/OrthancServer/ServerContext.cpp	Tue Aug 25 13:05:22 2015 +0200
+++ b/OrthancServer/ServerContext.cpp	Tue Aug 25 13:37:57 2015 +0200
@@ -186,8 +186,8 @@
       DicomInstanceHasher hasher(dicom.GetSummary());
       resultPublicId = hasher.HashInstance();
 
-      Json::Value simplified;
-      SimplifyTags(simplified, dicom.GetJson());
+      Json::Value simplifiedTags;
+      SimplifyTags(simplifiedTags, dicom.GetJson());
 
       // Test if the instance must be filtered out
       bool accepted = true;
@@ -199,7 +199,7 @@
         {
           try
           {
-            if (!it->GetListener().FilterIncomingInstance(simplified, dicom.GetRemoteAet()))
+            if (!it->GetListener().FilterIncomingInstance(dicom, simplifiedTags))
             {
               accepted = false;
               break;
@@ -281,7 +281,7 @@
         {
           try
           {
-            it->GetListener().SignalStoredInstance(resultPublicId, dicom, simplified);
+            it->GetListener().SignalStoredInstance(resultPublicId, dicom, simplifiedTags);
           }
           catch (OrthancException& e)
           {
--- a/Plugins/Engine/OrthancPlugins.h	Tue Aug 25 13:05:22 2015 +0200
+++ b/Plugins/Engine/OrthancPlugins.h	Tue Aug 25 13:37:57 2015 +0200
@@ -122,8 +122,8 @@
                                       DicomInstanceToStore& instance,
                                       const Json::Value& simplifiedTags);
 
-    virtual bool FilterIncomingInstance(const Json::Value& simplified,
-                                        const std::string& remoteAet)
+    virtual bool FilterIncomingInstance(const DicomInstanceToStore& instance,
+                                        const Json::Value& simplified)
     {
       return true; // TODO Enable filtering of instances from plugins
     }