Mercurial > hg > orthanc
comparison 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 |
comparison
equal
deleted
inserted
replaced
5609:4690a0d2b01e | 5610:d4b570834d3a |
---|---|
374 } | 374 } |
375 | 375 |
376 | 376 |
377 void FindResponse::Resource::SetOneInstanceIdentifier(const std::string& id) | 377 void FindResponse::Resource::SetOneInstanceIdentifier(const std::string& id) |
378 { | 378 { |
379 if (HasOneInstanceIdentifier()) | 379 if (level_ == ResourceType_Instance) |
380 { | |
381 throw OrthancException(ErrorCode_BadParameterType); | |
382 } | |
383 else if (HasOneInstanceIdentifier()) | |
380 { | 384 { |
381 throw OrthancException(ErrorCode_BadSequenceOfCalls); | 385 throw OrthancException(ErrorCode_BadSequenceOfCalls); |
382 } | 386 } |
383 else | 387 else |
384 { | 388 { |
387 } | 391 } |
388 | 392 |
389 | 393 |
390 const std::string& FindResponse::Resource::GetOneInstanceIdentifier() const | 394 const std::string& FindResponse::Resource::GetOneInstanceIdentifier() const |
391 { | 395 { |
392 if (HasOneInstanceIdentifier()) | 396 if (level_ == ResourceType_Instance) |
397 { | |
398 throw OrthancException(ErrorCode_BadParameterType); | |
399 } | |
400 else if (HasOneInstanceIdentifier()) | |
393 { | 401 { |
394 return *oneInstanceIdentifier_; | 402 return *oneInstanceIdentifier_; |
395 } | 403 } |
396 else | 404 else |
397 { | 405 { |
400 } | 408 } |
401 | 409 |
402 | 410 |
403 bool FindResponse::Resource::HasOneInstanceIdentifier() const | 411 bool FindResponse::Resource::HasOneInstanceIdentifier() const |
404 { | 412 { |
405 return oneInstanceIdentifier_.get() != NULL; | 413 if (level_ == ResourceType_Instance) |
414 { | |
415 throw OrthancException(ErrorCode_BadParameterType); | |
416 } | |
417 else | |
418 { | |
419 return oneInstanceIdentifier_.get() != NULL; | |
420 } | |
406 } | 421 } |
407 | 422 |
408 | 423 |
409 static void DebugDicomMap(Json::Value& target, | 424 static void DebugDicomMap(Json::Value& target, |
410 const DicomMap& m) | 425 const DicomMap& m) |