Mercurial > hg > orthanc
changeset 3677:4182cde57afb
refactoring FindStorageAccessMode
author | Sebastien Jodogne <s.jodogne@gmail.com> |
---|---|
date | Wed, 19 Feb 2020 17:17:27 +0100 |
parents | 231b46ce1984 |
children | 26c6d47467a9 |
files | OrthancServer/ServerContext.cpp OrthancServer/ServerContext.h OrthancServer/ServerEnumerations.cpp OrthancServer/ServerEnumerations.h |
diffstat | 4 files changed, 46 insertions(+), 49 deletions(-) [+] |
line wrap: on
line diff
--- a/OrthancServer/ServerContext.cpp Wed Feb 19 14:19:49 2020 +0100 +++ b/OrthancServer/ServerContext.cpp Wed Feb 19 17:17:27 2020 +0100 @@ -254,6 +254,11 @@ jobsEngine_.SetWorkersCount(lock.GetConfiguration().GetUnsignedIntegerParameter("ConcurrentJobs", 2)); saveJobs_ = lock.GetConfiguration().GetBooleanParameter("SaveJobs", true); metricsRegistry_->SetEnabled(lock.GetConfiguration().GetBooleanParameter("MetricsEnabled", true)); + + // New configuration options in Orthanc 1.5.1 + findStorageAccessMode_ = StringToFindStorageAccessMode(lock.GetConfiguration().GetStringParameter("StorageAccessOnFind", "Always")); + limitFindInstances_ = lock.GetConfiguration().GetUnsignedIntegerParameter("LimitFindInstances", 0); + limitFindResults_ = lock.GetConfiguration().GetUnsignedIntegerParameter("LimitFindResults", 0); } jobsEngine_.SetThreadSleep(unitTesting ? 20 : 200); @@ -796,44 +801,8 @@ size_t since, size_t limit) { - LookupMode mode; - unsigned int databaseLimit; + unsigned int databaseLimit = (queryLevel == ResourceType_Instance ? limitFindInstances_ : limitFindResults_); - { - // New configuration option in 1.5.1 - OrthancConfiguration::ReaderLock lock; - - std::string value = lock.GetConfiguration().GetStringParameter("StorageAccessOnFind", "Always"); - - if (value == "Always") - { - mode = LookupMode_DiskOnLookupAndAnswer; - } - else if (value == "Never") - { - mode = LookupMode_DatabaseOnly; - } - else if (value == "Answers") - { - mode = LookupMode_DiskOnAnswer; - } - else - { - throw OrthancException(ErrorCode_ParameterOutOfRange, - "Configuration option \"StorageAccessOnFind\" " - "should be \"Always\", \"Never\" or \"Answers\": " + value); - } - - if (queryLevel == ResourceType_Instance) - { - databaseLimit = lock.GetConfiguration().GetUnsignedIntegerParameter("LimitFindInstances", 0); - } - else - { - databaseLimit = lock.GetConfiguration().GetUnsignedIntegerParameter("LimitFindResults", 0); - } - } - std::vector<std::string> resources, instances; { @@ -863,8 +832,8 @@ bool hasOnlyMainDicomTags; DicomMap dicom; - if (mode == LookupMode_DatabaseOnly || - mode == LookupMode_DiskOnAnswer || + if (findStorageAccessMode_ == FindStorageAccessMode_DatabaseOnly || + findStorageAccessMode_ == FindStorageAccessMode_DiskOnAnswer || lookup.HasOnlyMainDicomTags()) { // Case (1): The main DICOM tags, as stored in the database, @@ -907,8 +876,8 @@ } else { - if ((mode == LookupMode_DiskOnLookupAndAnswer || - mode == LookupMode_DiskOnAnswer) && + if ((findStorageAccessMode_ == FindStorageAccessMode_DiskOnLookupAndAnswer || + findStorageAccessMode_ == FindStorageAccessMode_DiskOnAnswer) && dicomAsJson.get() == NULL && isDicomAsJsonNeeded) {
--- a/OrthancServer/ServerContext.h Wed Feb 19 14:19:49 2020 +0100 +++ b/OrthancServer/ServerContext.h Wed Feb 19 17:17:27 2020 +0100 @@ -82,14 +82,6 @@ private: - enum LookupMode - { - LookupMode_DatabaseOnly, - LookupMode_DiskOnAnswer, - LookupMode_DiskOnLookupAndAnswer - }; - - class LuaServerListener : public IServerListener { private: @@ -218,6 +210,9 @@ std::string defaultLocalAet_; OrthancHttpHandler httpHandler_; bool saveJobs_; + FindStorageAccessMode findStorageAccessMode_; + unsigned int limitFindInstances_; + unsigned int limitFindResults_; std::auto_ptr<MetricsRegistry> metricsRegistry_; bool isHttpServerSecure_;
--- a/OrthancServer/ServerEnumerations.cpp Wed Feb 19 14:19:49 2020 +0100 +++ b/OrthancServer/ServerEnumerations.cpp Wed Feb 19 17:17:27 2020 +0100 @@ -192,6 +192,30 @@ return dictContentType_.Translate(str); } + + FindStorageAccessMode StringToFindStorageAccessMode(const std::string& value) + { + if (value == "Always") + { + return FindStorageAccessMode_DiskOnLookupAndAnswer; + } + else if (value == "Never") + { + return FindStorageAccessMode_DatabaseOnly; + } + else if (value == "Answers") + { + return FindStorageAccessMode_DiskOnAnswer; + } + else + { + throw OrthancException(ErrorCode_ParameterOutOfRange, + "Configuration option \"StorageAccessOnFind\" " + "should be \"Always\", \"Never\" or \"Answers\": " + value); + } + } + + std::string GetBasePath(ResourceType type, const std::string& publicId) {
--- a/OrthancServer/ServerEnumerations.h Wed Feb 19 14:19:49 2020 +0100 +++ b/OrthancServer/ServerEnumerations.h Wed Feb 19 17:17:27 2020 +0100 @@ -83,6 +83,13 @@ }; } + enum FindStorageAccessMode + { + FindStorageAccessMode_DatabaseOnly, + FindStorageAccessMode_DiskOnAnswer, + FindStorageAccessMode_DiskOnLookupAndAnswer + }; + /** * WARNING: Do not change the explicit values in the enumerations @@ -178,6 +185,8 @@ FileContentType StringToContentType(const std::string& str); + FindStorageAccessMode StringToFindStorageAccessMode(const std::string& str); + std::string EnumerationToString(FileContentType type); std::string GetFileContentMime(FileContentType type);