comparison Core/DicomNetworking/DicomUserConnection.cpp @ 3700:5cbbf14e516b

Fix issue #103 ("queries/.../retrieve" API returns HTTP code 200 even on server errors)
author Sebastien Jodogne <s.jodogne@gmail.com>
date Wed, 26 Feb 2020 13:21:41 +0100
parents 94f4a18a79cc
children 736907ecb626 58f92b1c8061
comparison
equal deleted inserted replaced
3699:efa815dd2c20 3700:5cbbf14e516b
420 request.MoveOriginatorID = moveOriginatorID; // The type DIC_US is an alias for uint16_t 420 request.MoveOriginatorID = moveOriginatorID; // The type DIC_US is an alias for uint16_t
421 request.opts |= O_STORE_MOVEORIGINATORID; 421 request.opts |= O_STORE_MOVEORIGINATORID;
422 } 422 }
423 423
424 // Finally conduct transmission of data 424 // Finally conduct transmission of data
425 T_DIMSE_C_StoreRSP rsp; 425 T_DIMSE_C_StoreRSP response;
426 DcmDataset* statusDetail = NULL; 426 DcmDataset* statusDetail = NULL;
427 Check(DIMSE_storeUser(assoc_, presID, &request, 427 Check(DIMSE_storeUser(assoc_, presID, &request,
428 NULL, dcmff.getDataset(), /*progressCallback*/ NULL, NULL, 428 NULL, dcmff.getDataset(), /*progressCallback*/ NULL, NULL,
429 /*opt_blockMode*/ DIMSE_BLOCKING, /*opt_dimse_timeout*/ dimseTimeout_, 429 /*opt_blockMode*/ DIMSE_BLOCKING, /*opt_dimse_timeout*/ dimseTimeout_,
430 &rsp, &statusDetail, NULL), 430 &response, &statusDetail, NULL),
431 connection.remoteAet_, "C-STORE"); 431 connection.remoteAet_, "C-STORE");
432 432
433 if (statusDetail != NULL) 433 if (statusDetail != NULL)
434 { 434 {
435 delete statusDetail; 435 delete statusDetail;
436 }
437
438
439 /**
440 * New in Orthanc 1.6.0: Deal with failures during C-STORE.
441 * http://dicom.nema.org/medical/dicom/current/output/chtml/part04/sect_B.2.3.html#table_B.2-1
442 **/
443
444 if (response.DimseStatus != 0x0000 && // Success
445 response.DimseStatus != 0xB000 && // Warning - Coercion of Data Elements
446 response.DimseStatus != 0xB007 && // Warning - Data Set does not match SOP Class
447 response.DimseStatus != 0xB006) // Warning - Elements Discarded
448 {
449 char buf[16];
450 sprintf(buf, "%04X", response.DimseStatus);
451 throw OrthancException(ErrorCode_NetworkProtocol,
452 "C-STORE SCU to AET \"" + connection.remoteAet_ +
453 "\" has failed with DIMSE status 0x" + buf);
436 } 454 }
437 } 455 }
438 456
439 457
440 namespace 458 namespace
650 { 668 {
651 delete statusDetail; 669 delete statusDetail;
652 } 670 }
653 671
654 Check(cond, remoteAet, "C-FIND"); 672 Check(cond, remoteAet, "C-FIND");
673
674
675 /**
676 * New in Orthanc 1.6.0: Deal with failures during C-FIND.
677 * http://dicom.nema.org/medical/dicom/current/output/chtml/part04/sect_C.4.html#table_C.4-1
678 **/
679
680 if (response.DimseStatus != 0x0000 && // Success
681 response.DimseStatus != 0xFF00 && // Pending - Matches are continuing
682 response.DimseStatus != 0xFF01) // Pending - Matches are continuing
683 {
684 char buf[16];
685 sprintf(buf, "%04X", response.DimseStatus);
686 throw OrthancException(ErrorCode_NetworkProtocol,
687 "C-FIND SCU to AET \"" + remoteAet +
688 "\" has failed with DIMSE status 0x" + buf);
689 }
690
655 } 691 }
656 692
657 693
658 void DicomUserConnection::Find(DicomFindAnswers& result, 694 void DicomUserConnection::Find(DicomFindAnswers& result,
659 ResourceType level, 695 ResourceType level,
836 { 872 {
837 delete responseIdentifiers; 873 delete responseIdentifiers;
838 } 874 }
839 875
840 Check(cond, remoteAet_, "C-MOVE"); 876 Check(cond, remoteAet_, "C-MOVE");
877
878
879 /**
880 * New in Orthanc 1.6.0: Deal with failures during C-MOVE.
881 * http://dicom.nema.org/medical/dicom/current/output/chtml/part04/sect_C.4.2.html#table_C.4-2
882 **/
883
884 if (response.DimseStatus != 0x0000 && // Success
885 response.DimseStatus != 0xFF00) // Pending - Sub-operations are continuing
886 {
887 char buf[16];
888 sprintf(buf, "%04X", response.DimseStatus);
889 throw OrthancException(ErrorCode_NetworkProtocol,
890 "C-MOVE SCU to AET \"" + remoteAet_ +
891 "\" has failed with DIMSE status 0x" + buf);
892 }
841 } 893 }
842 894
843 895
844 void DicomUserConnection::ResetStorageSOPClasses() 896 void DicomUserConnection::ResetStorageSOPClasses()
845 { 897 {