comparison OrthancServer/OrthancInitialization.cpp @ 2799:6e3a60b85da6

New primitives to access Orthanc peers from plugins
author Sebastien Jodogne <s.jodogne@gmail.com>
date Wed, 22 Aug 2018 16:55:07 +0200
parents 0196d07a900f
children dc7330089736
comparison
equal deleted inserted replaced
2798:5c83e5cf9d79 2799:6e3a60b85da6
606 throw; 606 throw;
607 } 607 }
608 } 608 }
609 609
610 610
611 611 bool Configuration::GetOrthancPeer(WebServiceParameters& peer,
612 void Configuration::GetOrthancPeer(WebServiceParameters& peer,
613 const std::string& name) 612 const std::string& name)
614 { 613 {
615 boost::recursive_mutex::scoped_lock lock(globalMutex_); 614 boost::recursive_mutex::scoped_lock lock(globalMutex_);
616 615
617 if (!configuration_.isMember("OrthancPeers")) 616 if (!configuration_.isMember("OrthancPeers"))
618 { 617 {
619 LOG(ERROR) << "No peer with symbolic name: " << name; 618 return false;
620 throw OrthancException(ErrorCode_InexistentItem);
621 } 619 }
622 620
623 try 621 try
624 { 622 {
625 const Json::Value& modalities = configuration_["OrthancPeers"]; 623 const Json::Value& modalities = configuration_["OrthancPeers"];
626 if (modalities.type() != Json::objectValue || 624 if (modalities.type() != Json::objectValue ||
627 !modalities.isMember(name)) 625 !modalities.isMember(name))
628 { 626 {
629 LOG(ERROR) << "No peer with symbolic name: " << name; 627 return false;
630 throw OrthancException(ErrorCode_InexistentItem); 628 }
631 } 629 else
632 630 {
633 peer.FromJson(modalities[name]); 631 peer.FromJson(modalities[name]);
632 return true;
633 }
634 } 634 }
635 catch (OrthancException&) 635 catch (OrthancException&)
636 { 636 {
637 LOG(ERROR) << "Syntax error in the definition of peer \"" << name 637 LOG(ERROR) << "Syntax error in the definition of peer \"" << name
638 << "\". Please check your configuration file."; 638 << "\". Please check your configuration file.";