comparison OrthancServer/main.cpp @ 810:401a9633e492

configuration into a namespace
author Sebastien Jodogne <s.jodogne@gmail.com>
date Wed, 07 May 2014 16:47:56 +0200
parents 4e3593c3511d
children a811bdf8b8eb
comparison
equal deleted inserted replaced
809:8ce2f69436ca 810:401a9633e492
128 { 128 {
129 // Incoming store requests are always accepted, even from unknown AET 129 // Incoming store requests are always accepted, even from unknown AET
130 return true; 130 return true;
131 } 131 }
132 132
133 if (!IsKnownAETitle(callingAet)) 133 if (!Configuration::IsKnownAETitle(callingAet))
134 { 134 {
135 LOG(ERROR) << "Unknown remote DICOM modality AET: \"" << callingAet << "\""; 135 LOG(ERROR) << "Unknown remote DICOM modality AET: \"" << callingAet << "\"";
136 return false; 136 return false;
137 } 137 }
138 else 138 else
322 if (!isInitialized) 322 if (!isInitialized)
323 { 323 {
324 OrthancInitialize(); 324 OrthancInitialize();
325 } 325 }
326 326
327 std::string storageDirectoryStr = GetGlobalStringParameter("StorageDirectory", "OrthancStorage"); 327 std::string storageDirectoryStr = Configuration::GetGlobalStringParameter("StorageDirectory", "OrthancStorage");
328 boost::filesystem::path storageDirectory = InterpretStringParameterAsPath(storageDirectoryStr); 328 boost::filesystem::path storageDirectory = Configuration::InterpretStringParameterAsPath(storageDirectoryStr);
329 boost::filesystem::path indexDirectory = 329 boost::filesystem::path indexDirectory = Configuration::InterpretStringParameterAsPath(
330 InterpretStringParameterAsPath(GetGlobalStringParameter("IndexDirectory", storageDirectoryStr)); 330 Configuration::GetGlobalStringParameter("IndexDirectory", storageDirectoryStr));
331 ServerContext context(storageDirectory, indexDirectory); 331 ServerContext context(storageDirectory, indexDirectory);
332 332
333 LOG(WARNING) << "Storage directory: " << storageDirectory; 333 LOG(WARNING) << "Storage directory: " << storageDirectory;
334 LOG(WARNING) << "Index directory: " << indexDirectory; 334 LOG(WARNING) << "Index directory: " << indexDirectory;
335 335
336 context.SetCompressionEnabled(GetGlobalBoolParameter("StorageCompression", false)); 336 context.SetCompressionEnabled(Configuration::GetGlobalBoolParameter("StorageCompression", false));
337 context.SetStoreMD5ForAttachments(GetGlobalBoolParameter("StoreMD5ForAttachments", true)); 337 context.SetStoreMD5ForAttachments(Configuration::GetGlobalBoolParameter("StoreMD5ForAttachments", true));
338 338
339 std::list<std::string> luaScripts; 339 std::list<std::string> luaScripts;
340 GetGlobalListOfStringsParameter(luaScripts, "LuaScripts"); 340 Configuration::GetGlobalListOfStringsParameter(luaScripts, "LuaScripts");
341 for (std::list<std::string>::const_iterator 341 for (std::list<std::string>::const_iterator
342 it = luaScripts.begin(); it != luaScripts.end(); ++it) 342 it = luaScripts.begin(); it != luaScripts.end(); ++it)
343 { 343 {
344 std::string path = InterpretStringParameterAsPath(*it); 344 std::string path = Configuration::InterpretStringParameterAsPath(*it);
345 LOG(WARNING) << "Installing the Lua scripts from: " << path; 345 LOG(WARNING) << "Installing the Lua scripts from: " << path;
346 std::string script; 346 std::string script;
347 Toolbox::ReadFile(script, path); 347 Toolbox::ReadFile(script, path);
348 context.GetLuaContext().Execute(script); 348 context.GetLuaContext().Execute(script);
349 } 349 }
350 350
351 351
352 try 352 try
353 { 353 {
354 context.GetIndex().SetMaximumPatientCount(GetGlobalIntegerParameter("MaximumPatientCount", 0)); 354 context.GetIndex().SetMaximumPatientCount(Configuration::GetGlobalIntegerParameter("MaximumPatientCount", 0));
355 } 355 }
356 catch (...) 356 catch (...)
357 { 357 {
358 context.GetIndex().SetMaximumPatientCount(0); 358 context.GetIndex().SetMaximumPatientCount(0);
359 } 359 }
360 360
361 try 361 try
362 { 362 {
363 uint64_t size = GetGlobalIntegerParameter("MaximumStorageSize", 0); 363 uint64_t size = Configuration::GetGlobalIntegerParameter("MaximumStorageSize", 0);
364 context.GetIndex().SetMaximumStorageSize(size * 1024 * 1024); 364 context.GetIndex().SetMaximumStorageSize(size * 1024 * 1024);
365 } 365 }
366 catch (...) 366 catch (...)
367 { 367 {
368 context.GetIndex().SetMaximumStorageSize(0); 368 context.GetIndex().SetMaximumStorageSize(0);
372 372
373 { 373 {
374 // DICOM server 374 // DICOM server
375 DicomServer dicomServer; 375 DicomServer dicomServer;
376 OrthancApplicationEntityFilter dicomFilter; 376 OrthancApplicationEntityFilter dicomFilter;
377 dicomServer.SetCalledApplicationEntityTitleCheck(GetGlobalBoolParameter("DicomCheckCalledAet", false)); 377 dicomServer.SetCalledApplicationEntityTitleCheck(Configuration::GetGlobalBoolParameter("DicomCheckCalledAet", false));
378 dicomServer.SetStoreRequestHandlerFactory(serverFactory); 378 dicomServer.SetStoreRequestHandlerFactory(serverFactory);
379 dicomServer.SetMoveRequestHandlerFactory(serverFactory); 379 dicomServer.SetMoveRequestHandlerFactory(serverFactory);
380 dicomServer.SetFindRequestHandlerFactory(serverFactory); 380 dicomServer.SetFindRequestHandlerFactory(serverFactory);
381 dicomServer.SetPortNumber(GetGlobalIntegerParameter("DicomPort", 4242)); 381 dicomServer.SetPortNumber(Configuration::GetGlobalIntegerParameter("DicomPort", 4242));
382 dicomServer.SetApplicationEntityTitle(GetGlobalStringParameter("DicomAet", "ORTHANC")); 382 dicomServer.SetApplicationEntityTitle(Configuration::GetGlobalStringParameter("DicomAet", "ORTHANC"));
383 dicomServer.SetApplicationEntityFilter(dicomFilter); 383 dicomServer.SetApplicationEntityFilter(dicomFilter);
384 384
385 // HTTP server 385 // HTTP server
386 MyIncomingHttpRequestFilter httpFilter(context); 386 MyIncomingHttpRequestFilter httpFilter(context);
387 MongooseServer httpServer; 387 MongooseServer httpServer;
388 httpServer.SetPortNumber(GetGlobalIntegerParameter("HttpPort", 8042)); 388 httpServer.SetPortNumber(Configuration::GetGlobalIntegerParameter("HttpPort", 8042));
389 httpServer.SetRemoteAccessAllowed(GetGlobalBoolParameter("RemoteAccessAllowed", false)); 389 httpServer.SetRemoteAccessAllowed(Configuration::GetGlobalBoolParameter("RemoteAccessAllowed", false));
390 httpServer.SetIncomingHttpRequestFilter(httpFilter); 390 httpServer.SetIncomingHttpRequestFilter(httpFilter);
391 391
392 httpServer.SetAuthenticationEnabled(GetGlobalBoolParameter("AuthenticationEnabled", false)); 392 httpServer.SetAuthenticationEnabled(Configuration::GetGlobalBoolParameter("AuthenticationEnabled", false));
393 SetupRegisteredUsers(httpServer); 393 Configuration::SetupRegisteredUsers(httpServer);
394 394
395 if (GetGlobalBoolParameter("SslEnabled", false)) 395 if (Configuration::GetGlobalBoolParameter("SslEnabled", false))
396 { 396 {
397 std::string certificate = 397 std::string certificate = Configuration::InterpretStringParameterAsPath(
398 InterpretStringParameterAsPath(GetGlobalStringParameter("SslCertificate", "certificate.pem")); 398 Configuration::GetGlobalStringParameter("SslCertificate", "certificate.pem"));
399 httpServer.SetSslEnabled(true); 399 httpServer.SetSslEnabled(true);
400 httpServer.SetSslCertificate(certificate.c_str()); 400 httpServer.SetSslCertificate(certificate.c_str());
401 } 401 }
402 else 402 else
403 { 403 {
411 #endif 411 #endif
412 412
413 httpServer.RegisterHandler(new OrthancRestApi(context)); 413 httpServer.RegisterHandler(new OrthancRestApi(context));
414 414
415 // GO !!! Start the requested servers 415 // GO !!! Start the requested servers
416 if (GetGlobalBoolParameter("HttpServerEnabled", true)) 416 if (Configuration::GetGlobalBoolParameter("HttpServerEnabled", true))
417 { 417 {
418 httpServer.Start(); 418 httpServer.Start();
419 LOG(WARNING) << "HTTP server listening on port: " << httpServer.GetPortNumber(); 419 LOG(WARNING) << "HTTP server listening on port: " << httpServer.GetPortNumber();
420 } 420 }
421 else 421 else
422 { 422 {
423 LOG(WARNING) << "The HTTP server is disabled"; 423 LOG(WARNING) << "The HTTP server is disabled";
424 } 424 }
425 425
426 if (GetGlobalBoolParameter("DicomServerEnabled", true)) 426 if (Configuration::GetGlobalBoolParameter("DicomServerEnabled", true))
427 { 427 {
428 dicomServer.Start(); 428 dicomServer.Start();
429 LOG(WARNING) << "DICOM server listening on port: " << dicomServer.GetPortNumber(); 429 LOG(WARNING) << "DICOM server listening on port: " << dicomServer.GetPortNumber();
430 } 430 }
431 else 431 else