comparison Framework/Loaders/SeriesThumbnailsLoader.cpp @ 1254:7a0460c5e98e broker

don't follow redirections if contacting the Orthanc REST API
author Sebastien Jodogne <s.jodogne@gmail.com>
date Wed, 08 Jan 2020 14:01:36 +0100
parents c471a0aa137b
children 0ca50d275b9a
comparison
equal deleted inserted replaced
1253:227ebd71802f 1254:7a0460c5e98e
45 { 45 {
46 return SeriesThumbnailType_Video; 46 return SeriesThumbnailType_Video;
47 } 47 }
48 else 48 else
49 { 49 {
50 return SeriesThumbnailType_Unknown; 50 return SeriesThumbnailType_Unsupported;
51 } 51 }
52 } 52 }
53 53
54 54
55 SeriesThumbnailsLoader::Thumbnail::Thumbnail(const std::string& image, 55 SeriesThumbnailsLoader::Thumbnail::Thumbnail(const std::string& image,
183 { 183 {
184 throw Orthanc::OrthancException(Orthanc::ErrorCode_NetworkProtocol); 184 throw Orthanc::OrthancException(Orthanc::ErrorCode_NetworkProtocol);
185 } 185 }
186 else 186 else
187 { 187 {
188 SeriesThumbnailType type = SeriesThumbnailType_Unknown; 188 SeriesThumbnailType type = SeriesThumbnailType_Unsupported;
189 189
190 std::string sopClassUid; 190 std::string sopClassUid;
191 if (value.size() > 0 && 191 if (value.size() > 0 &&
192 GetSopClassUid(sopClassUid, value[0])) 192 GetSopClassUid(sopClassUid, value[0]))
193 { 193 {
427 427
428 void SeriesThumbnailsLoader::Handle(const OracleCommandExceptionMessage& message) 428 void SeriesThumbnailsLoader::Handle(const OracleCommandExceptionMessage& message)
429 { 429 {
430 const OracleCommandBase& command = dynamic_cast<const OracleCommandBase&>(message.GetOrigin()); 430 const OracleCommandBase& command = dynamic_cast<const OracleCommandBase&>(message.GetOrigin());
431 assert(command.HasPayload()); 431 assert(command.HasPayload());
432 dynamic_cast<Handler&>(command.GetPayload()).HandleError(); 432
433 if (command.GetType() == IOracleCommand::Type_GetOrthancImage)
434 {
435 // This is presumably a HTTP status 301 (Moved permanently)
436 // because of an unsupported DICOM file in "/preview"
437 const ThumbnailInformation& info = dynamic_cast<const ThumbnailInformation&>(command.GetPayload());
438 AcquireThumbnail(info.GetDicomSource(), info.GetStudyInstanceUid(),
439 info.GetSeriesInstanceUid(), new Thumbnail(SeriesThumbnailType_Unsupported));
440 }
441 else
442 {
443 dynamic_cast<Handler&>(command.GetPayload()).HandleError();
444 }
433 } 445 }
434 446
435 447
436 SeriesThumbnailsLoader::SeriesThumbnailsLoader(ILoadersContext& context, 448 SeriesThumbnailsLoader::SeriesThumbnailsLoader(ILoadersContext& context,
437 int priority) : 449 int priority) :
488 { 500 {
489 Thumbnails::const_iterator found = thumbnails_.find(seriesInstanceUid); 501 Thumbnails::const_iterator found = thumbnails_.find(seriesInstanceUid);
490 502
491 if (found == thumbnails_.end()) 503 if (found == thumbnails_.end())
492 { 504 {
493 return SeriesThumbnailType_Unknown; 505 return SeriesThumbnailType_NotLoaded;
494 } 506 }
495 else 507 else
496 { 508 {
497 assert(found->second != NULL); 509 assert(found->second != NULL);
498 image.assign(found->second->GetImage()); 510 image.assign(found->second->GetImage());