# HG changeset patch # User Sebastien Jodogne # Date 1406297186 -7200 # Node ID 0332e6e8c679622b1cac5fe3b84aac63c83b7848 # Parent 804a75413ee793acf8c8aa614710e97bc5955c6c Fix automated generation of the list of resource children in the REST API diff -r 804a75413ee7 -r 0332e6e8c679 Core/RestApi/RestApi.cpp --- a/Core/RestApi/RestApi.cpp Fri Jul 25 14:51:18 2014 +0200 +++ b/Core/RestApi/RestApi.cpp Fri Jul 25 16:06:26 2014 +0200 @@ -195,13 +195,6 @@ return true; } - Json::Value directory; - if (root_.GetDirectory(directory, uri)) - { - wrappedOutput.AnswerJson(directory); - return true; - } - std::set methods; root_.GetAcceptedMethods(methods, uri); @@ -243,4 +236,15 @@ { root_.Register(path, handler); } + + void RestApi::AutoListChildren(RestApiGetCall& call) + { + RestApi& context = call.GetContext(); + + Json::Value directory; + if (context.root_.GetDirectory(directory, call.GetFullUri())) + { + call.GetOutput().AnswerJson(directory); + } + } } diff -r 804a75413ee7 -r 0332e6e8c679 Core/RestApi/RestApi.h --- a/Core/RestApi/RestApi.h Fri Jul 25 14:51:18 2014 +0200 +++ b/Core/RestApi/RestApi.h Fri Jul 25 16:06:26 2014 +0200 @@ -44,6 +44,8 @@ RestApiHierarchy root_; public: + static void AutoListChildren(RestApiGetCall& call); + virtual bool Handle(HttpOutput& output, HttpMethod method, const UriComponents& uri, diff -r 804a75413ee7 -r 0332e6e8c679 Core/RestApi/RestApiHierarchy.cpp --- a/Core/RestApi/RestApiHierarchy.cpp Fri Jul 25 14:51:18 2014 +0200 +++ b/Core/RestApi/RestApiHierarchy.cpp Fri Jul 25 16:06:26 2014 +0200 @@ -35,6 +35,7 @@ #include "../OrthancException.h" #include +#include namespace Orthanc { @@ -274,8 +275,7 @@ bool RestApiHierarchy::CanGenerateDirectory() const { - return (!handlers_.HasHandler(HttpMethod_Get) && - universalHandlers_.IsEmpty() && + return (universalHandlers_.IsEmpty() && wildcardChildren_.size() == 0); } diff -r 804a75413ee7 -r 0332e6e8c679 NEWS --- a/NEWS Fri Jul 25 14:51:18 2014 +0200 +++ b/NEWS Fri Jul 25 16:06:26 2014 +0200 @@ -9,7 +9,6 @@ * On-the-fly conversion of JSON to XML according to the HTTP Accept header * C-Echo SCU in the REST API * Lua scripts can do HTTP requests, and thus can call Web services -* Fix build of Google Log with Visual Studio >= 11.0 Plugins ------- @@ -17,6 +16,12 @@ * Lookup for DICOM UIDs in the plugin SDK * Plugins have access to the HTTP headers and can answer with HTTP status codes +Fixes +----- + +* Fix build of Google Log with Visual Studio >= 11.0 +* Fix automated generation of the list of resource children in the REST API + Version 0.8.0 (2014/07/10) ========================== diff -r 804a75413ee7 -r 0332e6e8c679 OrthancServer/OrthancRestApi/OrthancRestApi.cpp --- a/OrthancServer/OrthancRestApi/OrthancRestApi.cpp Fri Jul 25 14:51:18 2014 +0200 +++ b/OrthancServer/OrthancRestApi/OrthancRestApi.cpp Fri Jul 25 16:06:26 2014 +0200 @@ -96,5 +96,9 @@ RegisterArchive(); Register("/instances", UploadDicomFile); + + // Auto-generated directories + Register("/tools", RestApi::AutoListChildren); + Register("/instances/{id}/frames/{frame}", RestApi::AutoListChildren); } } diff -r 804a75413ee7 -r 0332e6e8c679 OrthancServer/OrthancRestApi/OrthancRestModalities.cpp --- a/OrthancServer/OrthancRestApi/OrthancRestModalities.cpp Fri Jul 25 14:51:18 2014 +0200 +++ b/OrthancServer/OrthancRestApi/OrthancRestModalities.cpp Fri Jul 25 16:06:26 2014 +0200 @@ -391,9 +391,7 @@ std::string id = call.GetUriComponent("id", ""); if (IsExistingPeer(peers, id)) { - Json::Value result = Json::arrayValue; - result.append("store"); - call.GetOutput().AnswerJson(result); + RestApi::AutoListChildren(call); } } @@ -458,15 +456,7 @@ std::string id = call.GetUriComponent("id", ""); if (IsExistingModality(modalities, id)) { - Json::Value result = Json::arrayValue; - result.append("echo"); - result.append("find-patient"); - result.append("find-study"); - result.append("find-series"); - result.append("find-instance"); - result.append("find"); - result.append("store"); - call.GetOutput().AnswerJson(result); + RestApi::AutoListChildren(call); } }