Mercurial > hg > orthanc
comparison Core/DicomParsing/ParsedDicomFile.cpp @ 2954:d924f9bb61cc
taking advantage of details in OrthancException
author | Sebastien Jodogne <s.jodogne@gmail.com> |
---|---|
date | Mon, 03 Dec 2018 14:35:34 +0100 |
parents | 22524fd06225 |
children | aa0f06b43b2e |
comparison
equal
deleted
inserted
replaced
2953:210d5afd8f2b | 2954:d924f9bb61cc |
---|---|
290 | 290 |
291 offset_ += chunkSize_; | 291 offset_ += chunkSize_; |
292 | 292 |
293 if (!cond.good()) | 293 if (!cond.good()) |
294 { | 294 { |
295 LOG(ERROR) << "Error while sending a DICOM field: " << cond.text(); | 295 throw OrthancException(ErrorCode_InternalError, |
296 throw OrthancException(ErrorCode_InternalError); | 296 "Error while sending a DICOM field: " + |
297 std::string(cond.text())); | |
297 } | 298 } |
298 | 299 |
299 return true; | 300 return true; |
300 } | 301 } |
301 } | 302 } |
953 { | 954 { |
954 SetEncoding(defaultEncoding); | 955 SetEncoding(defaultEncoding); |
955 } | 956 } |
956 else if (tmp->IsBinary()) | 957 else if (tmp->IsBinary()) |
957 { | 958 { |
958 LOG(ERROR) << "Invalid binary string in the SpecificCharacterSet (0008,0005) tag"; | 959 throw OrthancException(ErrorCode_ParameterOutOfRange, |
959 throw OrthancException(ErrorCode_ParameterOutOfRange); | 960 "Invalid binary string in the SpecificCharacterSet (0008,0005) tag"); |
960 } | 961 } |
961 else if (tmp->IsNull() || | 962 else if (tmp->IsNull() || |
962 tmp->GetContent().empty()) | 963 tmp->GetContent().empty()) |
963 { | 964 { |
964 SetEncoding(defaultEncoding); | 965 SetEncoding(defaultEncoding); |
971 { | 972 { |
972 SetEncoding(encoding); | 973 SetEncoding(encoding); |
973 } | 974 } |
974 else | 975 else |
975 { | 976 { |
976 LOG(ERROR) << "Unsupported value for the SpecificCharacterSet (0008,0005) tag: \"" | 977 throw OrthancException(ErrorCode_ParameterOutOfRange, |
977 << tmp->GetContent() << "\""; | 978 "Unsupported value for the SpecificCharacterSet (0008,0005) tag: \"" + |
978 throw OrthancException(ErrorCode_ParameterOutOfRange); | 979 tmp->GetContent() + "\""); |
979 } | 980 } |
980 } | 981 } |
981 | 982 |
982 for (DicomMap::Map::const_iterator | 983 for (DicomMap::Map::const_iterator |
983 it = source.map_.begin(); it != source.map_.end(); ++it) | 984 it = source.map_.begin(); it != source.map_.end(); ++it) |
1079 case MimeType_Png: | 1080 case MimeType_Png: |
1080 #if ORTHANC_ENABLE_PNG == 1 | 1081 #if ORTHANC_ENABLE_PNG == 1 |
1081 EmbedImage(mime, content); | 1082 EmbedImage(mime, content); |
1082 break; | 1083 break; |
1083 #else | 1084 #else |
1084 LOG(ERROR) << "Orthanc was compiled without support of PNG"; | 1085 throw OrthancException(ErrorCode_NotImplemented, |
1085 throw OrthancException(ErrorCode_NotImplemented); | 1086 "Orthanc was compiled without support of PNG"); |
1086 #endif | 1087 #endif |
1087 | 1088 |
1088 case MimeType_Jpeg: | 1089 case MimeType_Jpeg: |
1089 #if ORTHANC_ENABLE_JPEG == 1 | 1090 #if ORTHANC_ENABLE_JPEG == 1 |
1090 EmbedImage(mime, content); | 1091 EmbedImage(mime, content); |
1091 break; | 1092 break; |
1092 #else | 1093 #else |
1093 LOG(ERROR) << "Orthanc was compiled without support of JPEG"; | 1094 throw OrthancException(ErrorCode_NotImplemented, |
1094 throw OrthancException(ErrorCode_NotImplemented); | 1095 "Orthanc was compiled without support of JPEG"); |
1095 #endif | 1096 #endif |
1096 | 1097 |
1097 case MimeType_Pam: | 1098 case MimeType_Pam: |
1098 EmbedImage(mime, content); | 1099 EmbedImage(mime, content); |
1099 break; | 1100 break; |
1101 case MimeType_Pdf: | 1102 case MimeType_Pdf: |
1102 EmbedPdf(content); | 1103 EmbedPdf(content); |
1103 break; | 1104 break; |
1104 | 1105 |
1105 default: | 1106 default: |
1106 LOG(ERROR) << "Unsupported MIME type for the content of a new DICOM file: " << mime; | 1107 throw OrthancException(ErrorCode_NotImplemented, |
1107 throw OrthancException(ErrorCode_NotImplemented); | 1108 "Unsupported MIME type for the content of a new DICOM file: " + mime); |
1108 } | 1109 } |
1109 | 1110 |
1110 return true; | 1111 return true; |
1111 } | 1112 } |
1112 | 1113 |
1367 void ParsedDicomFile::EmbedPdf(const std::string& pdf) | 1368 void ParsedDicomFile::EmbedPdf(const std::string& pdf) |
1368 { | 1369 { |
1369 if (pdf.size() < 5 || // (*) | 1370 if (pdf.size() < 5 || // (*) |
1370 strncmp("%PDF-", pdf.c_str(), 5) != 0) | 1371 strncmp("%PDF-", pdf.c_str(), 5) != 0) |
1371 { | 1372 { |
1372 LOG(ERROR) << "Not a PDF file"; | 1373 throw OrthancException(ErrorCode_BadFileFormat, "Not a PDF file"); |
1373 throw OrthancException(ErrorCode_BadFileFormat); | |
1374 } | 1374 } |
1375 | 1375 |
1376 InvalidateCache(); | 1376 InvalidateCache(); |
1377 | 1377 |
1378 ReplacePlainString(DICOM_TAG_SOP_CLASS_UID, UID_EncapsulatedPDFStorage); | 1378 ReplacePlainString(DICOM_TAG_SOP_CLASS_UID, UID_EncapsulatedPDFStorage); |