# HG changeset patch # User Sebastien Jodogne # Date 1602321791 -7200 # Node ID c70df925151e9f04b8cc188ab16db54dc0b5498c # Parent 416c35da7d25e88a19712ab463e39e3b392cba1e RequestOrigin_WebDav diff -r 416c35da7d25 -r c70df925151e OrthancFramework/Sources/Enumerations.cpp --- a/OrthancFramework/Sources/Enumerations.cpp Sat Oct 10 10:38:45 2020 +0200 +++ b/OrthancFramework/Sources/Enumerations.cpp Sat Oct 10 11:23:11 2020 +0200 @@ -738,6 +738,9 @@ case RequestOrigin_Lua: return "Lua"; + case RequestOrigin_WebDav: + return "WebDav"; + default: throw OrthancException(ErrorCode_ParameterOutOfRange); } @@ -1662,6 +1665,10 @@ { return RequestOrigin_Lua; } + else if (origin == "WebDav") + { + return RequestOrigin_WebDav; + } else { throw OrthancException(ErrorCode_ParameterOutOfRange); diff -r 416c35da7d25 -r c70df925151e OrthancFramework/Sources/Enumerations.h --- a/OrthancFramework/Sources/Enumerations.h Sat Oct 10 10:38:45 2020 +0200 +++ b/OrthancFramework/Sources/Enumerations.h Sat Oct 10 11:23:11 2020 +0200 @@ -497,7 +497,8 @@ RequestOrigin_DicomProtocol, RequestOrigin_RestApi, RequestOrigin_Plugins, - RequestOrigin_Lua + RequestOrigin_Lua, + RequestOrigin_WebDav // New in Orthanc 1.8.0 }; enum ServerBarrierEvent diff -r 416c35da7d25 -r c70df925151e OrthancServer/Plugins/Engine/PluginsEnumerations.cpp --- a/OrthancServer/Plugins/Engine/PluginsEnumerations.cpp Sat Oct 10 10:38:45 2020 +0200 +++ b/OrthancServer/Plugins/Engine/PluginsEnumerations.cpp Sat Oct 10 11:23:11 2020 +0200 @@ -288,6 +288,9 @@ case RequestOrigin_Unknown: return OrthancPluginInstanceOrigin_Unknown; + case RequestOrigin_WebDav: + return OrthancPluginInstanceOrigin_WebDav; + default: throw OrthancException(ErrorCode_ParameterOutOfRange); } diff -r 416c35da7d25 -r c70df925151e OrthancServer/Plugins/Include/orthanc/OrthancCPlugin.h --- a/OrthancServer/Plugins/Include/orthanc/OrthancCPlugin.h Sat Oct 10 10:38:45 2020 +0200 +++ b/OrthancServer/Plugins/Include/orthanc/OrthancCPlugin.h Sat Oct 10 11:23:11 2020 +0200 @@ -116,8 +116,8 @@ #endif #define ORTHANC_PLUGINS_MINIMAL_MAJOR_NUMBER 1 -#define ORTHANC_PLUGINS_MINIMAL_MINOR_NUMBER 7 -#define ORTHANC_PLUGINS_MINIMAL_REVISION_NUMBER 2 +#define ORTHANC_PLUGINS_MINIMAL_MINOR_NUMBER 8 +#define ORTHANC_PLUGINS_MINIMAL_REVISION_NUMBER 0 #if !defined(ORTHANC_PLUGINS_VERSION_IS_ABOVE) @@ -891,6 +891,7 @@ OrthancPluginInstanceOrigin_RestApi = 3, /*!< Instance received through REST API of Orthanc */ OrthancPluginInstanceOrigin_Plugin = 4, /*!< Instance added to Orthanc by a plugin */ OrthancPluginInstanceOrigin_Lua = 5, /*!< Instance added to Orthanc by a Lua script */ + OrthancPluginInstanceOrigin_WebDav = 6, /*!< Instance received through WebDAV (new in 1.8.0) */ _OrthancPluginInstanceOrigin_INTERNAL = 0x7fffffff } OrthancPluginInstanceOrigin; diff -r 416c35da7d25 -r c70df925151e OrthancServer/Sources/DicomInstanceOrigin.cpp --- a/OrthancServer/Sources/DicomInstanceOrigin.cpp Sat Oct 10 10:38:45 2020 +0200 +++ b/OrthancServer/Sources/DicomInstanceOrigin.cpp Sat Oct 10 11:23:11 2020 +0200 @@ -70,6 +70,7 @@ case RequestOrigin_Lua: case RequestOrigin_Plugins: + case RequestOrigin_WebDav: { // No additional information available for these kinds of requests break; diff -r 416c35da7d25 -r c70df925151e OrthancServer/Sources/DicomInstanceOrigin.h --- a/OrthancServer/Sources/DicomInstanceOrigin.h Sat Oct 10 10:38:45 2020 +0200 +++ b/OrthancServer/Sources/DicomInstanceOrigin.h Sat Oct 10 11:23:11 2020 +0200 @@ -78,6 +78,11 @@ return DicomInstanceOrigin(RequestOrigin_Plugins); } + static DicomInstanceOrigin FromWebDav() + { + return DicomInstanceOrigin(RequestOrigin_WebDav); + } + RequestOrigin GetRequestOrigin() const { return origin_; diff -r 416c35da7d25 -r c70df925151e OrthancServer/Sources/OrthancWebDav.cpp --- a/OrthancServer/Sources/OrthancWebDav.cpp Sat Oct 10 10:38:45 2020 +0200 +++ b/OrthancServer/Sources/OrthancWebDav.cpp Sat Oct 10 11:23:11 2020 +0200 @@ -1199,9 +1199,14 @@ that->Upload(reinterpret_cast&>(*obj).GetValue()); lastModification = GetNow(); } - else if (GetNow() - lastModification > boost::posix_time::seconds(10)) + else if (GetNow() - lastModification > boost::posix_time::seconds(30)) { - // After every 10 seconds of inactivity, remove the empty folders + /** + * After every 30 seconds of inactivity, remove the empty + * folders. This delay is needed to avoid removing + * just-created folders before the remote WebDAV has time to + * write files into it. + **/ LOG(INFO) << "Cleaning up the empty WebDAV upload folders"; that->uploads_.RemoveEmptyFolders(); lastModification = GetNow(); @@ -1223,7 +1228,7 @@ if (uploads_.GetFileContent(mime, content, time, uri)) { DicomInstanceToStore instance; - // instance.SetOrigin(DicomInstanceOrigin_WebDav); // TODO + instance.SetOrigin(DicomInstanceOrigin::FromWebDav()); instance.SetBuffer(content.c_str(), content.size()); bool success = false; @@ -1235,7 +1240,8 @@ if (status == StoreStatus_Success || status == StoreStatus_AlreadyStored) { - LOG(INFO) << "Successfully imported DICOM instance from WebDAV: " << path << " (Orthanc ID: " << publicId << ")"; + LOG(INFO) << "Successfully imported DICOM instance from WebDAV: " + << path << " (Orthanc ID: " << publicId << ")"; success = true; } } diff -r 416c35da7d25 -r c70df925151e OrthancServer/UnitTestsSources/ServerJobsTests.cpp --- a/OrthancServer/UnitTestsSources/ServerJobsTests.cpp Sat Oct 10 10:38:45 2020 +0200 +++ b/OrthancServer/UnitTestsSources/ServerJobsTests.cpp Sat Oct 10 11:23:11 2020 +0200 @@ -478,6 +478,23 @@ ASSERT_FALSE(origin.LookupCalledAet(t)); ASSERT_FALSE(origin.LookupHttpUsername(t)); } + + { + DicomInstanceOrigin origin(DicomInstanceOrigin::FromWebDav()); + + s = 42; + origin.Serialize(s); + } + + { + DicomInstanceOrigin origin(s); + ASSERT_EQ(RequestOrigin_WebDav, origin.GetRequestOrigin()); + ASSERT_EQ("", std::string(origin.GetRemoteAetC())); + ASSERT_FALSE(origin.LookupRemoteIp(t)); + ASSERT_FALSE(origin.LookupRemoteAet(t)); + ASSERT_FALSE(origin.LookupCalledAet(t)); + ASSERT_FALSE(origin.LookupHttpUsername(t)); + } }