Mercurial > hg > orthanc
changeset 3709:1f4910999fe7
Fix issue #168 (Plugins can't read private tags from the configuration file)
author | Sebastien Jodogne <s.jodogne@gmail.com> |
---|---|
date | Fri, 28 Feb 2020 13:23:11 +0100 |
parents | bc25deb40302 |
children | 1c69af37d8ae 2a170a8f1faf |
files | Core/DicomParsing/DicomModification.cpp Core/DicomParsing/DicomModification.h NEWS OrthancServer/OrthancConfiguration.cpp OrthancServer/OrthancConfiguration.h OrthancServer/OrthancRestApi/OrthancRestAnonymizeModify.cpp Plugins/Engine/OrthancPlugins.cpp Resources/Configuration.json |
diffstat | 8 files changed, 68 insertions(+), 4 deletions(-) [+] |
line wrap: on
line diff
--- 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"); + } }
--- 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; }
--- 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)
--- 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", ""); + } }
--- 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; }; }
--- 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
--- 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<ParsedDicomFile> file (ParsedDicomFile::CreateFromJson(json, static_cast<DicomFromJsonFlags>(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) {
--- 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" : "" }