comparison OrthancServer/main.cpp @ 407:2d269089078f

reintegration of lua scripting into mainline
author Sebastien Jodogne <s.jodogne@gmail.com>
date Thu, 02 May 2013 16:49:28 +0200
parents 4d5f0857ec9c 941ea46e9e26
children 63f707278fc8
comparison
equal deleted inserted replaced
406:fb1d988a978b 407:2d269089078f
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
39 #include "../Core/HttpServer/EmbeddedResourceHttpHandler.h" 39 #include "../Core/HttpServer/EmbeddedResourceHttpHandler.h"
40 #include "../Core/HttpServer/FilesystemHttpHandler.h" 40 #include "../Core/HttpServer/FilesystemHttpHandler.h"
41 #include "../Core/HttpServer/MongooseServer.h" 41 #include "../Core/Lua/LuaFunctionCall.h"
42 #include "../Core/DicomFormat/DicomArray.h" 42 #include "../Core/DicomFormat/DicomArray.h"
43 #include "DicomProtocol/DicomServer.h" 43 #include "DicomProtocol/DicomServer.h"
44 #include "OrthancInitialization.h" 44 #include "OrthancInitialization.h"
45 #include "ServerContext.h" 45 #include "ServerContext.h"
46 46
49 49
50 50
51 class MyStoreRequestHandler : public IStoreRequestHandler 51 class MyStoreRequestHandler : public IStoreRequestHandler
52 { 52 {
53 private: 53 private:
54 ServerContext& context_; 54 ServerContext& server_;
55 55
56 public: 56 public:
57 MyStoreRequestHandler(ServerContext& context) : 57 MyStoreRequestHandler(ServerContext& context) :
58 context_(context) 58 server_(context)
59 { 59 {
60 } 60 }
61 61
62 virtual void Handle(const std::string& dicomFile, 62 virtual void Handle(const std::string& dicomFile,
63 const DicomMap& dicomSummary, 63 const DicomMap& dicomSummary,
64 const Json::Value& dicomJson, 64 const Json::Value& dicomJson,
65 const std::string& remoteAet) 65 const std::string& remoteAet)
66 { 66 {
67 if (dicomFile.size() > 0) 67 if (dicomFile.size() > 0)
68 { 68 {
69 context_.Store(&dicomFile[0], dicomFile.size(), dicomSummary, dicomJson, remoteAet); 69 server_.Store(&dicomFile[0], dicomFile.size(), dicomSummary, dicomJson, remoteAet);
70 } 70 }
71 } 71 }
72 }; 72 };
73 73
74 74
262 if (!isInitialized) 262 if (!isInitialized)
263 { 263 {
264 OrthancInitialize(); 264 OrthancInitialize();
265 } 265 }
266 266
267 boost::filesystem::path storageDirectory = GetGlobalStringParameter("StorageDirectory", "OrthancStorage"); 267 boost::filesystem::path storageDirectory =
268 boost::filesystem::path indexDirectory = GetGlobalStringParameter("IndexDirectory", storageDirectory.string()); 268 InterpretStringParameterAsPath(GetGlobalStringParameter("StorageDirectory", "OrthancStorage"));
269 boost::filesystem::path indexDirectory =
270 InterpretStringParameterAsPath(GetGlobalStringParameter("IndexDirectory", storageDirectory.string()));
269 ServerContext context(storageDirectory, indexDirectory); 271 ServerContext context(storageDirectory, indexDirectory);
270 272
271 LOG(WARNING) << "Storage directory: " << storageDirectory; 273 LOG(WARNING) << "Storage directory: " << storageDirectory;
272 LOG(WARNING) << "Index directory: " << indexDirectory; 274 LOG(WARNING) << "Index directory: " << indexDirectory;
273 275
274 context.SetCompressionEnabled(GetGlobalBoolParameter("StorageCompression", false)); 276 context.SetCompressionEnabled(GetGlobalBoolParameter("StorageCompression", false));
277
278 std::list<std::string> luaScripts;
279 GetGlobalListOfStringsParameter(luaScripts, "LuaScripts");
280 for (std::list<std::string>::const_iterator
281 it = luaScripts.begin(); it != luaScripts.end(); it++)
282 {
283 std::string path = InterpretStringParameterAsPath(*it);
284 LOG(WARNING) << "Installing the Lua scripts from: " << path;
285 std::string script;
286 Toolbox::ReadFile(script, path);
287 context.GetLuaContext().Execute(script);
288 }
289
275 290
276 try 291 try
277 { 292 {
278 context.GetIndex().SetMaximumPatientCount(GetGlobalIntegerParameter("MaximumPatientCount", 0)); 293 context.GetIndex().SetMaximumPatientCount(GetGlobalIntegerParameter("MaximumPatientCount", 0));
279 } 294 }
313 httpServer.SetAuthenticationEnabled(GetGlobalBoolParameter("AuthenticationEnabled", false)); 328 httpServer.SetAuthenticationEnabled(GetGlobalBoolParameter("AuthenticationEnabled", false));
314 SetupRegisteredUsers(httpServer); 329 SetupRegisteredUsers(httpServer);
315 330
316 if (GetGlobalBoolParameter("SslEnabled", false)) 331 if (GetGlobalBoolParameter("SslEnabled", false))
317 { 332 {
318 std::string certificate = GetGlobalStringParameter("SslCertificate", "certificate.pem"); 333 std::string certificate =
334 InterpretStringParameterAsPath(GetGlobalStringParameter("SslCertificate", "certificate.pem"));
319 httpServer.SetSslEnabled(true); 335 httpServer.SetSslEnabled(true);
320 httpServer.SetSslCertificate(certificate.c_str()); 336 httpServer.SetSslCertificate(certificate.c_str());
321 } 337 }
322 else 338 else
323 { 339 {