comparison OrthancServer/Sources/OrthancGetRequestHandler.cpp @ 4287:5a3374b6e707

using CLOG in Orthanc DICOM handlers
author Sebastien Jodogne <s.jodogne@gmail.com>
date Wed, 04 Nov 2020 17:48:11 +0100
parents 526bd8bad850
children 5b254bd435d3
comparison
equal deleted inserted replaced
4286:526bd8bad850 4287:5a3374b6e707
158 accepted[transferSyntax] = pc->presentationContextID; 158 accepted[transferSyntax] = pc->presentationContextID;
159 } 159 }
160 } 160 }
161 else 161 else
162 { 162 {
163 LOG(WARNING) << "C-GET: Unknown transfer syntax received: " 163 CLOG(WARNING, DICOM) << "C-GET: Unknown transfer syntax received: "
164 << pc->acceptedTransferSyntax; 164 << pc->acceptedTransferSyntax;
165 } 165 }
166 166
167 pc = (DUL_PRESENTATIONCONTEXT*) LST_Next(l); 167 pc = (DUL_PRESENTATIONCONTEXT*) LST_Next(l);
168 } 168 }
169 } 169 }
256 std::string(dcmSOPClassUIDToModality(sopClassUid.c_str(), "OT")) + 256 std::string(dcmSOPClassUIDToModality(sopClassUid.c_str(), "OT")) +
257 ") " + sopClassUid); 257 ") " + sopClassUid);
258 } 258 }
259 else 259 else
260 { 260 {
261 LOG(INFO) << "C-GET SCP selected transfer syntax " << GetTransferSyntaxUid(selectedSyntax) 261 CLOG(INFO, DICOM) << "C-GET SCP selected transfer syntax " << GetTransferSyntaxUid(selectedSyntax)
262 << ", for source instance with SOP class " << sopClassUid 262 << ", for source instance with SOP class " << sopClassUid
263 << " and transfer syntax " << GetTransferSyntaxUid(sourceSyntax); 263 << " and transfer syntax " << GetTransferSyntaxUid(sourceSyntax);
264 264
265 // make sure that we can send images in this presentation context 265 // make sure that we can send images in this presentation context
266 T_ASC_PresentationContext pc; 266 T_ASC_PresentationContext pc;
267 ASC_findAcceptedPresentationContext(assoc->params, presId, &pc); 267 ASC_findAcceptedPresentationContext(assoc->params, presId, &pc);
268 // the acceptedRole is the association requestor role 268 // the acceptedRole is the association requestor role
293 req.opts = 0; 293 req.opts = 0;
294 294
295 T_DIMSE_C_StoreRSP rsp; 295 T_DIMSE_C_StoreRSP rsp;
296 memset(&rsp, 0, sizeof(rsp)); 296 memset(&rsp, 0, sizeof(rsp));
297 297
298 LOG(INFO) << "Store SCU RQ: MsgID " << msgId << ", (" 298 CLOG(INFO, DICOM) << "Store SCU RQ: MsgID " << msgId << ", ("
299 << dcmSOPClassUIDToModality(sopClassUid.c_str(), "OT") << ")"; 299 << dcmSOPClassUIDToModality(sopClassUid.c_str(), "OT") << ")";
300 300
301 T_DIMSE_DetectedCancelParameters cancelParameters; 301 T_DIMSE_DetectedCancelParameters cancelParameters;
302 memset(&cancelParameters, 0, sizeof(cancelParameters)); 302 memset(&cancelParameters, 0, sizeof(cancelParameters));
303 303
304 std::unique_ptr<DcmDataset> stDetail; 304 std::unique_ptr<DcmDataset> stDetail;
359 << DIMSE_dumpMessage(str, rsp, DIMSE_INCOMING); 359 << DIMSE_dumpMessage(str, rsp, DIMSE_INCOMING);
360 } 360 }
361 361
362 if (cancelParameters.cancelEncountered) 362 if (cancelParameters.cancelEncountered)
363 { 363 {
364 LOG(INFO) << "C-GET SCP: Received C-Cancel RQ"; 364 CLOG(INFO, DICOM) << "C-GET SCP: Received C-Cancel RQ";
365 isContinue = false; 365 isContinue = false;
366 } 366 }
367 else if (rsp.DimseStatus == STATUS_Success) 367 else if (rsp.DimseStatus == STATUS_Success)
368 { 368 {
369 // everything ok 369 // everything ok
372 } 372 }
373 else if ((rsp.DimseStatus & 0xf000) == 0xb000) 373 else if ((rsp.DimseStatus & 0xf000) == 0xb000)
374 { 374 {
375 // a warning status message 375 // a warning status message
376 warningCount_++; 376 warningCount_++;
377 LOG(ERROR) << "C-GET SCP: Store Warning: Response Status: " 377 CLOG(ERROR, DICOM) << "C-GET SCP: Store Warning: Response Status: "
378 << DU_cstoreStatusString(rsp.DimseStatus); 378 << DU_cstoreStatusString(rsp.DimseStatus);
379 isContinue = true; 379 isContinue = true;
380 } 380 }
381 else 381 else
382 { 382 {
383 failedCount_++; 383 failedCount_++;
384 AddFailedUIDInstance(sopInstanceUid); 384 AddFailedUIDInstance(sopInstanceUid);
385 // print a status message 385 // print a status message
386 LOG(ERROR) << "C-GET SCP: Store Failed: Response Status: " 386 CLOG(ERROR, DICOM) << "C-GET SCP: Store Failed: Response Status: "
387 << DU_cstoreStatusString(rsp.DimseStatus); 387 << DU_cstoreStatusString(rsp.DimseStatus);
388 isContinue = true; 388 isContinue = true;
389 } 389 }
390 } 390 }
391 else 391 else
392 { 392 {
393 failedCount_++; 393 failedCount_++;
394 AddFailedUIDInstance(sopInstanceUid); 394 AddFailedUIDInstance(sopInstanceUid);
395 OFString temp_str; 395 OFString temp_str;
396 LOG(ERROR) << "C-GET SCP: storeSCU: Store Request Failed: " << DimseCondition::dump(temp_str, cond); 396 CLOG(ERROR, DICOM) << "C-GET SCP: storeSCU: Store Request Failed: "
397 << DimseCondition::dump(temp_str, cond);
397 isContinue = true; 398 isContinue = true;
398 } 399 }
399 400
400 if (stDetail.get() != NULL) 401 if (stDetail.get() != NULL)
401 { 402 {
403 // with "DcmObject::PrintHelper" using MSVC2008 404 // with "DcmObject::PrintHelper" using MSVC2008
404 std::stringstream s; 405 std::stringstream s;
405 DcmObject::PrintHelper obj(*stDetail); 406 DcmObject::PrintHelper obj(*stDetail);
406 obj.dcmobj_.print(s); 407 obj.dcmobj_.print(s);
407 408
408 LOG(INFO) << " Status Detail: " << s.str(); 409 CLOG(INFO, DICOM) << " Status Detail: " << s.str();
409 } 410 }
410 411
411 return isContinue; 412 return isContinue;
412 } 413 }
413 414
461 std::vector<std::string> tmp; 462 std::vector<std::string> tmp;
462 context_.GetIndex().LookupIdentifierExact(tmp, level, tag, tokens[i]); 463 context_.GetIndex().LookupIdentifierExact(tmp, level, tag, tokens[i]);
463 464
464 if (tmp.empty()) 465 if (tmp.empty())
465 { 466 {
466 LOG(ERROR) << "C-GET: Cannot locate resource \"" << tokens[i] 467 CLOG(ERROR, DICOM) << "C-GET: Cannot locate resource \"" << tokens[i]
467 << "\" at the " << EnumerationToString(level) << " level"; 468 << "\" at the " << EnumerationToString(level) << " level";
468 return false; 469 return false;
469 } 470 }
470 else 471 else
471 { 472 {
472 for (size_t j = 0; j < tmp.size(); j++) 473 for (size_t j = 0; j < tmp.size(); j++)
479 return true; 480 return true;
480 } 481 }
481 } 482 }
482 483
483 484
484 OrthancGetRequestHandler::OrthancGetRequestHandler(ServerContext& context) : 485 OrthancGetRequestHandler::OrthancGetRequestHandler(ServerContext& context) :
485 context_(context) 486 context_(context)
486 { 487 {
487 position_ = 0; 488 position_ = 0;
488 completedCount_ = 0; 489 completedCount_ = 0;
489 warningCount_ = 0; 490 warningCount_ = 0;
490 failedCount_ = 0; 491 failedCount_ = 0;
491 timeout_ = 0; 492 timeout_ = 0;
492 } 493 }
493 494
494 495
495 bool OrthancGetRequestHandler::Handle(const DicomMap& input, 496 bool OrthancGetRequestHandler::Handle(const DicomMap& input,
496 const std::string& originatorIp, 497 const std::string& originatorIp,
497 const std::string& originatorAet, 498 const std::string& originatorAet,
498 const std::string& calledAet, 499 const std::string& calledAet,
499 uint32_t timeout) 500 uint32_t timeout)
500 { 501 {
501 MetricsRegistry::Timer timer(context_.GetMetricsRegistry(), "orthanc_get_scp_duration_ms"); 502 MetricsRegistry::Timer timer(context_.GetMetricsRegistry(), "orthanc_get_scp_duration_ms");
502 503
503 LOG(WARNING) << "C-GET-SCU request received from AET \"" << originatorAet << "\""; 504 CLOG(WARNING, DICOM) << "C-GET-SCU request received from AET \"" << originatorAet << "\"";
504 505
505 { 506 {
506 DicomArray query(input); 507 DicomArray query(input);
507 for (size_t i = 0; i < query.GetSize(); i++) 508 for (size_t i = 0; i < query.GetSize(); i++)
508 { 509 {
509 if (!query.GetElement(i).GetValue().IsNull()) 510 if (!query.GetElement(i).GetValue().IsNull())
510 { 511 {
511 LOG(INFO) << " " << query.GetElement(i).GetTag() 512 CLOG(INFO, DICOM) << " " << query.GetElement(i).GetTag()
512 << " " << FromDcmtkBridge::GetTagName(query.GetElement(i)) 513 << " " << FromDcmtkBridge::GetTagName(query.GetElement(i))
513 << " = " << query.GetElement(i).GetValue().GetContent(); 514 << " = " << query.GetElement(i).GetValue().GetContent();
514 } 515 }
515 } 516 }
516 } 517 }
517 518
518 /** 519 /**
531 532
532 std::list<std::string> publicIds; 533 std::list<std::string> publicIds;
533 534
534 if (!LookupIdentifiers(publicIds, level, input)) 535 if (!LookupIdentifiers(publicIds, level, input))
535 { 536 {
536 LOG(ERROR) << "Cannot determine what resources are requested by C-GET"; 537 CLOG(ERROR, DICOM) << "Cannot determine what resources are requested by C-GET";
537 return false; 538 return false;
538 } 539 }
539 540
540 localAet_ = context_.GetDefaultLocalApplicationEntityTitle(); 541 localAet_ = context_.GetDefaultLocalApplicationEntityTitle();
541 position_ = 0; 542 position_ = 0;
547 } 548 }
548 549
549 for (std::list<std::string>::const_iterator 550 for (std::list<std::string>::const_iterator
550 resource = publicIds.begin(); resource != publicIds.end(); ++resource) 551 resource = publicIds.begin(); resource != publicIds.end(); ++resource)
551 { 552 {
552 LOG(INFO) << "C-GET: Sending resource " << *resource 553 CLOG(INFO, DICOM) << "C-GET: Sending resource " << *resource
553 << " to modality \"" << originatorAet << "\""; 554 << " to modality \"" << originatorAet << "\"";
554 555
555 std::list<std::string> tmp; 556 std::list<std::string> tmp;
556 context_.GetIndex().GetChildInstances(tmp, *resource); 557 context_.GetIndex().GetChildInstances(tmp, *resource);
557 558
558 instances_.reserve(tmp.size()); 559 instances_.reserve(tmp.size());