Mercurial > hg > orthanc
diff OrthancServer/Sources/Database/FindResponse.cpp @ 5610:d4b570834d3a find-refactoring
adding safeguards around FindRequest::SetRetrieveOneInstanceIdentifier()
author | Sebastien Jodogne <s.jodogne@gmail.com> |
---|---|
date | Thu, 09 May 2024 10:36:03 +0200 |
parents | 4690a0d2b01e |
children | 1864b16bc7b1 |
line wrap: on
line diff
--- a/OrthancServer/Sources/Database/FindResponse.cpp Wed May 08 18:28:36 2024 +0200 +++ b/OrthancServer/Sources/Database/FindResponse.cpp Thu May 09 10:36:03 2024 +0200 @@ -376,7 +376,11 @@ void FindResponse::Resource::SetOneInstanceIdentifier(const std::string& id) { - if (HasOneInstanceIdentifier()) + if (level_ == ResourceType_Instance) + { + throw OrthancException(ErrorCode_BadParameterType); + } + else if (HasOneInstanceIdentifier()) { throw OrthancException(ErrorCode_BadSequenceOfCalls); } @@ -389,7 +393,11 @@ const std::string& FindResponse::Resource::GetOneInstanceIdentifier() const { - if (HasOneInstanceIdentifier()) + if (level_ == ResourceType_Instance) + { + throw OrthancException(ErrorCode_BadParameterType); + } + else if (HasOneInstanceIdentifier()) { return *oneInstanceIdentifier_; } @@ -402,7 +410,14 @@ bool FindResponse::Resource::HasOneInstanceIdentifier() const { - return oneInstanceIdentifier_.get() != NULL; + if (level_ == ResourceType_Instance) + { + throw OrthancException(ErrorCode_BadParameterType); + } + else + { + return oneInstanceIdentifier_.get() != NULL; + } }