Mercurial > hg > orthanc
annotate OrthancServer/LuaScripting.cpp @ 1592:d73124f6b439
configuration option HttpDescribeErrors
author | Sebastien Jodogne <s.jodogne@gmail.com> |
---|---|
date | Thu, 27 Aug 2015 11:35:16 +0200 |
parents | d7e569640d09 |
children | 54bafe0e7e7b |
rev | line source |
---|---|
1433
461e7554bff7
refactoring: LuaScripting
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1 /** |
461e7554bff7
refactoring: LuaScripting
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
2 * Orthanc - A Lightweight, RESTful DICOM Store |
461e7554bff7
refactoring: LuaScripting
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
3 * Copyright (C) 2012-2015 Sebastien Jodogne, Medical Physics |
461e7554bff7
refactoring: LuaScripting
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
4 * Department, University Hospital of Liege, Belgium |
461e7554bff7
refactoring: LuaScripting
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
5 * |
461e7554bff7
refactoring: LuaScripting
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
6 * This program is free software: you can redistribute it and/or |
461e7554bff7
refactoring: LuaScripting
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
7 * modify it under the terms of the GNU General Public License as |
461e7554bff7
refactoring: LuaScripting
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
8 * published by the Free Software Foundation, either version 3 of the |
461e7554bff7
refactoring: LuaScripting
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
9 * License, or (at your option) any later version. |
461e7554bff7
refactoring: LuaScripting
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
10 * |
461e7554bff7
refactoring: LuaScripting
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
11 * In addition, as a special exception, the copyright holders of this |
461e7554bff7
refactoring: LuaScripting
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
12 * program give permission to link the code of its release with the |
461e7554bff7
refactoring: LuaScripting
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
13 * OpenSSL project's "OpenSSL" library (or with modified versions of it |
461e7554bff7
refactoring: LuaScripting
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
14 * that use the same license as the "OpenSSL" library), and distribute |
461e7554bff7
refactoring: LuaScripting
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
15 * the linked executables. You must obey the GNU General Public License |
461e7554bff7
refactoring: LuaScripting
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
16 * in all respects for all of the code used other than "OpenSSL". If you |
461e7554bff7
refactoring: LuaScripting
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
17 * modify file(s) with this exception, you may extend this exception to |
461e7554bff7
refactoring: LuaScripting
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
18 * your version of the file(s), but you are not obligated to do so. If |
461e7554bff7
refactoring: LuaScripting
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
19 * you do not wish to do so, delete this exception statement from your |
461e7554bff7
refactoring: LuaScripting
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
20 * version. If you delete this exception statement from all source files |
461e7554bff7
refactoring: LuaScripting
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
21 * in the program, then also delete it here. |
461e7554bff7
refactoring: LuaScripting
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
22 * |
461e7554bff7
refactoring: LuaScripting
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
23 * This program is distributed in the hope that it will be useful, but |
461e7554bff7
refactoring: LuaScripting
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
24 * WITHOUT ANY WARRANTY; without even the implied warranty of |
461e7554bff7
refactoring: LuaScripting
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
25 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
461e7554bff7
refactoring: LuaScripting
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
26 * General Public License for more details. |
461e7554bff7
refactoring: LuaScripting
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
27 * |
461e7554bff7
refactoring: LuaScripting
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
28 * You should have received a copy of the GNU General Public License |
461e7554bff7
refactoring: LuaScripting
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
29 * along with this program. If not, see <http://www.gnu.org/licenses/>. |
461e7554bff7
refactoring: LuaScripting
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
30 **/ |
461e7554bff7
refactoring: LuaScripting
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
31 |
461e7554bff7
refactoring: LuaScripting
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
32 |
461e7554bff7
refactoring: LuaScripting
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
33 #include "PrecompiledHeadersServer.h" |
461e7554bff7
refactoring: LuaScripting
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
34 #include "LuaScripting.h" |
461e7554bff7
refactoring: LuaScripting
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
35 |
461e7554bff7
refactoring: LuaScripting
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
36 #include "ServerContext.h" |
461e7554bff7
refactoring: LuaScripting
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
37 #include "OrthancInitialization.h" |
461e7554bff7
refactoring: LuaScripting
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
38 #include "../Core/Lua/LuaFunctionCall.h" |
1437
02f5a3f5c0a0
access to the REST API from Lua
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1436
diff
changeset
|
39 #include "../Core/HttpServer/StringHttpOutput.h" |
1486
f967bdf8534e
refactoring to Logging.h
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1465
diff
changeset
|
40 #include "../Core/Logging.h" |
1433
461e7554bff7
refactoring: LuaScripting
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
41 |
461e7554bff7
refactoring: LuaScripting
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
42 #include "Scheduler/DeleteInstanceCommand.h" |
461e7554bff7
refactoring: LuaScripting
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
43 #include "Scheduler/StoreScuCommand.h" |
461e7554bff7
refactoring: LuaScripting
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
44 #include "Scheduler/StorePeerCommand.h" |
461e7554bff7
refactoring: LuaScripting
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
45 #include "Scheduler/ModifyInstanceCommand.h" |
461e7554bff7
refactoring: LuaScripting
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
46 #include "Scheduler/CallSystemCommand.h" |
461e7554bff7
refactoring: LuaScripting
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
47 #include "OrthancRestApi/OrthancRestApi.h" |
461e7554bff7
refactoring: LuaScripting
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
48 |
461e7554bff7
refactoring: LuaScripting
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
49 #include <EmbeddedResources.h> |
461e7554bff7
refactoring: LuaScripting
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
50 |
461e7554bff7
refactoring: LuaScripting
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
51 |
461e7554bff7
refactoring: LuaScripting
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
52 namespace Orthanc |
461e7554bff7
refactoring: LuaScripting
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
53 { |
1444
b2b09a3dbd8e
refactoring: OrthancHttpHandler inside OrthancServer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1441
diff
changeset
|
54 ServerContext* LuaScripting::GetServerContext(lua_State *state) |
1437
02f5a3f5c0a0
access to the REST API from Lua
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1436
diff
changeset
|
55 { |
1444
b2b09a3dbd8e
refactoring: OrthancHttpHandler inside OrthancServer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1441
diff
changeset
|
56 const void* value = LuaContext::GetGlobalVariable(state, "_ServerContext"); |
b2b09a3dbd8e
refactoring: OrthancHttpHandler inside OrthancServer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1441
diff
changeset
|
57 return const_cast<ServerContext*>(reinterpret_cast<const ServerContext*>(value)); |
1437
02f5a3f5c0a0
access to the REST API from Lua
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1436
diff
changeset
|
58 } |
02f5a3f5c0a0
access to the REST API from Lua
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1436
diff
changeset
|
59 |
02f5a3f5c0a0
access to the REST API from Lua
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1436
diff
changeset
|
60 |
1447
5ba7471780ae
refactoring: HttpToolbox, DumpJson in Lua
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1445
diff
changeset
|
61 // Syntax in Lua: RestApiGet(uri, builtin) |
1444
b2b09a3dbd8e
refactoring: OrthancHttpHandler inside OrthancServer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1441
diff
changeset
|
62 int LuaScripting::RestApiGet(lua_State *state) |
1437
02f5a3f5c0a0
access to the REST API from Lua
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1436
diff
changeset
|
63 { |
1444
b2b09a3dbd8e
refactoring: OrthancHttpHandler inside OrthancServer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1441
diff
changeset
|
64 ServerContext* serverContext = GetServerContext(state); |
b2b09a3dbd8e
refactoring: OrthancHttpHandler inside OrthancServer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1441
diff
changeset
|
65 if (serverContext == NULL) |
1437
02f5a3f5c0a0
access to the REST API from Lua
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1436
diff
changeset
|
66 { |
1440 | 67 LOG(ERROR) << "Lua: The Orthanc API is unavailable"; |
1437
02f5a3f5c0a0
access to the REST API from Lua
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1436
diff
changeset
|
68 lua_pushnil(state); |
02f5a3f5c0a0
access to the REST API from Lua
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1436
diff
changeset
|
69 return 1; |
02f5a3f5c0a0
access to the REST API from Lua
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1436
diff
changeset
|
70 } |
02f5a3f5c0a0
access to the REST API from Lua
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1436
diff
changeset
|
71 |
02f5a3f5c0a0
access to the REST API from Lua
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1436
diff
changeset
|
72 // Check the types of the arguments |
02f5a3f5c0a0
access to the REST API from Lua
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1436
diff
changeset
|
73 int nArgs = lua_gettop(state); |
1444
b2b09a3dbd8e
refactoring: OrthancHttpHandler inside OrthancServer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1441
diff
changeset
|
74 if ((nArgs != 1 && nArgs != 2) || |
b2b09a3dbd8e
refactoring: OrthancHttpHandler inside OrthancServer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1441
diff
changeset
|
75 !lua_isstring(state, 1) || // URI |
b2b09a3dbd8e
refactoring: OrthancHttpHandler inside OrthancServer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1441
diff
changeset
|
76 (nArgs == 2 && !lua_isboolean(state, 2))) // Restrict to built-in API? |
1437
02f5a3f5c0a0
access to the REST API from Lua
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1436
diff
changeset
|
77 { |
1444
b2b09a3dbd8e
refactoring: OrthancHttpHandler inside OrthancServer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1441
diff
changeset
|
78 LOG(ERROR) << "Lua: Bad parameters to RestApiGet()"; |
1437
02f5a3f5c0a0
access to the REST API from Lua
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1436
diff
changeset
|
79 lua_pushnil(state); |
02f5a3f5c0a0
access to the REST API from Lua
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1436
diff
changeset
|
80 return 1; |
02f5a3f5c0a0
access to the REST API from Lua
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1436
diff
changeset
|
81 } |
02f5a3f5c0a0
access to the REST API from Lua
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1436
diff
changeset
|
82 |
02f5a3f5c0a0
access to the REST API from Lua
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1436
diff
changeset
|
83 const char* uri = lua_tostring(state, 1); |
1545 | 84 bool builtin = (nArgs == 2 ? lua_toboolean(state, 2) != 0 : false); |
1444
b2b09a3dbd8e
refactoring: OrthancHttpHandler inside OrthancServer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1441
diff
changeset
|
85 |
1445
d26c8a93d05a
refactoring: SimpleGet
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1444
diff
changeset
|
86 std::string result; |
1571
3232f1c995a5
provide the origin of the requests to HTTP handlers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1545
diff
changeset
|
87 if (HttpToolbox::SimpleGet(result, serverContext->GetHttpHandler().RestrictToOrthancRestApi(builtin), |
3232f1c995a5
provide the origin of the requests to HTTP handlers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1545
diff
changeset
|
88 RequestOrigin_Lua, uri)) |
1437
02f5a3f5c0a0
access to the REST API from Lua
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1436
diff
changeset
|
89 { |
1465
905842836ad4
sample Lua script to write DICOM series to disk
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1456
diff
changeset
|
90 lua_pushlstring(state, result.c_str(), result.size()); |
1437
02f5a3f5c0a0
access to the REST API from Lua
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1436
diff
changeset
|
91 } |
02f5a3f5c0a0
access to the REST API from Lua
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1436
diff
changeset
|
92 else |
02f5a3f5c0a0
access to the REST API from Lua
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1436
diff
changeset
|
93 { |
1447
5ba7471780ae
refactoring: HttpToolbox, DumpJson in Lua
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1445
diff
changeset
|
94 LOG(ERROR) << "Lua: Error in RestApiGet() for URI: " << uri; |
5ba7471780ae
refactoring: HttpToolbox, DumpJson in Lua
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1445
diff
changeset
|
95 lua_pushnil(state); |
5ba7471780ae
refactoring: HttpToolbox, DumpJson in Lua
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1445
diff
changeset
|
96 } |
5ba7471780ae
refactoring: HttpToolbox, DumpJson in Lua
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1445
diff
changeset
|
97 |
5ba7471780ae
refactoring: HttpToolbox, DumpJson in Lua
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1445
diff
changeset
|
98 return 1; |
5ba7471780ae
refactoring: HttpToolbox, DumpJson in Lua
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1445
diff
changeset
|
99 } |
5ba7471780ae
refactoring: HttpToolbox, DumpJson in Lua
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1445
diff
changeset
|
100 |
5ba7471780ae
refactoring: HttpToolbox, DumpJson in Lua
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1445
diff
changeset
|
101 |
5ba7471780ae
refactoring: HttpToolbox, DumpJson in Lua
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1445
diff
changeset
|
102 int LuaScripting::RestApiPostOrPut(lua_State *state, |
5ba7471780ae
refactoring: HttpToolbox, DumpJson in Lua
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1445
diff
changeset
|
103 bool isPost) |
5ba7471780ae
refactoring: HttpToolbox, DumpJson in Lua
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1445
diff
changeset
|
104 { |
5ba7471780ae
refactoring: HttpToolbox, DumpJson in Lua
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1445
diff
changeset
|
105 ServerContext* serverContext = GetServerContext(state); |
5ba7471780ae
refactoring: HttpToolbox, DumpJson in Lua
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1445
diff
changeset
|
106 if (serverContext == NULL) |
5ba7471780ae
refactoring: HttpToolbox, DumpJson in Lua
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1445
diff
changeset
|
107 { |
5ba7471780ae
refactoring: HttpToolbox, DumpJson in Lua
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1445
diff
changeset
|
108 LOG(ERROR) << "Lua: The Orthanc API is unavailable"; |
5ba7471780ae
refactoring: HttpToolbox, DumpJson in Lua
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1445
diff
changeset
|
109 lua_pushnil(state); |
5ba7471780ae
refactoring: HttpToolbox, DumpJson in Lua
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1445
diff
changeset
|
110 return 1; |
5ba7471780ae
refactoring: HttpToolbox, DumpJson in Lua
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1445
diff
changeset
|
111 } |
5ba7471780ae
refactoring: HttpToolbox, DumpJson in Lua
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1445
diff
changeset
|
112 |
5ba7471780ae
refactoring: HttpToolbox, DumpJson in Lua
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1445
diff
changeset
|
113 // Check the types of the arguments |
5ba7471780ae
refactoring: HttpToolbox, DumpJson in Lua
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1445
diff
changeset
|
114 int nArgs = lua_gettop(state); |
5ba7471780ae
refactoring: HttpToolbox, DumpJson in Lua
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1445
diff
changeset
|
115 if ((nArgs != 2 && nArgs != 3) || |
5ba7471780ae
refactoring: HttpToolbox, DumpJson in Lua
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1445
diff
changeset
|
116 !lua_isstring(state, 1) || // URI |
5ba7471780ae
refactoring: HttpToolbox, DumpJson in Lua
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1445
diff
changeset
|
117 !lua_isstring(state, 2) || // Body |
5ba7471780ae
refactoring: HttpToolbox, DumpJson in Lua
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1445
diff
changeset
|
118 (nArgs == 3 && !lua_isboolean(state, 3))) // Restrict to built-in API? |
5ba7471780ae
refactoring: HttpToolbox, DumpJson in Lua
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1445
diff
changeset
|
119 { |
5ba7471780ae
refactoring: HttpToolbox, DumpJson in Lua
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1445
diff
changeset
|
120 LOG(ERROR) << "Lua: Bad parameters to " << (isPost ? "RestApiPost()" : "RestApiPut()"); |
5ba7471780ae
refactoring: HttpToolbox, DumpJson in Lua
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1445
diff
changeset
|
121 lua_pushnil(state); |
5ba7471780ae
refactoring: HttpToolbox, DumpJson in Lua
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1445
diff
changeset
|
122 return 1; |
5ba7471780ae
refactoring: HttpToolbox, DumpJson in Lua
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1445
diff
changeset
|
123 } |
5ba7471780ae
refactoring: HttpToolbox, DumpJson in Lua
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1445
diff
changeset
|
124 |
5ba7471780ae
refactoring: HttpToolbox, DumpJson in Lua
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1445
diff
changeset
|
125 const char* uri = lua_tostring(state, 1); |
5ba7471780ae
refactoring: HttpToolbox, DumpJson in Lua
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1445
diff
changeset
|
126 size_t bodySize = 0; |
5ba7471780ae
refactoring: HttpToolbox, DumpJson in Lua
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1445
diff
changeset
|
127 const char* bodyData = lua_tolstring(state, 2, &bodySize); |
1545 | 128 bool builtin = (nArgs == 3 ? lua_toboolean(state, 3) != 0 : false); |
1447
5ba7471780ae
refactoring: HttpToolbox, DumpJson in Lua
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1445
diff
changeset
|
129 |
5ba7471780ae
refactoring: HttpToolbox, DumpJson in Lua
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1445
diff
changeset
|
130 std::string result; |
5ba7471780ae
refactoring: HttpToolbox, DumpJson in Lua
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1445
diff
changeset
|
131 if (isPost ? |
5ba7471780ae
refactoring: HttpToolbox, DumpJson in Lua
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1445
diff
changeset
|
132 HttpToolbox::SimplePost(result, serverContext->GetHttpHandler().RestrictToOrthancRestApi(builtin), |
1571
3232f1c995a5
provide the origin of the requests to HTTP handlers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1545
diff
changeset
|
133 RequestOrigin_Lua, uri, bodyData, bodySize) : |
1447
5ba7471780ae
refactoring: HttpToolbox, DumpJson in Lua
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1445
diff
changeset
|
134 HttpToolbox::SimplePut(result, serverContext->GetHttpHandler().RestrictToOrthancRestApi(builtin), |
1571
3232f1c995a5
provide the origin of the requests to HTTP handlers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1545
diff
changeset
|
135 RequestOrigin_Lua, uri, bodyData, bodySize)) |
1447
5ba7471780ae
refactoring: HttpToolbox, DumpJson in Lua
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1445
diff
changeset
|
136 { |
1465
905842836ad4
sample Lua script to write DICOM series to disk
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1456
diff
changeset
|
137 lua_pushlstring(state, result.c_str(), result.size()); |
1447
5ba7471780ae
refactoring: HttpToolbox, DumpJson in Lua
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1445
diff
changeset
|
138 } |
5ba7471780ae
refactoring: HttpToolbox, DumpJson in Lua
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1445
diff
changeset
|
139 else |
5ba7471780ae
refactoring: HttpToolbox, DumpJson in Lua
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1445
diff
changeset
|
140 { |
5ba7471780ae
refactoring: HttpToolbox, DumpJson in Lua
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1445
diff
changeset
|
141 LOG(ERROR) << "Lua: Error in " << (isPost ? "RestApiPost()" : "RestApiPut()") << " for URI: " << uri; |
5ba7471780ae
refactoring: HttpToolbox, DumpJson in Lua
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1445
diff
changeset
|
142 lua_pushnil(state); |
5ba7471780ae
refactoring: HttpToolbox, DumpJson in Lua
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1445
diff
changeset
|
143 } |
5ba7471780ae
refactoring: HttpToolbox, DumpJson in Lua
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1445
diff
changeset
|
144 |
5ba7471780ae
refactoring: HttpToolbox, DumpJson in Lua
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1445
diff
changeset
|
145 return 1; |
5ba7471780ae
refactoring: HttpToolbox, DumpJson in Lua
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1445
diff
changeset
|
146 } |
5ba7471780ae
refactoring: HttpToolbox, DumpJson in Lua
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1445
diff
changeset
|
147 |
5ba7471780ae
refactoring: HttpToolbox, DumpJson in Lua
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1445
diff
changeset
|
148 |
5ba7471780ae
refactoring: HttpToolbox, DumpJson in Lua
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1445
diff
changeset
|
149 // Syntax in Lua: RestApiPost(uri, body, builtin) |
5ba7471780ae
refactoring: HttpToolbox, DumpJson in Lua
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1445
diff
changeset
|
150 int LuaScripting::RestApiPost(lua_State *state) |
5ba7471780ae
refactoring: HttpToolbox, DumpJson in Lua
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1445
diff
changeset
|
151 { |
5ba7471780ae
refactoring: HttpToolbox, DumpJson in Lua
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1445
diff
changeset
|
152 return RestApiPostOrPut(state, true); |
5ba7471780ae
refactoring: HttpToolbox, DumpJson in Lua
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1445
diff
changeset
|
153 } |
5ba7471780ae
refactoring: HttpToolbox, DumpJson in Lua
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1445
diff
changeset
|
154 |
5ba7471780ae
refactoring: HttpToolbox, DumpJson in Lua
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1445
diff
changeset
|
155 |
5ba7471780ae
refactoring: HttpToolbox, DumpJson in Lua
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1445
diff
changeset
|
156 // Syntax in Lua: RestApiPut(uri, body, builtin) |
5ba7471780ae
refactoring: HttpToolbox, DumpJson in Lua
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1445
diff
changeset
|
157 int LuaScripting::RestApiPut(lua_State *state) |
5ba7471780ae
refactoring: HttpToolbox, DumpJson in Lua
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1445
diff
changeset
|
158 { |
5ba7471780ae
refactoring: HttpToolbox, DumpJson in Lua
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1445
diff
changeset
|
159 return RestApiPostOrPut(state, false); |
5ba7471780ae
refactoring: HttpToolbox, DumpJson in Lua
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1445
diff
changeset
|
160 } |
5ba7471780ae
refactoring: HttpToolbox, DumpJson in Lua
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1445
diff
changeset
|
161 |
5ba7471780ae
refactoring: HttpToolbox, DumpJson in Lua
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1445
diff
changeset
|
162 |
5ba7471780ae
refactoring: HttpToolbox, DumpJson in Lua
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1445
diff
changeset
|
163 // Syntax in Lua: RestApiDelete(uri, builtin) |
5ba7471780ae
refactoring: HttpToolbox, DumpJson in Lua
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1445
diff
changeset
|
164 int LuaScripting::RestApiDelete(lua_State *state) |
5ba7471780ae
refactoring: HttpToolbox, DumpJson in Lua
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1445
diff
changeset
|
165 { |
5ba7471780ae
refactoring: HttpToolbox, DumpJson in Lua
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1445
diff
changeset
|
166 ServerContext* serverContext = GetServerContext(state); |
5ba7471780ae
refactoring: HttpToolbox, DumpJson in Lua
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1445
diff
changeset
|
167 if (serverContext == NULL) |
5ba7471780ae
refactoring: HttpToolbox, DumpJson in Lua
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1445
diff
changeset
|
168 { |
5ba7471780ae
refactoring: HttpToolbox, DumpJson in Lua
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1445
diff
changeset
|
169 LOG(ERROR) << "Lua: The Orthanc API is unavailable"; |
5ba7471780ae
refactoring: HttpToolbox, DumpJson in Lua
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1445
diff
changeset
|
170 lua_pushnil(state); |
5ba7471780ae
refactoring: HttpToolbox, DumpJson in Lua
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1445
diff
changeset
|
171 return 1; |
5ba7471780ae
refactoring: HttpToolbox, DumpJson in Lua
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1445
diff
changeset
|
172 } |
5ba7471780ae
refactoring: HttpToolbox, DumpJson in Lua
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1445
diff
changeset
|
173 |
5ba7471780ae
refactoring: HttpToolbox, DumpJson in Lua
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1445
diff
changeset
|
174 // Check the types of the arguments |
5ba7471780ae
refactoring: HttpToolbox, DumpJson in Lua
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1445
diff
changeset
|
175 int nArgs = lua_gettop(state); |
5ba7471780ae
refactoring: HttpToolbox, DumpJson in Lua
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1445
diff
changeset
|
176 if ((nArgs != 1 && nArgs != 2) || |
5ba7471780ae
refactoring: HttpToolbox, DumpJson in Lua
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1445
diff
changeset
|
177 !lua_isstring(state, 1) || // URI |
5ba7471780ae
refactoring: HttpToolbox, DumpJson in Lua
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1445
diff
changeset
|
178 (nArgs == 2 && !lua_isboolean(state, 2))) // Restrict to built-in API? |
5ba7471780ae
refactoring: HttpToolbox, DumpJson in Lua
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1445
diff
changeset
|
179 { |
1449 | 180 LOG(ERROR) << "Lua: Bad parameters to RestApiDelete()"; |
1447
5ba7471780ae
refactoring: HttpToolbox, DumpJson in Lua
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1445
diff
changeset
|
181 lua_pushnil(state); |
5ba7471780ae
refactoring: HttpToolbox, DumpJson in Lua
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1445
diff
changeset
|
182 return 1; |
5ba7471780ae
refactoring: HttpToolbox, DumpJson in Lua
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1445
diff
changeset
|
183 } |
5ba7471780ae
refactoring: HttpToolbox, DumpJson in Lua
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1445
diff
changeset
|
184 |
5ba7471780ae
refactoring: HttpToolbox, DumpJson in Lua
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1445
diff
changeset
|
185 const char* uri = lua_tostring(state, 1); |
1545 | 186 bool builtin = (nArgs == 2 ? lua_toboolean(state, 2) != 0 : false); |
1447
5ba7471780ae
refactoring: HttpToolbox, DumpJson in Lua
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1445
diff
changeset
|
187 |
1571
3232f1c995a5
provide the origin of the requests to HTTP handlers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1545
diff
changeset
|
188 if (HttpToolbox::SimpleDelete(serverContext->GetHttpHandler().RestrictToOrthancRestApi(builtin), |
3232f1c995a5
provide the origin of the requests to HTTP handlers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1545
diff
changeset
|
189 RequestOrigin_Lua, uri)) |
1447
5ba7471780ae
refactoring: HttpToolbox, DumpJson in Lua
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1445
diff
changeset
|
190 { |
5ba7471780ae
refactoring: HttpToolbox, DumpJson in Lua
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1445
diff
changeset
|
191 lua_pushboolean(state, 1); |
5ba7471780ae
refactoring: HttpToolbox, DumpJson in Lua
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1445
diff
changeset
|
192 } |
5ba7471780ae
refactoring: HttpToolbox, DumpJson in Lua
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1445
diff
changeset
|
193 else |
5ba7471780ae
refactoring: HttpToolbox, DumpJson in Lua
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1445
diff
changeset
|
194 { |
1449 | 195 LOG(ERROR) << "Lua: Error in RestApiDelete() for URI: " << uri; |
1437
02f5a3f5c0a0
access to the REST API from Lua
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1436
diff
changeset
|
196 lua_pushnil(state); |
02f5a3f5c0a0
access to the REST API from Lua
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1436
diff
changeset
|
197 } |
02f5a3f5c0a0
access to the REST API from Lua
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1436
diff
changeset
|
198 |
02f5a3f5c0a0
access to the REST API from Lua
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1436
diff
changeset
|
199 return 1; |
02f5a3f5c0a0
access to the REST API from Lua
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1436
diff
changeset
|
200 } |
02f5a3f5c0a0
access to the REST API from Lua
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1436
diff
changeset
|
201 |
02f5a3f5c0a0
access to the REST API from Lua
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1436
diff
changeset
|
202 |
1587
d7e569640d09
New function "GetOrthancConfiguration()" to get the Orthanc configuration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1574
diff
changeset
|
203 // Syntax in Lua: GetOrthancConfiguration() |
d7e569640d09
New function "GetOrthancConfiguration()" to get the Orthanc configuration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1574
diff
changeset
|
204 int LuaScripting::GetOrthancConfiguration(lua_State *state) |
d7e569640d09
New function "GetOrthancConfiguration()" to get the Orthanc configuration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1574
diff
changeset
|
205 { |
d7e569640d09
New function "GetOrthancConfiguration()" to get the Orthanc configuration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1574
diff
changeset
|
206 Json::Value configuration; |
d7e569640d09
New function "GetOrthancConfiguration()" to get the Orthanc configuration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1574
diff
changeset
|
207 Configuration::GetConfiguration(configuration); |
d7e569640d09
New function "GetOrthancConfiguration()" to get the Orthanc configuration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1574
diff
changeset
|
208 |
d7e569640d09
New function "GetOrthancConfiguration()" to get the Orthanc configuration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1574
diff
changeset
|
209 LuaContext::GetLuaContext(state).PushJson(configuration); |
d7e569640d09
New function "GetOrthancConfiguration()" to get the Orthanc configuration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1574
diff
changeset
|
210 |
d7e569640d09
New function "GetOrthancConfiguration()" to get the Orthanc configuration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1574
diff
changeset
|
211 return 1; |
d7e569640d09
New function "GetOrthancConfiguration()" to get the Orthanc configuration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1574
diff
changeset
|
212 } |
d7e569640d09
New function "GetOrthancConfiguration()" to get the Orthanc configuration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1574
diff
changeset
|
213 |
d7e569640d09
New function "GetOrthancConfiguration()" to get the Orthanc configuration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1574
diff
changeset
|
214 |
1433
461e7554bff7
refactoring: LuaScripting
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
215 IServerCommand* LuaScripting::ParseOperation(const std::string& operation, |
461e7554bff7
refactoring: LuaScripting
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
216 const Json::Value& parameters) |
461e7554bff7
refactoring: LuaScripting
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
217 { |
461e7554bff7
refactoring: LuaScripting
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
218 if (operation == "delete") |
461e7554bff7
refactoring: LuaScripting
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
219 { |
1435
6406f5493d92
refactoring: Lua toolbox
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1433
diff
changeset
|
220 LOG(INFO) << "Lua script to delete resource " << parameters["Resource"].asString(); |
1433
461e7554bff7
refactoring: LuaScripting
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
221 return new DeleteInstanceCommand(context_); |
461e7554bff7
refactoring: LuaScripting
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
222 } |
461e7554bff7
refactoring: LuaScripting
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
223 |
461e7554bff7
refactoring: LuaScripting
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
224 if (operation == "store-scu") |
461e7554bff7
refactoring: LuaScripting
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
225 { |
461e7554bff7
refactoring: LuaScripting
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
226 std::string localAet; |
461e7554bff7
refactoring: LuaScripting
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
227 if (parameters.isMember("LocalAet")) |
461e7554bff7
refactoring: LuaScripting
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
228 { |
461e7554bff7
refactoring: LuaScripting
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
229 localAet = parameters["LocalAet"].asString(); |
461e7554bff7
refactoring: LuaScripting
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
230 } |
461e7554bff7
refactoring: LuaScripting
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
231 else |
461e7554bff7
refactoring: LuaScripting
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
232 { |
461e7554bff7
refactoring: LuaScripting
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
233 localAet = context_.GetDefaultLocalApplicationEntityTitle(); |
461e7554bff7
refactoring: LuaScripting
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
234 } |
461e7554bff7
refactoring: LuaScripting
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
235 |
461e7554bff7
refactoring: LuaScripting
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
236 std::string modality = parameters["Modality"].asString(); |
1435
6406f5493d92
refactoring: Lua toolbox
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1433
diff
changeset
|
237 LOG(INFO) << "Lua script to send resource " << parameters["Resource"].asString() |
1433
461e7554bff7
refactoring: LuaScripting
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
238 << " to modality " << modality << " using Store-SCU"; |
461e7554bff7
refactoring: LuaScripting
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
239 return new StoreScuCommand(context_, localAet, |
461e7554bff7
refactoring: LuaScripting
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
240 Configuration::GetModalityUsingSymbolicName(modality), true); |
461e7554bff7
refactoring: LuaScripting
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
241 } |
461e7554bff7
refactoring: LuaScripting
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
242 |
461e7554bff7
refactoring: LuaScripting
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
243 if (operation == "store-peer") |
461e7554bff7
refactoring: LuaScripting
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
244 { |
461e7554bff7
refactoring: LuaScripting
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
245 std::string peer = parameters["Peer"].asString(); |
1435
6406f5493d92
refactoring: Lua toolbox
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1433
diff
changeset
|
246 LOG(INFO) << "Lua script to send resource " << parameters["Resource"].asString() |
1433
461e7554bff7
refactoring: LuaScripting
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
247 << " to peer " << peer << " using HTTP"; |
461e7554bff7
refactoring: LuaScripting
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
248 |
461e7554bff7
refactoring: LuaScripting
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
249 OrthancPeerParameters parameters; |
461e7554bff7
refactoring: LuaScripting
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
250 Configuration::GetOrthancPeer(parameters, peer); |
461e7554bff7
refactoring: LuaScripting
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
251 return new StorePeerCommand(context_, parameters, true); |
461e7554bff7
refactoring: LuaScripting
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
252 } |
461e7554bff7
refactoring: LuaScripting
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
253 |
461e7554bff7
refactoring: LuaScripting
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
254 if (operation == "modify") |
461e7554bff7
refactoring: LuaScripting
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
255 { |
1435
6406f5493d92
refactoring: Lua toolbox
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1433
diff
changeset
|
256 LOG(INFO) << "Lua script to modify resource " << parameters["Resource"].asString(); |
1433
461e7554bff7
refactoring: LuaScripting
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
257 DicomModification modification; |
461e7554bff7
refactoring: LuaScripting
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
258 OrthancRestApi::ParseModifyRequest(modification, parameters); |
461e7554bff7
refactoring: LuaScripting
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
259 |
1572
904096e7367e
More information about the origin request in OnStoredInstance() callbacks
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1571
diff
changeset
|
260 std::auto_ptr<ModifyInstanceCommand> command(new ModifyInstanceCommand(context_, RequestOrigin_Lua, modification)); |
1433
461e7554bff7
refactoring: LuaScripting
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
261 return command.release(); |
461e7554bff7
refactoring: LuaScripting
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
262 } |
461e7554bff7
refactoring: LuaScripting
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
263 |
461e7554bff7
refactoring: LuaScripting
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
264 if (operation == "call-system") |
461e7554bff7
refactoring: LuaScripting
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
265 { |
1435
6406f5493d92
refactoring: Lua toolbox
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1433
diff
changeset
|
266 LOG(INFO) << "Lua script to call system command on " << parameters["Resource"].asString(); |
1433
461e7554bff7
refactoring: LuaScripting
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
267 |
461e7554bff7
refactoring: LuaScripting
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
268 const Json::Value& argsIn = parameters["Arguments"]; |
461e7554bff7
refactoring: LuaScripting
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
269 if (argsIn.type() != Json::arrayValue) |
461e7554bff7
refactoring: LuaScripting
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
270 { |
461e7554bff7
refactoring: LuaScripting
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
271 throw OrthancException(ErrorCode_BadParameterType); |
461e7554bff7
refactoring: LuaScripting
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
272 } |
461e7554bff7
refactoring: LuaScripting
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
273 |
461e7554bff7
refactoring: LuaScripting
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
274 std::vector<std::string> args; |
461e7554bff7
refactoring: LuaScripting
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
275 args.reserve(argsIn.size()); |
461e7554bff7
refactoring: LuaScripting
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
276 for (Json::Value::ArrayIndex i = 0; i < argsIn.size(); ++i) |
461e7554bff7
refactoring: LuaScripting
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
277 { |
461e7554bff7
refactoring: LuaScripting
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
278 // http://jsoncpp.sourceforge.net/namespace_json.html#7d654b75c16a57007925868e38212b4e |
461e7554bff7
refactoring: LuaScripting
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
279 switch (argsIn[i].type()) |
461e7554bff7
refactoring: LuaScripting
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
280 { |
461e7554bff7
refactoring: LuaScripting
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
281 case Json::stringValue: |
461e7554bff7
refactoring: LuaScripting
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
282 args.push_back(argsIn[i].asString()); |
461e7554bff7
refactoring: LuaScripting
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
283 break; |
461e7554bff7
refactoring: LuaScripting
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
284 |
461e7554bff7
refactoring: LuaScripting
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
285 case Json::intValue: |
461e7554bff7
refactoring: LuaScripting
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
286 args.push_back(boost::lexical_cast<std::string>(argsIn[i].asInt())); |
461e7554bff7
refactoring: LuaScripting
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
287 break; |
461e7554bff7
refactoring: LuaScripting
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
288 |
461e7554bff7
refactoring: LuaScripting
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
289 case Json::uintValue: |
461e7554bff7
refactoring: LuaScripting
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
290 args.push_back(boost::lexical_cast<std::string>(argsIn[i].asUInt())); |
461e7554bff7
refactoring: LuaScripting
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
291 break; |
461e7554bff7
refactoring: LuaScripting
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
292 |
461e7554bff7
refactoring: LuaScripting
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
293 case Json::realValue: |
461e7554bff7
refactoring: LuaScripting
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
294 args.push_back(boost::lexical_cast<std::string>(argsIn[i].asFloat())); |
461e7554bff7
refactoring: LuaScripting
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
295 break; |
461e7554bff7
refactoring: LuaScripting
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
296 |
461e7554bff7
refactoring: LuaScripting
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
297 default: |
461e7554bff7
refactoring: LuaScripting
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
298 throw OrthancException(ErrorCode_BadParameterType); |
461e7554bff7
refactoring: LuaScripting
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
299 } |
461e7554bff7
refactoring: LuaScripting
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
300 } |
461e7554bff7
refactoring: LuaScripting
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
301 |
461e7554bff7
refactoring: LuaScripting
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
302 return new CallSystemCommand(context_, parameters["Command"].asString(), args); |
461e7554bff7
refactoring: LuaScripting
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
303 } |
461e7554bff7
refactoring: LuaScripting
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
304 |
461e7554bff7
refactoring: LuaScripting
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
305 throw OrthancException(ErrorCode_ParameterOutOfRange); |
461e7554bff7
refactoring: LuaScripting
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
306 } |
461e7554bff7
refactoring: LuaScripting
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
307 |
461e7554bff7
refactoring: LuaScripting
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
308 |
1435
6406f5493d92
refactoring: Lua toolbox
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1433
diff
changeset
|
309 void LuaScripting::InitializeJob() |
6406f5493d92
refactoring: Lua toolbox
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1433
diff
changeset
|
310 { |
6406f5493d92
refactoring: Lua toolbox
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1433
diff
changeset
|
311 lua_.Execute("_InitializeJob()"); |
6406f5493d92
refactoring: Lua toolbox
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1433
diff
changeset
|
312 } |
6406f5493d92
refactoring: Lua toolbox
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1433
diff
changeset
|
313 |
6406f5493d92
refactoring: Lua toolbox
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1433
diff
changeset
|
314 |
6406f5493d92
refactoring: Lua toolbox
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1433
diff
changeset
|
315 void LuaScripting::SubmitJob(const std::string& description) |
6406f5493d92
refactoring: Lua toolbox
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1433
diff
changeset
|
316 { |
6406f5493d92
refactoring: Lua toolbox
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1433
diff
changeset
|
317 Json::Value operations; |
6406f5493d92
refactoring: Lua toolbox
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1433
diff
changeset
|
318 LuaFunctionCall call2(lua_, "_AccessJob"); |
6406f5493d92
refactoring: Lua toolbox
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1433
diff
changeset
|
319 call2.ExecuteToJson(operations); |
6406f5493d92
refactoring: Lua toolbox
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1433
diff
changeset
|
320 |
6406f5493d92
refactoring: Lua toolbox
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1433
diff
changeset
|
321 if (operations.type() != Json::arrayValue) |
6406f5493d92
refactoring: Lua toolbox
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1433
diff
changeset
|
322 { |
6406f5493d92
refactoring: Lua toolbox
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1433
diff
changeset
|
323 throw OrthancException(ErrorCode_InternalError); |
6406f5493d92
refactoring: Lua toolbox
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1433
diff
changeset
|
324 } |
6406f5493d92
refactoring: Lua toolbox
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1433
diff
changeset
|
325 |
6406f5493d92
refactoring: Lua toolbox
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1433
diff
changeset
|
326 ServerJob job; |
6406f5493d92
refactoring: Lua toolbox
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1433
diff
changeset
|
327 ServerCommandInstance* previousCommand = NULL; |
6406f5493d92
refactoring: Lua toolbox
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1433
diff
changeset
|
328 |
6406f5493d92
refactoring: Lua toolbox
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1433
diff
changeset
|
329 for (Json::Value::ArrayIndex i = 0; i < operations.size(); ++i) |
6406f5493d92
refactoring: Lua toolbox
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1433
diff
changeset
|
330 { |
6406f5493d92
refactoring: Lua toolbox
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1433
diff
changeset
|
331 if (operations[i].type() != Json::objectValue || |
6406f5493d92
refactoring: Lua toolbox
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1433
diff
changeset
|
332 !operations[i].isMember("Operation")) |
6406f5493d92
refactoring: Lua toolbox
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1433
diff
changeset
|
333 { |
6406f5493d92
refactoring: Lua toolbox
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1433
diff
changeset
|
334 throw OrthancException(ErrorCode_InternalError); |
6406f5493d92
refactoring: Lua toolbox
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1433
diff
changeset
|
335 } |
6406f5493d92
refactoring: Lua toolbox
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1433
diff
changeset
|
336 |
6406f5493d92
refactoring: Lua toolbox
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1433
diff
changeset
|
337 const Json::Value& parameters = operations[i]; |
6406f5493d92
refactoring: Lua toolbox
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1433
diff
changeset
|
338 std::string operation = parameters["Operation"].asString(); |
6406f5493d92
refactoring: Lua toolbox
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1433
diff
changeset
|
339 |
6406f5493d92
refactoring: Lua toolbox
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1433
diff
changeset
|
340 ServerCommandInstance& command = job.AddCommand(ParseOperation(operation, operations[i])); |
6406f5493d92
refactoring: Lua toolbox
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1433
diff
changeset
|
341 |
6406f5493d92
refactoring: Lua toolbox
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1433
diff
changeset
|
342 if (!parameters.isMember("Resource")) |
6406f5493d92
refactoring: Lua toolbox
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1433
diff
changeset
|
343 { |
6406f5493d92
refactoring: Lua toolbox
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1433
diff
changeset
|
344 throw OrthancException(ErrorCode_InternalError); |
6406f5493d92
refactoring: Lua toolbox
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1433
diff
changeset
|
345 } |
6406f5493d92
refactoring: Lua toolbox
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1433
diff
changeset
|
346 |
6406f5493d92
refactoring: Lua toolbox
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1433
diff
changeset
|
347 std::string resource = parameters["Resource"].asString(); |
6406f5493d92
refactoring: Lua toolbox
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1433
diff
changeset
|
348 if (resource.empty()) |
6406f5493d92
refactoring: Lua toolbox
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1433
diff
changeset
|
349 { |
6406f5493d92
refactoring: Lua toolbox
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1433
diff
changeset
|
350 previousCommand->ConnectOutput(command); |
6406f5493d92
refactoring: Lua toolbox
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1433
diff
changeset
|
351 } |
6406f5493d92
refactoring: Lua toolbox
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1433
diff
changeset
|
352 else |
6406f5493d92
refactoring: Lua toolbox
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1433
diff
changeset
|
353 { |
6406f5493d92
refactoring: Lua toolbox
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1433
diff
changeset
|
354 command.AddInput(resource); |
6406f5493d92
refactoring: Lua toolbox
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1433
diff
changeset
|
355 } |
6406f5493d92
refactoring: Lua toolbox
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1433
diff
changeset
|
356 |
6406f5493d92
refactoring: Lua toolbox
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1433
diff
changeset
|
357 previousCommand = &command; |
6406f5493d92
refactoring: Lua toolbox
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1433
diff
changeset
|
358 } |
6406f5493d92
refactoring: Lua toolbox
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1433
diff
changeset
|
359 |
6406f5493d92
refactoring: Lua toolbox
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1433
diff
changeset
|
360 job.SetDescription(description); |
6406f5493d92
refactoring: Lua toolbox
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1433
diff
changeset
|
361 context_.GetScheduler().Submit(job); |
6406f5493d92
refactoring: Lua toolbox
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1433
diff
changeset
|
362 } |
6406f5493d92
refactoring: Lua toolbox
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1433
diff
changeset
|
363 |
6406f5493d92
refactoring: Lua toolbox
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1433
diff
changeset
|
364 |
1444
b2b09a3dbd8e
refactoring: OrthancHttpHandler inside OrthancServer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1441
diff
changeset
|
365 LuaScripting::LuaScripting(ServerContext& context) : context_(context) |
1433
461e7554bff7
refactoring: LuaScripting
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
366 { |
1444
b2b09a3dbd8e
refactoring: OrthancHttpHandler inside OrthancServer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1441
diff
changeset
|
367 lua_.SetGlobalVariable("_ServerContext", &context); |
b2b09a3dbd8e
refactoring: OrthancHttpHandler inside OrthancServer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1441
diff
changeset
|
368 lua_.RegisterFunction("RestApiGet", RestApiGet); |
1447
5ba7471780ae
refactoring: HttpToolbox, DumpJson in Lua
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1445
diff
changeset
|
369 lua_.RegisterFunction("RestApiPost", RestApiPost); |
5ba7471780ae
refactoring: HttpToolbox, DumpJson in Lua
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1445
diff
changeset
|
370 lua_.RegisterFunction("RestApiPut", RestApiPut); |
5ba7471780ae
refactoring: HttpToolbox, DumpJson in Lua
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1445
diff
changeset
|
371 lua_.RegisterFunction("RestApiDelete", RestApiDelete); |
1587
d7e569640d09
New function "GetOrthancConfiguration()" to get the Orthanc configuration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1574
diff
changeset
|
372 lua_.RegisterFunction("GetOrthancConfiguration", GetOrthancConfiguration); |
1437
02f5a3f5c0a0
access to the REST API from Lua
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1436
diff
changeset
|
373 |
1433
461e7554bff7
refactoring: LuaScripting
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
374 lua_.Execute(Orthanc::EmbeddedResources::LUA_TOOLBOX); |
461e7554bff7
refactoring: LuaScripting
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
375 lua_.SetHttpProxy(Configuration::GetGlobalStringParameter("HttpProxy", "")); |
461e7554bff7
refactoring: LuaScripting
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
376 } |
461e7554bff7
refactoring: LuaScripting
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
377 |
461e7554bff7
refactoring: LuaScripting
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
378 |
461e7554bff7
refactoring: LuaScripting
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
379 void LuaScripting::ApplyOnStoredInstance(const std::string& instanceId, |
461e7554bff7
refactoring: LuaScripting
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
380 const Json::Value& simplifiedTags, |
461e7554bff7
refactoring: LuaScripting
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
381 const Json::Value& metadata, |
1572
904096e7367e
More information about the origin request in OnStoredInstance() callbacks
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1571
diff
changeset
|
382 const DicomInstanceToStore& instance) |
1433
461e7554bff7
refactoring: LuaScripting
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
383 { |
1435
6406f5493d92
refactoring: Lua toolbox
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1433
diff
changeset
|
384 static const char* NAME = "OnStoredInstance"; |
6406f5493d92
refactoring: Lua toolbox
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1433
diff
changeset
|
385 |
6406f5493d92
refactoring: Lua toolbox
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1433
diff
changeset
|
386 if (lua_.IsExistingFunction(NAME)) |
1433
461e7554bff7
refactoring: LuaScripting
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
387 { |
1435
6406f5493d92
refactoring: Lua toolbox
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1433
diff
changeset
|
388 InitializeJob(); |
1433
461e7554bff7
refactoring: LuaScripting
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
389 |
1435
6406f5493d92
refactoring: Lua toolbox
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1433
diff
changeset
|
390 LuaFunctionCall call(lua_, NAME); |
1433
461e7554bff7
refactoring: LuaScripting
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
391 call.PushString(instanceId); |
461e7554bff7
refactoring: LuaScripting
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
392 call.PushJson(simplifiedTags); |
461e7554bff7
refactoring: LuaScripting
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
393 call.PushJson(metadata); |
1572
904096e7367e
More information about the origin request in OnStoredInstance() callbacks
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1571
diff
changeset
|
394 |
904096e7367e
More information about the origin request in OnStoredInstance() callbacks
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1571
diff
changeset
|
395 Json::Value origin; |
904096e7367e
More information about the origin request in OnStoredInstance() callbacks
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1571
diff
changeset
|
396 instance.GetOriginInformation(origin); |
904096e7367e
More information about the origin request in OnStoredInstance() callbacks
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1571
diff
changeset
|
397 call.PushJson(origin); |
904096e7367e
More information about the origin request in OnStoredInstance() callbacks
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1571
diff
changeset
|
398 |
1433
461e7554bff7
refactoring: LuaScripting
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
399 call.Execute(); |
461e7554bff7
refactoring: LuaScripting
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
400 |
1435
6406f5493d92
refactoring: Lua toolbox
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1433
diff
changeset
|
401 SubmitJob(std::string("Lua script: ") + NAME); |
1433
461e7554bff7
refactoring: LuaScripting
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
402 } |
461e7554bff7
refactoring: LuaScripting
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
403 } |
461e7554bff7
refactoring: LuaScripting
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
404 |
461e7554bff7
refactoring: LuaScripting
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
405 |
461e7554bff7
refactoring: LuaScripting
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
406 void LuaScripting::SignalStoredInstance(const std::string& publicId, |
461e7554bff7
refactoring: LuaScripting
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
407 DicomInstanceToStore& instance, |
461e7554bff7
refactoring: LuaScripting
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
408 const Json::Value& simplifiedTags) |
461e7554bff7
refactoring: LuaScripting
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
409 { |
1456
68827c07e683
fix recursive calls with Lua
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1455
diff
changeset
|
410 boost::recursive_mutex::scoped_lock lock(mutex_); |
1433
461e7554bff7
refactoring: LuaScripting
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
411 |
461e7554bff7
refactoring: LuaScripting
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
412 Json::Value metadata = Json::objectValue; |
461e7554bff7
refactoring: LuaScripting
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
413 |
461e7554bff7
refactoring: LuaScripting
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
414 for (ServerIndex::MetadataMap::const_iterator |
461e7554bff7
refactoring: LuaScripting
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
415 it = instance.GetMetadata().begin(); |
461e7554bff7
refactoring: LuaScripting
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
416 it != instance.GetMetadata().end(); ++it) |
461e7554bff7
refactoring: LuaScripting
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
417 { |
461e7554bff7
refactoring: LuaScripting
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
418 if (it->first.first == ResourceType_Instance) |
461e7554bff7
refactoring: LuaScripting
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
419 { |
461e7554bff7
refactoring: LuaScripting
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
420 metadata[EnumerationToString(it->first.second)] = it->second; |
461e7554bff7
refactoring: LuaScripting
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
421 } |
461e7554bff7
refactoring: LuaScripting
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
422 } |
461e7554bff7
refactoring: LuaScripting
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
423 |
1572
904096e7367e
More information about the origin request in OnStoredInstance() callbacks
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1571
diff
changeset
|
424 ApplyOnStoredInstance(publicId, simplifiedTags, metadata, instance); |
1433
461e7554bff7
refactoring: LuaScripting
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
425 } |
461e7554bff7
refactoring: LuaScripting
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
426 |
461e7554bff7
refactoring: LuaScripting
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
427 |
1435
6406f5493d92
refactoring: Lua toolbox
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1433
diff
changeset
|
428 |
6406f5493d92
refactoring: Lua toolbox
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1433
diff
changeset
|
429 void LuaScripting::OnStableResource(const ServerIndexChange& change) |
6406f5493d92
refactoring: Lua toolbox
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1433
diff
changeset
|
430 { |
6406f5493d92
refactoring: Lua toolbox
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1433
diff
changeset
|
431 const char* name; |
6406f5493d92
refactoring: Lua toolbox
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1433
diff
changeset
|
432 |
6406f5493d92
refactoring: Lua toolbox
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1433
diff
changeset
|
433 switch (change.GetChangeType()) |
6406f5493d92
refactoring: Lua toolbox
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1433
diff
changeset
|
434 { |
6406f5493d92
refactoring: Lua toolbox
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1433
diff
changeset
|
435 case ChangeType_StablePatient: |
6406f5493d92
refactoring: Lua toolbox
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1433
diff
changeset
|
436 name = "OnStablePatient"; |
6406f5493d92
refactoring: Lua toolbox
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1433
diff
changeset
|
437 break; |
6406f5493d92
refactoring: Lua toolbox
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1433
diff
changeset
|
438 |
6406f5493d92
refactoring: Lua toolbox
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1433
diff
changeset
|
439 case ChangeType_StableStudy: |
6406f5493d92
refactoring: Lua toolbox
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1433
diff
changeset
|
440 name = "OnStableStudy"; |
6406f5493d92
refactoring: Lua toolbox
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1433
diff
changeset
|
441 break; |
6406f5493d92
refactoring: Lua toolbox
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1433
diff
changeset
|
442 |
6406f5493d92
refactoring: Lua toolbox
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1433
diff
changeset
|
443 case ChangeType_StableSeries: |
6406f5493d92
refactoring: Lua toolbox
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1433
diff
changeset
|
444 name = "OnStableSeries"; |
6406f5493d92
refactoring: Lua toolbox
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1433
diff
changeset
|
445 break; |
6406f5493d92
refactoring: Lua toolbox
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1433
diff
changeset
|
446 |
6406f5493d92
refactoring: Lua toolbox
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1433
diff
changeset
|
447 default: |
6406f5493d92
refactoring: Lua toolbox
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1433
diff
changeset
|
448 throw OrthancException(ErrorCode_InternalError); |
6406f5493d92
refactoring: Lua toolbox
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1433
diff
changeset
|
449 } |
6406f5493d92
refactoring: Lua toolbox
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1433
diff
changeset
|
450 |
6406f5493d92
refactoring: Lua toolbox
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1433
diff
changeset
|
451 |
1447
5ba7471780ae
refactoring: HttpToolbox, DumpJson in Lua
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1445
diff
changeset
|
452 Json::Value tags, metadata; |
5ba7471780ae
refactoring: HttpToolbox, DumpJson in Lua
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1445
diff
changeset
|
453 if (context_.GetIndex().LookupResource(tags, change.GetPublicId(), change.GetResourceType()) && |
5ba7471780ae
refactoring: HttpToolbox, DumpJson in Lua
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1445
diff
changeset
|
454 context_.GetIndex().GetMetadata(metadata, change.GetPublicId())) |
1435
6406f5493d92
refactoring: Lua toolbox
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1433
diff
changeset
|
455 { |
1456
68827c07e683
fix recursive calls with Lua
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1455
diff
changeset
|
456 boost::recursive_mutex::scoped_lock lock(mutex_); |
1435
6406f5493d92
refactoring: Lua toolbox
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1433
diff
changeset
|
457 |
6406f5493d92
refactoring: Lua toolbox
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1433
diff
changeset
|
458 if (lua_.IsExistingFunction(name)) |
6406f5493d92
refactoring: Lua toolbox
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1433
diff
changeset
|
459 { |
6406f5493d92
refactoring: Lua toolbox
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1433
diff
changeset
|
460 InitializeJob(); |
6406f5493d92
refactoring: Lua toolbox
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1433
diff
changeset
|
461 |
6406f5493d92
refactoring: Lua toolbox
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1433
diff
changeset
|
462 LuaFunctionCall call(lua_, name); |
6406f5493d92
refactoring: Lua toolbox
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1433
diff
changeset
|
463 call.PushString(change.GetPublicId()); |
1436
0a3e3be59094
uncoupling of SignalChange for Lua scripts
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1435
diff
changeset
|
464 call.PushJson(tags["MainDicomTags"]); |
1447
5ba7471780ae
refactoring: HttpToolbox, DumpJson in Lua
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1445
diff
changeset
|
465 call.PushJson(metadata); |
1435
6406f5493d92
refactoring: Lua toolbox
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1433
diff
changeset
|
466 call.Execute(); |
6406f5493d92
refactoring: Lua toolbox
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1433
diff
changeset
|
467 |
6406f5493d92
refactoring: Lua toolbox
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1433
diff
changeset
|
468 SubmitJob(std::string("Lua script: ") + name); |
6406f5493d92
refactoring: Lua toolbox
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1433
diff
changeset
|
469 } |
6406f5493d92
refactoring: Lua toolbox
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1433
diff
changeset
|
470 } |
6406f5493d92
refactoring: Lua toolbox
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1433
diff
changeset
|
471 } |
6406f5493d92
refactoring: Lua toolbox
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1433
diff
changeset
|
472 |
6406f5493d92
refactoring: Lua toolbox
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1433
diff
changeset
|
473 |
6406f5493d92
refactoring: Lua toolbox
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1433
diff
changeset
|
474 |
1433
461e7554bff7
refactoring: LuaScripting
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
475 void LuaScripting::SignalChange(const ServerIndexChange& change) |
461e7554bff7
refactoring: LuaScripting
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
476 { |
1435
6406f5493d92
refactoring: Lua toolbox
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1433
diff
changeset
|
477 if (change.GetChangeType() == ChangeType_StablePatient || |
6406f5493d92
refactoring: Lua toolbox
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1433
diff
changeset
|
478 change.GetChangeType() == ChangeType_StableStudy || |
6406f5493d92
refactoring: Lua toolbox
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1433
diff
changeset
|
479 change.GetChangeType() == ChangeType_StableSeries) |
6406f5493d92
refactoring: Lua toolbox
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1433
diff
changeset
|
480 { |
6406f5493d92
refactoring: Lua toolbox
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1433
diff
changeset
|
481 OnStableResource(change); |
6406f5493d92
refactoring: Lua toolbox
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1433
diff
changeset
|
482 } |
1433
461e7554bff7
refactoring: LuaScripting
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
483 } |
461e7554bff7
refactoring: LuaScripting
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
484 |
461e7554bff7
refactoring: LuaScripting
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
485 |
1574
0c29ebe80ac9
give access to full request origin in ReceivedInstanceFilter (Lua)
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1572
diff
changeset
|
486 bool LuaScripting::FilterIncomingInstance(const DicomInstanceToStore& instance, |
0c29ebe80ac9
give access to full request origin in ReceivedInstanceFilter (Lua)
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1572
diff
changeset
|
487 const Json::Value& simplified) |
1433
461e7554bff7
refactoring: LuaScripting
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
488 { |
1435
6406f5493d92
refactoring: Lua toolbox
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1433
diff
changeset
|
489 static const char* NAME = "ReceivedInstanceFilter"; |
6406f5493d92
refactoring: Lua toolbox
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1433
diff
changeset
|
490 |
1456
68827c07e683
fix recursive calls with Lua
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1455
diff
changeset
|
491 boost::recursive_mutex::scoped_lock lock(mutex_); |
1433
461e7554bff7
refactoring: LuaScripting
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
492 |
1435
6406f5493d92
refactoring: Lua toolbox
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1433
diff
changeset
|
493 if (lua_.IsExistingFunction(NAME)) |
1433
461e7554bff7
refactoring: LuaScripting
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
494 { |
1435
6406f5493d92
refactoring: Lua toolbox
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1433
diff
changeset
|
495 LuaFunctionCall call(lua_, NAME); |
1433
461e7554bff7
refactoring: LuaScripting
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
496 call.PushJson(simplified); |
1574
0c29ebe80ac9
give access to full request origin in ReceivedInstanceFilter (Lua)
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1572
diff
changeset
|
497 |
0c29ebe80ac9
give access to full request origin in ReceivedInstanceFilter (Lua)
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1572
diff
changeset
|
498 Json::Value origin; |
0c29ebe80ac9
give access to full request origin in ReceivedInstanceFilter (Lua)
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1572
diff
changeset
|
499 instance.GetOriginInformation(origin); |
0c29ebe80ac9
give access to full request origin in ReceivedInstanceFilter (Lua)
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1572
diff
changeset
|
500 call.PushJson(origin); |
1433
461e7554bff7
refactoring: LuaScripting
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
501 |
461e7554bff7
refactoring: LuaScripting
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
502 if (!call.ExecutePredicate()) |
461e7554bff7
refactoring: LuaScripting
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
503 { |
461e7554bff7
refactoring: LuaScripting
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
504 return false; |
461e7554bff7
refactoring: LuaScripting
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
505 } |
461e7554bff7
refactoring: LuaScripting
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
506 } |
461e7554bff7
refactoring: LuaScripting
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
507 |
461e7554bff7
refactoring: LuaScripting
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
508 return true; |
461e7554bff7
refactoring: LuaScripting
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
509 } |
1455
a68545767975
Initialize() and Finalize() events in Lua
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1449
diff
changeset
|
510 |
a68545767975
Initialize() and Finalize() events in Lua
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1449
diff
changeset
|
511 |
a68545767975
Initialize() and Finalize() events in Lua
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1449
diff
changeset
|
512 void LuaScripting::Execute(const std::string& command) |
a68545767975
Initialize() and Finalize() events in Lua
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1449
diff
changeset
|
513 { |
a68545767975
Initialize() and Finalize() events in Lua
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1449
diff
changeset
|
514 LuaScripting::Locker locker(*this); |
a68545767975
Initialize() and Finalize() events in Lua
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1449
diff
changeset
|
515 |
a68545767975
Initialize() and Finalize() events in Lua
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1449
diff
changeset
|
516 if (locker.GetLua().IsExistingFunction(command.c_str())) |
a68545767975
Initialize() and Finalize() events in Lua
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1449
diff
changeset
|
517 { |
a68545767975
Initialize() and Finalize() events in Lua
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1449
diff
changeset
|
518 LuaFunctionCall call(locker.GetLua(), command.c_str()); |
a68545767975
Initialize() and Finalize() events in Lua
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1449
diff
changeset
|
519 call.Execute(); |
a68545767975
Initialize() and Finalize() events in Lua
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1449
diff
changeset
|
520 } |
a68545767975
Initialize() and Finalize() events in Lua
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1449
diff
changeset
|
521 } |
1433
461e7554bff7
refactoring: LuaScripting
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
522 } |