Mercurial > hg > orthanc
comparison OrthancServer/ServerContext.cpp @ 1066:bb82e5e818e9
OnStoredInstance callback in plugins
author | Sebastien Jodogne <s.jodogne@gmail.com> |
---|---|
date | Fri, 25 Jul 2014 18:39:02 +0200 |
parents | 921532f67770 |
children | ace99e272203 |
comparison
equal
deleted
inserted
replaced
1065:921532f67770 | 1066:bb82e5e818e9 |
---|---|
48 #include "Scheduler/DeleteInstanceCommand.h" | 48 #include "Scheduler/DeleteInstanceCommand.h" |
49 #include "Scheduler/ModifyInstanceCommand.h" | 49 #include "Scheduler/ModifyInstanceCommand.h" |
50 #include "Scheduler/StoreScuCommand.h" | 50 #include "Scheduler/StoreScuCommand.h" |
51 #include "Scheduler/StorePeerCommand.h" | 51 #include "Scheduler/StorePeerCommand.h" |
52 #include "OrthancRestApi/OrthancRestApi.h" | 52 #include "OrthancRestApi/OrthancRestApi.h" |
53 | 53 #include "../Plugins/Engine/PluginsHttpHandler.h" |
54 | 54 |
55 | 55 |
56 #define ENABLE_DICOM_CACHE 1 | 56 #define ENABLE_DICOM_CACHE 1 |
57 | 57 |
58 static const char* RECEIVED_INSTANCE_FILTER = "ReceivedInstanceFilter"; | 58 static const char* RECEIVED_INSTANCE_FILTER = "ReceivedInstanceFilter"; |
77 index_(*this, indexPath.string()), | 77 index_(*this, indexPath.string()), |
78 accessor_(storage_), | 78 accessor_(storage_), |
79 compressionEnabled_(false), | 79 compressionEnabled_(false), |
80 provider_(*this), | 80 provider_(*this), |
81 dicomCache_(provider_, DICOM_CACHE_SIZE), | 81 dicomCache_(provider_, DICOM_CACHE_SIZE), |
82 scheduler_(Configuration::GetGlobalIntegerParameter("LimitJobs", 10)) | 82 scheduler_(Configuration::GetGlobalIntegerParameter("LimitJobs", 10)), |
83 plugins_(NULL) | |
83 { | 84 { |
84 scu_.SetLocalApplicationEntityTitle(Configuration::GetGlobalStringParameter("DicomAet", "ORTHANC")); | 85 scu_.SetLocalApplicationEntityTitle(Configuration::GetGlobalStringParameter("DicomAet", "ORTHANC")); |
85 //scu_.SetMillisecondsBeforeClose(1); // The connection is always released | 86 //scu_.SetMillisecondsBeforeClose(1); // The connection is always released |
86 | 87 |
87 lua_.Execute(Orthanc::EmbeddedResources::LUA_TOOLBOX); | 88 lua_.Execute(Orthanc::EmbeddedResources::LUA_TOOLBOX); |
204 | 205 |
205 throw OrthancException(ErrorCode_ParameterOutOfRange); | 206 throw OrthancException(ErrorCode_ParameterOutOfRange); |
206 } | 207 } |
207 | 208 |
208 | 209 |
209 void ServerContext::ApplyOnStoredInstance(const std::string& instanceId, | 210 void ServerContext::ApplyLuaOnStoredInstance(const std::string& instanceId, |
210 const Json::Value& simplifiedDicom, | 211 const Json::Value& simplifiedDicom, |
211 const Json::Value& metadata) | 212 const Json::Value& metadata) |
212 { | 213 { |
213 LuaContextLocker locker(*this); | 214 LuaContextLocker locker(*this); |
214 | 215 |
215 if (locker.GetLua().IsExistingFunction(ON_STORED_INSTANCE)) | 216 if (locker.GetLua().IsExistingFunction(ON_STORED_INSTANCE)) |
216 { | 217 { |
345 metadata[EnumerationToString(it->first)] = it->second; | 346 metadata[EnumerationToString(it->first)] = it->second; |
346 } | 347 } |
347 | 348 |
348 try | 349 try |
349 { | 350 { |
350 ApplyOnStoredInstance(resultPublicId, simplified, metadata); | 351 ApplyLuaOnStoredInstance(resultPublicId, simplified, metadata); |
351 } | 352 } |
352 catch (OrthancException& e) | 353 catch (OrthancException& e) |
353 { | 354 { |
354 LOG(ERROR) << "Error in OnStoredInstance callback (Lua): " << e.What(); | 355 LOG(ERROR) << "Error in OnStoredInstance callback (Lua): " << e.What(); |
356 } | |
357 | |
358 if (plugins_ != NULL) | |
359 { | |
360 try | |
361 { | |
362 plugins_->SignalStoredInstance(dicom, resultPublicId); | |
363 } | |
364 catch (OrthancException& e) | |
365 { | |
366 LOG(ERROR) << "Error in OnStoredInstance callback (Lua): " << e.What(); | |
367 } | |
355 } | 368 } |
356 } | 369 } |
357 | 370 |
358 return status; | 371 return status; |
359 } | 372 } |