comparison OrthancServer/Sources/ServerJobs/ResourceModificationJob.cpp @ 5139:021d7fdcb659

more sanity checks for modifications
author Alain Mazy <am@osimis.io>
date Fri, 20 Jan 2023 17:24:16 +0100
parents 15109c3f0f7d
children 023569e7155b
comparison
equal deleted inserted replaced
5137:15109c3f0f7d 5139:021d7fdcb659
667 replaceStudyMainDicomTags |= DicomMap::IsMainDicomTag(*it, ResourceType_Study); 667 replaceStudyMainDicomTags |= DicomMap::IsMainDicomTag(*it, ResourceType_Study);
668 replaceSeriesMainDicomTags |= DicomMap::IsMainDicomTag(*it, ResourceType_Series); 668 replaceSeriesMainDicomTags |= DicomMap::IsMainDicomTag(*it, ResourceType_Series);
669 replaceInstanceMainDicomTags |= DicomMap::IsMainDicomTag(*it, ResourceType_Instance); 669 replaceInstanceMainDicomTags |= DicomMap::IsMainDicomTag(*it, ResourceType_Instance);
670 } 670 }
671 671
672 if (modification_->IsKept(DICOM_TAG_SOP_INSTANCE_UID) && !IsKeepSource()) 672 if (modification_->IsKept(DICOM_TAG_SOP_INSTANCE_UID)
673 { 673 && (modificationLevel == ResourceType_Series || modificationLevel == ResourceType_Study || modificationLevel == ResourceType_Patient))
674 // note: we could refine this criteria -> this is valid only if all DicomUIDs are kept identical (but this can happen through Keep or Replace options) 674 {
675 throw OrthancException(ErrorCode_BadRequest, 675 // if we keep the SOPInstanceUID, it very likely means that we are modifying existing resources 'in place'
676 "When keeping SOPInstanceUID tag, you must set KeepSource to true to avoid deleting the modified files at the end of the process"); 676
677 // we must make sure we do not delete them at the end of the job
678 if (!IsKeepSource()) // note: we can refine this criteria -> this is valid only if all DicomUIDs are kept identical (but this can happen through Keep or Replace options)
679 {
680 throw OrthancException(ErrorCode_BadRequest,
681 "When keeping SOPInstanceUID tag, you must set KeepSource to true to avoid deleting the modified files at the end of the process");
682 }
683
684 // and we must make sure that we overwite them with the modified resources
685 if (IsKeepSource() && !GetContext().IsOverwriteInstances())
686 {
687 throw OrthancException(ErrorCode_BadRequest,
688 "When keeping SOPInstanceUID tag, you must have the 'OverwriteInstances' Orthanc configuration set to true in order to replace the modified resources");
689 }
677 } 690 }
678 691
679 if (modificationLevel == ResourceType_Study && replacePatientMainDicomTags) 692 if (modificationLevel == ResourceType_Study && replacePatientMainDicomTags)
680 { 693 {
681 for (std::set<std::string>::const_iterator studyId = parentResources_.begin(); studyId != parentResources_.end(); ++studyId) 694 for (std::set<std::string>::const_iterator studyId = parentResources_.begin(); studyId != parentResources_.end(); ++studyId)