changeset 3010:9f859a18cbc2

make "/tools/create-dicom" more tolerant to invalid specific character set
author Sebastien Jodogne <s.jodogne@gmail.com>
date Thu, 13 Dec 2018 17:16:32 +0100
parents 0e1755e5efd0
children af1530b45290
files NEWS OrthancServer/OrthancRestApi/OrthancRestAnonymizeModify.cpp
diffstat 2 files changed, 14 insertions(+), 2 deletions(-) [+]
line wrap: on
line diff
--- a/NEWS	Thu Dec 13 12:37:10 2018 +0100
+++ b/NEWS	Thu Dec 13 17:16:32 2018 +0100
@@ -2,6 +2,13 @@
 ===============================
 
 
+Maintenance
+-----------
+
+* "/tools/create-dicom" is more tolerant to invalid specific character set
+
+
+
 Version 1.5.0 (2018-12-10)
 ==========================
 
--- a/OrthancServer/OrthancRestApi/OrthancRestAnonymizeModify.cpp	Thu Dec 13 12:37:10 2018 +0100
+++ b/OrthancServer/OrthancRestApi/OrthancRestAnonymizeModify.cpp	Thu Dec 13 17:16:32 2018 +0100
@@ -440,6 +440,7 @@
       // Select one existing child instance of the parent resource, to
       // retrieve all its tags
       Json::Value siblingTags;
+      std::string siblingInstanceId;
 
       {
         // Retrieve all the instances of the parent resource
@@ -452,7 +453,8 @@
           throw OrthancException(ErrorCode_InternalError);
         }
 
-        context.ReadDicomAsJson(siblingTags, siblingInstances.front());
+        siblingInstanceId = siblingInstances.front();
+        context.ReadDicomAsJson(siblingTags, siblingInstanceId);
       }
 
 
@@ -463,11 +465,14 @@
         if (siblingTags.isMember(SPECIFIC_CHARACTER_SET))
         {
           Encoding encoding;
+
           if (!siblingTags[SPECIFIC_CHARACTER_SET].isMember("Value") ||
               siblingTags[SPECIFIC_CHARACTER_SET]["Value"].type() != Json::stringValue ||
               !GetDicomEncoding(encoding, siblingTags[SPECIFIC_CHARACTER_SET]["Value"].asCString()))
           {
-            throw OrthancException(ErrorCode_CreateDicomParentEncoding);
+            LOG(WARNING) << "Instance with an incorrect Specific Character Set, "
+                         << "using the default Orthanc encoding: " << siblingInstanceId;
+            encoding = GetDefaultDicomEncoding();
           }
 
           dicom.SetEncoding(encoding);