comparison OrthancServer/OrthancInitialization.cpp @ 1366:a3559b66fba7 query-retrieve

move primitives
author Sebastien Jodogne <s.jodogne@gmail.com>
date Fri, 22 May 2015 16:17:28 +0200
parents 59b603763f43
children 52b2070fc8f1
comparison
equal deleted inserted replaced
1365:38ce915cb455 1366:a3559b66fba7
236 std::string Configuration::GetGlobalStringParameter(const std::string& parameter, 236 std::string Configuration::GetGlobalStringParameter(const std::string& parameter,
237 const std::string& defaultValue) 237 const std::string& defaultValue)
238 { 238 {
239 boost::mutex::scoped_lock lock(globalMutex_); 239 boost::mutex::scoped_lock lock(globalMutex_);
240 240
241 if (configuration_->isMember(parameter)) 241 if (configuration_.get() != NULL &&
242 configuration_->isMember(parameter))
242 { 243 {
243 return (*configuration_) [parameter].asString(); 244 return (*configuration_) [parameter].asString();
244 } 245 }
245 else 246 else
246 { 247 {
252 int Configuration::GetGlobalIntegerParameter(const std::string& parameter, 253 int Configuration::GetGlobalIntegerParameter(const std::string& parameter,
253 int defaultValue) 254 int defaultValue)
254 { 255 {
255 boost::mutex::scoped_lock lock(globalMutex_); 256 boost::mutex::scoped_lock lock(globalMutex_);
256 257
257 if (configuration_->isMember(parameter)) 258 if (configuration_.get() != NULL &&
259 configuration_->isMember(parameter))
258 { 260 {
259 return (*configuration_) [parameter].asInt(); 261 return (*configuration_) [parameter].asInt();
260 } 262 }
261 else 263 else
262 { 264 {
268 bool Configuration::GetGlobalBoolParameter(const std::string& parameter, 270 bool Configuration::GetGlobalBoolParameter(const std::string& parameter,
269 bool defaultValue) 271 bool defaultValue)
270 { 272 {
271 boost::mutex::scoped_lock lock(globalMutex_); 273 boost::mutex::scoped_lock lock(globalMutex_);
272 274
273 if (configuration_->isMember(parameter)) 275 if (configuration_.get() != NULL &&
276 configuration_->isMember(parameter))
274 { 277 {
275 return (*configuration_) [parameter].asBool(); 278 return (*configuration_) [parameter].asBool();
276 } 279 }
277 else 280 else
278 { 281 {
284 void Configuration::GetDicomModalityUsingSymbolicName(RemoteModalityParameters& modality, 287 void Configuration::GetDicomModalityUsingSymbolicName(RemoteModalityParameters& modality,
285 const std::string& name) 288 const std::string& name)
286 { 289 {
287 boost::mutex::scoped_lock lock(globalMutex_); 290 boost::mutex::scoped_lock lock(globalMutex_);
288 291
292 if (configuration_.get() == NULL)
293 {
294 throw OrthancException(ErrorCode_InexistentItem);
295 }
296
289 if (!configuration_->isMember("DicomModalities")) 297 if (!configuration_->isMember("DicomModalities"))
290 { 298 {
291 throw OrthancException(ErrorCode_BadFileFormat); 299 throw OrthancException(ErrorCode_BadFileFormat);
292 } 300 }
293 301
316 void Configuration::GetOrthancPeer(OrthancPeerParameters& peer, 324 void Configuration::GetOrthancPeer(OrthancPeerParameters& peer,
317 const std::string& name) 325 const std::string& name)
318 { 326 {
319 boost::mutex::scoped_lock lock(globalMutex_); 327 boost::mutex::scoped_lock lock(globalMutex_);
320 328
329 if (configuration_.get() == NULL)
330 {
331 throw OrthancException(ErrorCode_InexistentItem);
332 }
333
321 if (!configuration_->isMember("OrthancPeers")) 334 if (!configuration_->isMember("OrthancPeers"))
322 { 335 {
323 throw OrthancException(ErrorCode_BadFileFormat); 336 throw OrthancException(ErrorCode_BadFileFormat);
324 } 337 }
325 338
350 { 363 {
351 boost::mutex::scoped_lock lock(globalMutex_); 364 boost::mutex::scoped_lock lock(globalMutex_);
352 365
353 target.clear(); 366 target.clear();
354 367
355 if (!configuration_->isMember(parameter)) 368 if (configuration_.get() == NULL ||
369 !configuration_->isMember(parameter))
356 { 370 {
357 return true; 371 return true;
358 } 372 }
359 373
360 const Json::Value& modalities = (*configuration_) [parameter]; 374 const Json::Value& modalities = (*configuration_) [parameter];
407 { 421 {
408 boost::mutex::scoped_lock lock(globalMutex_); 422 boost::mutex::scoped_lock lock(globalMutex_);
409 423
410 httpServer.ClearUsers(); 424 httpServer.ClearUsers();
411 425
412 if (!configuration_->isMember("RegisteredUsers")) 426 if (configuration_.get() == NULL ||
427 !configuration_->isMember("RegisteredUsers"))
413 { 428 {
414 return; 429 return;
415 } 430 }
416 431
417 const Json::Value& users = (*configuration_) ["RegisteredUsers"]; 432 const Json::Value& users = (*configuration_) ["RegisteredUsers"];
468 { 483 {
469 boost::mutex::scoped_lock lock(globalMutex_); 484 boost::mutex::scoped_lock lock(globalMutex_);
470 485
471 target.clear(); 486 target.clear();
472 487
473 if (!configuration_->isMember(key)) 488 if (configuration_.get() == NULL ||
489 !configuration_->isMember(key))
474 { 490 {
475 return; 491 return;
476 } 492 }
477 493
478 const Json::Value& lst = (*configuration_) [key]; 494 const Json::Value& lst = (*configuration_) [key];
569 void Configuration::UpdateModality(const std::string& symbolicName, 585 void Configuration::UpdateModality(const std::string& symbolicName,
570 const RemoteModalityParameters& modality) 586 const RemoteModalityParameters& modality)
571 { 587 {
572 boost::mutex::scoped_lock lock(globalMutex_); 588 boost::mutex::scoped_lock lock(globalMutex_);
573 589
590 if (configuration_.get() == NULL)
591 {
592 throw OrthancException(ErrorCode_InternalError);
593 }
594
574 if (!configuration_->isMember("DicomModalities")) 595 if (!configuration_->isMember("DicomModalities"))
575 { 596 {
576 (*configuration_) ["DicomModalities"] = Json::objectValue; 597 (*configuration_) ["DicomModalities"] = Json::objectValue;
577 } 598 }
578 599
592 613
593 void Configuration::RemoveModality(const std::string& symbolicName) 614 void Configuration::RemoveModality(const std::string& symbolicName)
594 { 615 {
595 boost::mutex::scoped_lock lock(globalMutex_); 616 boost::mutex::scoped_lock lock(globalMutex_);
596 617
618 if (configuration_.get() == NULL)
619 {
620 throw OrthancException(ErrorCode_InternalError);
621 }
622
597 if (!configuration_->isMember("DicomModalities")) 623 if (!configuration_->isMember("DicomModalities"))
598 { 624 {
599 throw OrthancException(ErrorCode_BadFileFormat); 625 throw OrthancException(ErrorCode_BadFileFormat);
600 } 626 }
601 627
611 637
612 void Configuration::UpdatePeer(const std::string& symbolicName, 638 void Configuration::UpdatePeer(const std::string& symbolicName,
613 const OrthancPeerParameters& peer) 639 const OrthancPeerParameters& peer)
614 { 640 {
615 boost::mutex::scoped_lock lock(globalMutex_); 641 boost::mutex::scoped_lock lock(globalMutex_);
642
643 if (configuration_.get() == NULL)
644 {
645 throw OrthancException(ErrorCode_InternalError);
646 }
616 647
617 if (!configuration_->isMember("OrthancPeers")) 648 if (!configuration_->isMember("OrthancPeers"))
618 { 649 {
619 (*configuration_) ["OrthancPeers"] = Json::objectValue; 650 (*configuration_) ["OrthancPeers"] = Json::objectValue;
620 } 651 }
634 665
635 666
636 void Configuration::RemovePeer(const std::string& symbolicName) 667 void Configuration::RemovePeer(const std::string& symbolicName)
637 { 668 {
638 boost::mutex::scoped_lock lock(globalMutex_); 669 boost::mutex::scoped_lock lock(globalMutex_);
670
671 if (configuration_.get() == NULL)
672 {
673 throw OrthancException(ErrorCode_InternalError);
674 }
639 675
640 if (!configuration_->isMember("OrthancPeers")) 676 if (!configuration_->isMember("OrthancPeers"))
641 { 677 {
642 throw OrthancException(ErrorCode_BadFileFormat); 678 throw OrthancException(ErrorCode_BadFileFormat);
643 } 679 }