comparison OrthancServer/main.cpp @ 758:67e6400fca03 query-retrieve

integration mainline -> query-retrieve
author Sebastien Jodogne <s.jodogne@gmail.com>
date Wed, 16 Apr 2014 16:34:09 +0200
parents 3bdb5db8e839 4afad8cb94fd
children c2c28dd17e87
comparison
equal deleted inserted replaced
681:3bdb5db8e839 758:67e6400fca03
1 /** 1 /**
2 * Orthanc - A Lightweight, RESTful DICOM Store 2 * Orthanc - A Lightweight, RESTful DICOM Store
3 * Copyright (C) 2012-2013 Medical Physics Department, CHU of Liege, 3 * Copyright (C) 2012-2014 Medical Physics Department, CHU of Liege,
4 * Belgium 4 * Belgium
5 * 5 *
6 * This program is free software: you can redistribute it and/or 6 * This program is free software: you can redistribute it and/or
7 * modify it under the terms of the GNU General Public License as 7 * modify it under the terms of the GNU General Public License as
8 * published by the Free Software Foundation, either version 3 of the 8 * published by the Free Software Foundation, either version 3 of the
28 * You should have received a copy of the GNU General Public License 28 * You should have received a copy of the GNU General Public License
29 * along with this program. If not, see <http://www.gnu.org/licenses/>. 29 * along with this program. If not, see <http://www.gnu.org/licenses/>.
30 **/ 30 **/
31 31
32 32
33 #include "OrthancRestApi.h" 33 #include "OrthancRestApi/OrthancRestApi.h"
34 34
35 #include <fstream> 35 #include <fstream>
36 #include <glog/logging.h> 36 #include <glog/logging.h>
37 #include <boost/algorithm/string/predicate.hpp> 37 #include <boost/algorithm/string/predicate.hpp>
38 38
44 #include "DicomProtocol/DicomUserConnection.h" 44 #include "DicomProtocol/DicomUserConnection.h"
45 #include "OrthancInitialization.h" 45 #include "OrthancInitialization.h"
46 #include "ServerContext.h" 46 #include "ServerContext.h"
47 #include "OrthancFindRequestHandler.h" 47 #include "OrthancFindRequestHandler.h"
48 #include "OrthancMoveRequestHandler.h" 48 #include "OrthancMoveRequestHandler.h"
49 #include "ServerToolbox.h"
49 50
50 using namespace Orthanc; 51 using namespace Orthanc;
51 52
52 53
53 54
129 return true; 130 return true;
130 } 131 }
131 132
132 if (!IsKnownAETitle(callingAet)) 133 if (!IsKnownAETitle(callingAet))
133 { 134 {
134 LOG(ERROR) << "Unkwnown remote DICOM modality AET: \"" << callingAet << "\""; 135 LOG(ERROR) << "Unknown remote DICOM modality AET: \"" << callingAet << "\"";
135 return false; 136 return false;
136 } 137 }
137 else 138 else
138 { 139 {
139 return true; 140 return true;
231 232
232 void PrintVersion(char* path) 233 void PrintVersion(char* path)
233 { 234 {
234 std::cout 235 std::cout
235 << path << " " << ORTHANC_VERSION << std::endl 236 << path << " " << ORTHANC_VERSION << std::endl
236 << "Copyright (C) 2012-2013 Medical Physics Department, CHU of Liege (Belgium) " << std::endl 237 << "Copyright (C) 2012-2014 Medical Physics Department, CHU of Liege (Belgium) " << std::endl
237 << "Licensing GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>, with OpenSSL exception." << std::endl 238 << "Licensing GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>, with OpenSSL exception." << std::endl
238 << "This is free software: you are free to change and redistribute it." << std::endl 239 << "This is free software: you are free to change and redistribute it." << std::endl
239 << "There is NO WARRANTY, to the extent permitted by law." << std::endl 240 << "There is NO WARRANTY, to the extent permitted by law." << std::endl
240 << std::endl 241 << std::endl
241 << "Written by Sebastien Jodogne <s.jodogne@gmail.com>" << std::endl; 242 << "Written by Sebastien Jodogne <s.jodogne@gmail.com>" << std::endl;
282 283
283 if (boost::starts_with(argv[i], "--config=")) 284 if (boost::starts_with(argv[i], "--config="))
284 { 285 {
285 std::string configurationSample; 286 std::string configurationSample;
286 GetFileResource(configurationSample, EmbeddedResources::CONFIGURATION_SAMPLE); 287 GetFileResource(configurationSample, EmbeddedResources::CONFIGURATION_SAMPLE);
288
289 #if defined(_WIN32)
290 // Replace UNIX newlines with DOS newlines
291 boost::replace_all(configurationSample, "\n", "\r\n");
292 #endif
287 293
288 std::string target = std::string(argv[i]).substr(9); 294 std::string target = std::string(argv[i]).substr(9);
289 std::ofstream f(target.c_str()); 295 std::ofstream f(target.c_str());
290 f << configurationSample; 296 f << configurationSample;
291 f.close(); 297 f.close();
326 332
327 LOG(WARNING) << "Storage directory: " << storageDirectory; 333 LOG(WARNING) << "Storage directory: " << storageDirectory;
328 LOG(WARNING) << "Index directory: " << indexDirectory; 334 LOG(WARNING) << "Index directory: " << indexDirectory;
329 335
330 context.SetCompressionEnabled(GetGlobalBoolParameter("StorageCompression", false)); 336 context.SetCompressionEnabled(GetGlobalBoolParameter("StorageCompression", false));
337 context.SetStoreMD5ForAttachments(GetGlobalBoolParameter("StoreMD5ForAttachments", true));
331 338
332 std::list<std::string> luaScripts; 339 std::list<std::string> luaScripts;
333 GetGlobalListOfStringsParameter(luaScripts, "LuaScripts"); 340 GetGlobalListOfStringsParameter(luaScripts, "LuaScripts");
334 for (std::list<std::string>::const_iterator 341 for (std::list<std::string>::const_iterator
335 it = luaScripts.begin(); it != luaScripts.end(); ++it) 342 it = luaScripts.begin(); it != luaScripts.end(); ++it)
395 else 402 else
396 { 403 {
397 httpServer.SetSslEnabled(false); 404 httpServer.SetSslEnabled(false);
398 } 405 }
399 406
400 LOG(WARNING) << "DICOM server listening on port: " << dicomServer.GetPortNumber();
401 LOG(WARNING) << "HTTP server listening on port: " << httpServer.GetPortNumber();
402
403 #if ORTHANC_STANDALONE == 1 407 #if ORTHANC_STANDALONE == 1
404 httpServer.RegisterHandler(new EmbeddedResourceHttpHandler("/app", EmbeddedResources::ORTHANC_EXPLORER)); 408 httpServer.RegisterHandler(new EmbeddedResourceHttpHandler("/app", EmbeddedResources::ORTHANC_EXPLORER));
405 #else 409 #else
406 httpServer.RegisterHandler(new FilesystemHttpHandler("/app", ORTHANC_PATH "/OrthancExplorer")); 410 httpServer.RegisterHandler(new FilesystemHttpHandler("/app", ORTHANC_PATH "/OrthancExplorer"));
407 #endif 411 #endif
408 412
409 httpServer.RegisterHandler(new OrthancRestApi(context)); 413 httpServer.RegisterHandler(new OrthancRestApi(context));
410 414
411 // GO !!! 415 // GO !!! Start the requested servers
412 httpServer.Start(); 416 if (GetGlobalBoolParameter("HttpServerEnabled", true))
413 dicomServer.Start(); 417 {
418 httpServer.Start();
419 LOG(WARNING) << "HTTP server listening on port: " << httpServer.GetPortNumber();
420 }
421 else
422 {
423 LOG(WARNING) << "The HTTP server is disabled";
424 }
425
426 if (GetGlobalBoolParameter("DicomServerEnabled", true))
427 {
428 dicomServer.Start();
429 LOG(WARNING) << "DICOM server listening on port: " << dicomServer.GetPortNumber();
430 }
431 else
432 {
433 LOG(WARNING) << "The DICOM server is disabled";
434 }
414 435
415 436
416 { 437 {
417 DicomUserConnection c; 438 DicomUserConnection c;
418 c.SetLocalApplicationEntityTitle("ORTHANC"); 439 c.SetLocalApplicationEntityTitle("ORTHANC");
436 457
437 458
438 LOG(WARNING) << "Orthanc has started"; 459 LOG(WARNING) << "Orthanc has started";
439 Toolbox::ServerBarrier(); 460 Toolbox::ServerBarrier();
440 461
441 // Stop 462 // We're done
442 LOG(WARNING) << "Orthanc is stopping"; 463 LOG(WARNING) << "Orthanc is stopping";
443 } 464 }
444 465
445 serverFactory.Done(); 466 serverFactory.Done();
446 } 467 }
455 status = -1; 476 status = -1;
456 } 477 }
457 478
458 OrthancFinalize(); 479 OrthancFinalize();
459 480
481 LOG(WARNING) << "Orthanc has stopped";
482
460 return status; 483 return status;
461 } 484 }