Mercurial > hg > orthanc-webviewer
comparison Plugin/Plugin.cpp @ 19:20af33af313a
is-stable-series
author | Sebastien Jodogne <s.jodogne@gmail.com> |
---|---|
date | Thu, 09 Apr 2015 16:41:49 +0200 |
parents | 379131283479 |
children | a6492d20b2a8 |
comparison
equal
deleted
inserted
replaced
18:54d5dd1df2e5 | 19:20af33af313a |
---|---|
213 } | 213 } |
214 } | 214 } |
215 | 215 |
216 | 216 |
217 | 217 |
218 static int32_t IsStableSeries(OrthancPluginRestOutput* output, | |
219 const char* url, | |
220 const OrthancPluginHttpRequest* request) | |
221 { | |
222 try | |
223 { | |
224 if (request->method != OrthancPluginHttpMethod_Get) | |
225 { | |
226 OrthancPluginSendMethodNotAllowed(context_, output, "GET"); | |
227 return 0; | |
228 } | |
229 | |
230 const std::string id = request->groups[0]; | |
231 Json::Value series; | |
232 | |
233 if (OrthancPlugins::GetJsonFromOrthanc(series, context_, "/series/" + id) && | |
234 series.type() == Json::objectValue) | |
235 { | |
236 bool value = (series["IsStable"].asBool() || | |
237 series["Status"].asString() == "Complete"); | |
238 std::string answer = value ? "true" : "false"; | |
239 OrthancPluginAnswerBuffer(context_, output, answer.c_str(), answer.size(), "application/json"); | |
240 } | |
241 else | |
242 { | |
243 OrthancPluginSendHttpStatusCode(context_, output, 404); | |
244 } | |
245 | |
246 return 0; | |
247 } | |
248 catch (Orthanc::OrthancException& e) | |
249 { | |
250 OrthancPluginLogError(context_, e.What()); | |
251 return -1; | |
252 } | |
253 catch (std::runtime_error& e) | |
254 { | |
255 OrthancPluginLogError(context_, e.what()); | |
256 return -1; | |
257 } | |
258 catch (boost::bad_lexical_cast&) | |
259 { | |
260 OrthancPluginLogError(context_, "Bad lexical cast"); | |
261 return -1; | |
262 } | |
263 } | |
264 | |
218 | 265 |
219 extern "C" | 266 extern "C" |
220 { | 267 { |
221 ORTHANC_PLUGINS_API int32_t OrthancPluginInitialize(OrthancPluginContext* context) | 268 ORTHANC_PLUGINS_API int32_t OrthancPluginInitialize(OrthancPluginContext* context) |
222 { | 269 { |
326 } | 373 } |
327 | 374 |
328 | 375 |
329 /* Install the callbacks */ | 376 /* Install the callbacks */ |
330 OrthancPluginRegisterRestCallback(context_, "/web-viewer/series/(.*)", ServeCache<CacheBundle_SeriesInformation>); | 377 OrthancPluginRegisterRestCallback(context_, "/web-viewer/series/(.*)", ServeCache<CacheBundle_SeriesInformation>); |
378 OrthancPluginRegisterRestCallback(context_, "/web-viewer/is-stable-series/(.*)", IsStableSeries); | |
331 OrthancPluginRegisterRestCallback(context_, "/web-viewer/instances/(.*)", ServeCache<CacheBundle_DecodedImage>); | 379 OrthancPluginRegisterRestCallback(context_, "/web-viewer/instances/(.*)", ServeCache<CacheBundle_DecodedImage>); |
332 OrthancPluginRegisterRestCallback(context, "/web-viewer/libs/(.*)", ServeEmbeddedFolder<EmbeddedResources::JAVASCRIPT_LIBS>); | 380 OrthancPluginRegisterRestCallback(context, "/web-viewer/libs/(.*)", ServeEmbeddedFolder<EmbeddedResources::JAVASCRIPT_LIBS>); |
333 | 381 |
334 #if ORTHANC_STANDALONE == 1 | 382 #if ORTHANC_STANDALONE == 1 |
335 OrthancPluginRegisterRestCallback(context, "/web-viewer/app/(.*)", ServeEmbeddedFolder<EmbeddedResources::WEB_VIEWER>); | 383 OrthancPluginRegisterRestCallback(context, "/web-viewer/app/(.*)", ServeEmbeddedFolder<EmbeddedResources::WEB_VIEWER>); |