# HG changeset patch # User Sebastien Jodogne # Date 1450084250 -3600 # Node ID 0001f8cd78494e897af37f480915a0a4cfb299fa # Parent b465506eb0280250bb6917fead387b0c6c4a70f3 Warn about badly formatted modality/peer definitions in configuration file at startup diff -r b465506eb028 -r 0001f8cd7849 NEWS --- a/NEWS Fri Dec 11 19:09:46 2015 +0100 +++ b/NEWS Mon Dec 14 10:10:50 2015 +0100 @@ -6,6 +6,7 @@ * New function in plugin SDK: "OrthancPluginSendMultipartItem2()" * Fix range search if the lower or upper limit is absent * Fix modality worklists lookups if tags with UN (unknown) VR are present +* Warn about badly formatted modality/peer definitions in configuration file at startup Version 0.9.6 (2015/12/08) diff -r b465506eb028 -r 0001f8cd7849 OrthancServer/DicomProtocol/RemoteModalityParameters.cpp --- a/OrthancServer/DicomProtocol/RemoteModalityParameters.cpp Fri Dec 11 19:09:46 2015 +0100 +++ b/OrthancServer/DicomProtocol/RemoteModalityParameters.cpp Mon Dec 14 10:10:50 2015 +0100 @@ -33,6 +33,7 @@ #include "../PrecompiledHeadersServer.h" #include "RemoteModalityParameters.h" +#include "../../Core/Logging.h" #include "../../Core/OrthancException.h" #include @@ -97,7 +98,17 @@ if (modality.size() == 4) { - SetManufacturer(modality.get(3u, "").asString()); + const std::string& manufacturer = modality.get(3u, "").asString(); + + try + { + SetManufacturer(manufacturer); + } + catch (OrthancException&) + { + LOG(ERROR) << "Unknown modality manufacturer: \"" << manufacturer << "\""; + throw; + } } else { diff -r b465506eb028 -r 0001f8cd7849 OrthancServer/OrthancInitialization.cpp --- a/OrthancServer/OrthancInitialization.cpp Fri Dec 11 19:09:46 2015 +0100 +++ b/OrthancServer/OrthancInitialization.cpp Mon Dec 14 10:10:50 2015 +0100 @@ -71,7 +71,7 @@ namespace Orthanc { - static boost::mutex globalMutex_; + static boost::recursive_mutex globalMutex_; static Json::Value configuration_; static boost::filesystem::path defaultDirectory_; static std::string configurationAbsolutePath_; @@ -243,6 +243,26 @@ } + static void ValidateGlobalConfiguration() + { + std::set ids; + + Configuration::GetListOfOrthancPeers(ids); + for (std::set::const_iterator it = ids.begin(); it != ids.end(); ++it) + { + OrthancPeerParameters peer; + Configuration::GetOrthancPeer(peer, *it); + } + + Configuration::GetListOfDicomModalities(ids); + for (std::set::const_iterator it = ids.begin(); it != ids.end(); ++it) + { + RemoteModalityParameters modality; + Configuration::GetDicomModalityUsingSymbolicName(modality, *it); + } + } + + static void RegisterUserMetadata() { if (configuration_.isMember("UserMetadata")) @@ -367,7 +387,7 @@ void OrthancInitialize(const char* configurationFile) { - boost::mutex::scoped_lock lock(globalMutex_); + boost::recursive_mutex::scoped_lock lock(globalMutex_); #if ORTHANC_SSL_ENABLED == 1 // https://wiki.openssl.org/index.php/Library_Initialization @@ -385,6 +405,7 @@ // Read the user-provided configuration ReadGlobalConfiguration(configurationFile); + ValidateGlobalConfiguration(); HttpClient::GlobalInitialize(GetGlobalBoolParameterInternal("HttpsVerifyPeers", true), GetGlobalStringParameterInternal("HttpsCACertificates", "")); @@ -412,7 +433,7 @@ void OrthancFinalize() { - boost::mutex::scoped_lock lock(globalMutex_); + boost::recursive_mutex::scoped_lock lock(globalMutex_); HttpClient::GlobalFinalize(); #if ORTHANC_JPEG_LOSSLESS_ENABLED == 1 @@ -444,7 +465,7 @@ std::string Configuration::GetGlobalStringParameter(const std::string& parameter, const std::string& defaultValue) { - boost::mutex::scoped_lock lock(globalMutex_); + boost::recursive_mutex::scoped_lock lock(globalMutex_); return GetGlobalStringParameterInternal(parameter, defaultValue); } @@ -452,7 +473,7 @@ int Configuration::GetGlobalIntegerParameter(const std::string& parameter, int defaultValue) { - boost::mutex::scoped_lock lock(globalMutex_); + boost::recursive_mutex::scoped_lock lock(globalMutex_); if (configuration_.isMember(parameter)) { @@ -476,7 +497,7 @@ bool Configuration::GetGlobalBoolParameter(const std::string& parameter, bool defaultValue) { - boost::mutex::scoped_lock lock(globalMutex_); + boost::recursive_mutex::scoped_lock lock(globalMutex_); return GetGlobalBoolParameterInternal(parameter, defaultValue); } @@ -484,7 +505,7 @@ void Configuration::GetDicomModalityUsingSymbolicName(RemoteModalityParameters& modality, const std::string& name) { - boost::mutex::scoped_lock lock(globalMutex_); + boost::recursive_mutex::scoped_lock lock(globalMutex_); if (!configuration_.isMember("DicomModalities")) { @@ -517,7 +538,7 @@ void Configuration::GetOrthancPeer(OrthancPeerParameters& peer, const std::string& name) { - boost::mutex::scoped_lock lock(globalMutex_); + boost::recursive_mutex::scoped_lock lock(globalMutex_); if (!configuration_.isMember("OrthancPeers")) { @@ -550,7 +571,7 @@ const char* parameter, bool onlyAlphanumeric) { - boost::mutex::scoped_lock lock(globalMutex_); + boost::recursive_mutex::scoped_lock lock(globalMutex_); target.clear(); @@ -589,6 +610,8 @@ void Configuration::GetListOfDicomModalities(std::set& target) { + target.clear(); + if (!ReadKeys(target, "DicomModalities", true)) { LOG(ERROR) << "Only alphanumeric and dash characters are allowed in the names of the modalities"; @@ -599,6 +622,8 @@ void Configuration::GetListOfOrthancPeers(std::set& target) { + target.clear(); + if (!ReadKeys(target, "OrthancPeers", true)) { LOG(ERROR) << "Only alphanumeric and dash characters are allowed in the names of Orthanc peers"; @@ -610,7 +635,7 @@ void Configuration::SetupRegisteredUsers(MongooseServer& httpServer) { - boost::mutex::scoped_lock lock(globalMutex_); + boost::recursive_mutex::scoped_lock lock(globalMutex_); httpServer.ClearUsers(); @@ -664,7 +689,7 @@ std::string Configuration::InterpretStringParameterAsPath(const std::string& parameter) { - boost::mutex::scoped_lock lock(globalMutex_); + boost::recursive_mutex::scoped_lock lock(globalMutex_); return InterpretRelativePath(defaultDirectory_.string(), parameter); } @@ -672,7 +697,7 @@ void Configuration::GetGlobalListOfStringsParameter(std::list& target, const std::string& key) { - boost::mutex::scoped_lock lock(globalMutex_); + boost::recursive_mutex::scoped_lock lock(globalMutex_); target.clear(); @@ -777,7 +802,7 @@ void Configuration::UpdateModality(const std::string& symbolicName, const RemoteModalityParameters& modality) { - boost::mutex::scoped_lock lock(globalMutex_); + boost::recursive_mutex::scoped_lock lock(globalMutex_); if (!configuration_.isMember("DicomModalities")) { @@ -801,7 +826,7 @@ void Configuration::RemoveModality(const std::string& symbolicName) { - boost::mutex::scoped_lock lock(globalMutex_); + boost::recursive_mutex::scoped_lock lock(globalMutex_); if (!configuration_.isMember("DicomModalities")) { @@ -823,7 +848,7 @@ void Configuration::UpdatePeer(const std::string& symbolicName, const OrthancPeerParameters& peer) { - boost::mutex::scoped_lock lock(globalMutex_); + boost::recursive_mutex::scoped_lock lock(globalMutex_); if (!configuration_.isMember("OrthancPeers")) { @@ -848,7 +873,7 @@ void Configuration::RemovePeer(const std::string& symbolicName) { - boost::mutex::scoped_lock lock(globalMutex_); + boost::recursive_mutex::scoped_lock lock(globalMutex_); if (!configuration_.isMember("OrthancPeers")) { @@ -980,7 +1005,7 @@ void Configuration::GetConfiguration(Json::Value& result) { - boost::mutex::scoped_lock lock(globalMutex_); + boost::recursive_mutex::scoped_lock lock(globalMutex_); result = configuration_; }