# HG changeset patch # User Sebastien Jodogne # Date 1582892591 -3600 # Node ID 1f4910999fe799f7a908823647c7a5c4f7b332ff # Parent bc25deb403027153509dcc2d094cfd65aef0ab1b Fix issue #168 (Plugins can't read private tags from the configuration file) diff -r bc25deb40302 -r 1f4910999fe7 Core/DicomParsing/DicomModification.cpp --- a/Core/DicomParsing/DicomModification.cpp Fri Feb 28 11:53:23 2020 +0100 +++ b/Core/DicomParsing/DicomModification.cpp Fri Feb 28 13:23:11 2020 +0100 @@ -1324,6 +1324,12 @@ patientNameReplaced = (IsReplaced(DICOM_TAG_PATIENT_NAME) && GetReplacement(DICOM_TAG_PATIENT_NAME) == patientName); + + // New in Orthanc 1.6.0 + if (request.isMember("PrivateCreator")) + { + privateCreator_ = SerializationToolbox::ReadString(request, "PrivateCreator"); + } } diff -r bc25deb40302 -r 1f4910999fe7 Core/DicomParsing/DicomModification.h --- a/Core/DicomParsing/DicomModification.h Fri Feb 28 11:53:23 2020 +0100 +++ b/Core/DicomParsing/DicomModification.h Fri Feb 28 13:23:11 2020 +0100 @@ -187,7 +187,7 @@ void Serialize(Json::Value& value) const; - void SetPrivateCreator(std::string& privateCreator) + void SetPrivateCreator(const std::string& privateCreator) { privateCreator_ = privateCreator; } diff -r bc25deb40302 -r 1f4910999fe7 NEWS --- a/NEWS Fri Feb 28 11:53:23 2020 +0100 +++ b/NEWS Fri Feb 28 13:23:11 2020 +0100 @@ -45,6 +45,7 @@ * Fix issue #165 (Boundary parameter in multipart Content-Type is too long) * Fix issue #166 (CMake find_boost version is now broken with newer boost/cmake) * Fix issue #167 (Job can't be cancelled - Handling of timeouts after established association) +* Fix issue #168 (Plugins can't read private tags from the configuration file) Version 1.5.8 (2019-10-16) diff -r bc25deb40302 -r 1f4910999fe7 OrthancServer/OrthancConfiguration.cpp --- a/OrthancServer/OrthancConfiguration.cpp Fri Feb 28 11:53:23 2020 +0100 +++ b/OrthancServer/OrthancConfiguration.cpp Fri Feb 28 13:23:11 2020 +0100 @@ -865,4 +865,11 @@ return new TemporaryFile; } } + + + std::string OrthancConfiguration::GetDefaultPrivateCreator() const + { + // New configuration option in Orthanc 1.6.0 + return GetStringParameter("DefaultPrivateCreator", ""); + } } diff -r bc25deb40302 -r 1f4910999fe7 OrthancServer/OrthancConfiguration.h --- a/OrthancServer/OrthancConfiguration.h Fri Feb 28 11:53:23 2020 +0100 +++ b/OrthancServer/OrthancConfiguration.h Fri Feb 28 13:23:11 2020 +0100 @@ -231,5 +231,7 @@ void ResetServerIndex(); TemporaryFile* CreateTemporaryFile() const; + + std::string GetDefaultPrivateCreator() const; }; } diff -r bc25deb40302 -r 1f4910999fe7 OrthancServer/OrthancRestApi/OrthancRestAnonymizeModify.cpp --- a/OrthancServer/OrthancRestApi/OrthancRestAnonymizeModify.cpp Fri Feb 28 11:53:23 2020 +0100 +++ b/OrthancServer/OrthancRestApi/OrthancRestAnonymizeModify.cpp Fri Feb 28 13:23:11 2020 +0100 @@ -37,6 +37,7 @@ #include "../../Core/DicomParsing/FromDcmtkBridge.h" #include "../../Core/Logging.h" #include "../../Core/SerializationToolbox.h" +#include "../OrthancConfiguration.h" #include "../ServerContext.h" #include "../ServerJobs/MergeStudyJob.h" #include "../ServerJobs/ResourceModificationJob.h" @@ -63,6 +64,11 @@ { // curl http://localhost:8042/series/95a6e2bf-9296e2cc-bf614e2f-22b391ee-16e010e0/modify -X POST -d '{"Replace":{"InstitutionName":"My own clinic"},"Priority":9}' + { + OrthancConfiguration::ReaderLock lock; + target.SetPrivateCreator(lock.GetConfiguration().GetDefaultPrivateCreator()); + } + if (call.ParseJsonRequest(request)) { target.ParseModifyRequest(request); @@ -80,6 +86,11 @@ { // curl http://localhost:8042/instances/6e67da51-d119d6ae-c5667437-87b9a8a5-0f07c49f/anonymize -X POST -d '{"Replace":{"PatientName":"hello","0010-0020":"world"},"Keep":["StudyDescription", "SeriesDescription"],"KeepPrivateTags": true,"Remove":["Modality"]}' > Anonymized.dcm + { + OrthancConfiguration::ReaderLock lock; + target.SetPrivateCreator(lock.GetConfiguration().GetDefaultPrivateCreator()); + } + if (call.ParseJsonRequest(request) && request.isObject()) { @@ -553,6 +564,11 @@ privateCreator = v.asString(); } + else + { + OrthancConfiguration::ReaderLock lock; + privateCreator = lock.GetConfiguration().GetDefaultPrivateCreator(); + } // Inject time-related information diff -r bc25deb40302 -r 1f4910999fe7 Plugins/Engine/OrthancPlugins.cpp --- a/Plugins/Engine/OrthancPlugins.cpp Fri Feb 28 11:53:23 2020 +0100 +++ b/Plugins/Engine/OrthancPlugins.cpp Fri Feb 28 13:23:11 2020 +0100 @@ -2922,9 +2922,18 @@ std::string dicom; { + // Fix issue 168 (Plugins can't read private tags from the + // configuration file) + // https://bitbucket.org/sjodogne/orthanc/issues/168/ + std::string privateCreator; + { + OrthancConfiguration::ReaderLock lock; + privateCreator = lock.GetConfiguration().GetDefaultPrivateCreator(); + } + std::auto_ptr file (ParsedDicomFile::CreateFromJson(json, static_cast(p.flags), - "" /* TODO - private creator */)); + privateCreator)); if (p.pixelData) { @@ -3097,7 +3106,25 @@ DcmTagKey tag2(tag.GetGroup(), tag.GetElement()); DictionaryReadLocker locker; - const DcmDictEntry* entry = locker->findEntry(tag2, NULL); + const DcmDictEntry* entry = NULL; + + if (tag.IsPrivate()) + { + // Fix issue 168 (Plugins can't read private tags from the + // configuration file) + // https://bitbucket.org/sjodogne/orthanc/issues/168/ + std::string privateCreator; + { + OrthancConfiguration::ReaderLock lock; + privateCreator = lock.GetConfiguration().GetDefaultPrivateCreator(); + } + + entry = locker->findEntry(tag2, privateCreator.c_str()); + } + else + { + entry = locker->findEntry(tag2, NULL); + } if (entry == NULL) { diff -r bc25deb40302 -r 1f4910999fe7 Resources/Configuration.json --- a/Resources/Configuration.json Fri Feb 28 11:53:23 2020 +0100 +++ b/Resources/Configuration.json Fri Feb 28 13:23:11 2020 +0100 @@ -521,5 +521,10 @@ // to option "request_timeout_ms" of Mongoose/Civetweb. It will set // the socket options "SO_RCVTIMEO" and "SO_SNDTIMEO" to the // specified value. - "HttpRequestTimeout" : 30 + "HttpRequestTimeout" : 30, + + // Set the default private creator that is used by Orthanc when it + // looks for a private tag in its dictionary (cf. "Dictionary" + // option), or when it creates/modifies a DICOM file (new in Orthanc 1.6.0). + "DefaultPrivateCreator" : "" }