# HG changeset patch # User Sebastien Jodogne # Date 1404132943 -7200 # Node ID 6968356679c01d02dcf4e78cfd661fa3a29affc4 # Parent ab6475e33473f9d739e992264b413b6bb7ecbaef# Parent c550e99c452b1094d2ff2246ea18ac2d11f6f25a integration mainline->plugins diff -r ab6475e33473 -r 6968356679c0 CMakeLists.txt --- a/CMakeLists.txt Mon Jun 30 14:08:51 2014 +0200 +++ b/CMakeLists.txt Mon Jun 30 14:55:43 2014 +0200 @@ -84,6 +84,8 @@ Core/HttpServer/MongooseServer.cpp Core/HttpServer/HttpFileSender.cpp Core/HttpServer/FilesystemHttpSender.cpp + Core/RestApi/RestApiCall.cpp + Core/RestApi/RestApiGetCall.cpp Core/RestApi/RestApiHierarchy.cpp Core/RestApi/RestApiPath.cpp Core/RestApi/RestApiOutput.cpp diff -r ab6475e33473 -r 6968356679c0 Core/RestApi/RestApi.cpp --- a/Core/RestApi/RestApi.cpp Mon Jun 30 14:08:51 2014 +0200 +++ b/Core/RestApi/RestApi.cpp Mon Jun 30 14:55:43 2014 +0200 @@ -38,29 +38,6 @@ namespace Orthanc { - bool RestApi::Call::ParseJsonRequestInternal(Json::Value& result, - const char* request) - { - result.clear(); - Json::Reader reader; - return reader.parse(request, result); - } - - - bool RestApi::GetCall::ParseJsonRequest(Json::Value& result) const - { - result.clear(); - - for (HttpHandler::Arguments::const_iterator - it = getArguments_.begin(); it != getArguments_.end(); ++it) - { - result[it->first] = it->second; - } - - return true; - } - - bool RestApi::IsGetAccepted(const UriComponents& uri) { for (GetHandlers::const_iterator it = getHandlers_.begin(); @@ -192,7 +169,7 @@ bool ok = false; RestApiOutput restOutput(output); - RestApiPath::Components components; + HttpHandler::Arguments components; UriComponents trailing; if (method == HttpMethod_Get) @@ -204,7 +181,7 @@ { //LOG(INFO) << "REST GET call on: " << Toolbox::FlattenUri(uri); ok = true; - GetCall call(restOutput, *this, headers, components, trailing, uri, getArguments); + RestApiGetCall call(restOutput, *this, headers, components, trailing, uri, getArguments); it->second(call); } } @@ -218,7 +195,7 @@ { //LOG(INFO) << "REST PUT call on: " << Toolbox::FlattenUri(uri); ok = true; - PutCall call(restOutput, *this, headers, components, trailing, uri, postData); + RestApiPutCall call(restOutput, *this, headers, components, trailing, uri, postData); it->second(call); } } @@ -232,7 +209,7 @@ { //LOG(INFO) << "REST POST call on: " << Toolbox::FlattenUri(uri); ok = true; - PostCall call(restOutput, *this, headers, components, trailing, uri, postData); + RestApiPostCall call(restOutput, *this, headers, components, trailing, uri, postData); it->second(call); } } @@ -246,7 +223,7 @@ { //LOG(INFO) << "REST DELETE call on: " << Toolbox::FlattenUri(uri); ok = true; - DeleteCall call(restOutput, *this, headers, components, trailing, uri); + RestApiDeleteCall call(restOutput, *this, headers, components, trailing, uri); it->second(call); } } @@ -263,25 +240,25 @@ } void RestApi::Register(const std::string& path, - GetHandler handler) + RestApiGetCall::Handler handler) { getHandlers_.push_back(std::make_pair(new RestApiPath(path), handler)); } void RestApi::Register(const std::string& path, - PutHandler handler) + RestApiPutCall::Handler handler) { putHandlers_.push_back(std::make_pair(new RestApiPath(path), handler)); } void RestApi::Register(const std::string& path, - PostHandler handler) + RestApiPostCall::Handler handler) { postHandlers_.push_back(std::make_pair(new RestApiPath(path), handler)); } void RestApi::Register(const std::string& path, - DeleteHandler handler) + RestApiDeleteCall::Handler handler) { deleteHandlers_.push_back(std::make_pair(new RestApiPath(path), handler)); } diff -r ab6475e33473 -r 6968356679c0 Core/RestApi/RestApi.h --- a/Core/RestApi/RestApi.h Mon Jun 30 14:08:51 2014 +0200 +++ b/Core/RestApi/RestApi.h Mon Jun 30 14:55:43 2014 +0200 @@ -35,6 +35,10 @@ #include "../HttpServer/HttpHandler.h" #include "RestApiPath.h" #include "RestApiOutput.h" +#include "RestApiGetCall.h" +#include "RestApiPutCall.h" +#include "RestApiPostCall.h" +#include "RestApiDeleteCall.h" #include @@ -42,215 +46,11 @@ { class RestApi : public HttpHandler { - public: - class Call - { - friend class RestApi; - - private: - RestApiOutput& output_; - RestApi& context_; - const HttpHandler::Arguments& httpHeaders_; - const RestApiPath::Components& uriComponents_; - const UriComponents& trailing_; - const UriComponents& fullUri_; - - Call(RestApiOutput& output, - RestApi& context, - const HttpHandler::Arguments& httpHeaders, - const RestApiPath::Components& uriComponents, - const UriComponents& trailing, - const UriComponents& fullUri) : - output_(output), - context_(context), - httpHeaders_(httpHeaders), - uriComponents_(uriComponents), - trailing_(trailing), - fullUri_(fullUri) - { - } - - protected: - static bool ParseJsonRequestInternal(Json::Value& result, - const char* request); - - public: - RestApiOutput& GetOutput() - { - return output_; - } - - RestApi& GetContext() - { - return context_; - } - - const UriComponents& GetFullUri() const - { - return fullUri_; - } - - const UriComponents& GetTrailingUri() const - { - return trailing_; - } - - std::string GetUriComponent(const std::string& name, - const std::string& defaultValue) const - { - return HttpHandler::GetArgument(uriComponents_, name, defaultValue); - } - - std::string GetHttpHeader(const std::string& name, - const std::string& defaultValue) const - { - return HttpHandler::GetArgument(httpHeaders_, name, defaultValue); - } - - const HttpHandler::Arguments& GetHttpHeaders() const - { - return httpHeaders_; - } - - void ParseCookies(HttpHandler::Arguments& result) const - { - HttpHandler::ParseCookies(result, httpHeaders_); - } - - virtual bool ParseJsonRequest(Json::Value& result) const = 0; - }; - - - class GetCall : public Call - { - friend class RestApi; - - private: - const HttpHandler::Arguments& getArguments_; - - public: - GetCall(RestApiOutput& output, - RestApi& context, - const HttpHandler::Arguments& httpHeaders, - const RestApiPath::Components& uriComponents, - const UriComponents& trailing, - const UriComponents& fullUri, - const HttpHandler::Arguments& getArguments) : - Call(output, context, httpHeaders, uriComponents, trailing, fullUri), - getArguments_(getArguments) - { - } - - std::string GetArgument(const std::string& name, - const std::string& defaultValue) const - { - return HttpHandler::GetArgument(getArguments_, name, defaultValue); - } - - bool HasArgument(const std::string& name) const - { - return getArguments_.find(name) != getArguments_.end(); - } - - virtual bool ParseJsonRequest(Json::Value& result) const; - }; - - - class PutCall : public Call - { - friend class RestApi; - - private: - const std::string& data_; - - public: - PutCall(RestApiOutput& output, - RestApi& context, - const HttpHandler::Arguments& httpHeaders, - const RestApiPath::Components& uriComponents, - const UriComponents& trailing, - const UriComponents& fullUri, - const std::string& data) : - Call(output, context, httpHeaders, uriComponents, trailing, fullUri), - data_(data) - { - } - - const std::string& GetPutBody() const - { - return data_; - } - - virtual bool ParseJsonRequest(Json::Value& result) const - { - return ParseJsonRequestInternal(result, GetPutBody().c_str()); - } - }; - - class PostCall : public Call - { - friend class RestApi; - - private: - const std::string& data_; - - public: - PostCall(RestApiOutput& output, - RestApi& context, - const HttpHandler::Arguments& httpHeaders, - const RestApiPath::Components& uriComponents, - const UriComponents& trailing, - const UriComponents& fullUri, - const std::string& data) : - Call(output, context, httpHeaders, uriComponents, trailing, fullUri), - data_(data) - { - } - - const std::string& GetPostBody() const - { - return data_; - } - - virtual bool ParseJsonRequest(Json::Value& result) const - { - return ParseJsonRequestInternal(result, GetPostBody().c_str()); - } - }; - - class DeleteCall : public Call - { - public: - DeleteCall(RestApiOutput& output, - RestApi& context, - const HttpHandler::Arguments& httpHeaders, - const RestApiPath::Components& uriComponents, - const UriComponents& trailing, - const UriComponents& fullUri) : - Call(output, context, httpHeaders, uriComponents, trailing, fullUri) - { - } - - virtual bool ParseJsonRequest(Json::Value& result) const - { - result.clear(); - return true; - } - }; - - typedef void (*GetHandler) (GetCall& call); - - typedef void (*DeleteHandler) (DeleteCall& call); - - typedef void (*PutHandler) (PutCall& call); - - typedef void (*PostHandler) (PostCall& call); - private: - typedef std::list< std::pair > GetHandlers; - typedef std::list< std::pair > PutHandlers; - typedef std::list< std::pair > PostHandlers; - typedef std::list< std::pair > DeleteHandlers; + typedef std::list< std::pair > GetHandlers; + typedef std::list< std::pair > PutHandlers; + typedef std::list< std::pair > PostHandlers; + typedef std::list< std::pair > DeleteHandlers; GetHandlers getHandlers_; PutHandlers putHandlers_; @@ -279,15 +79,15 @@ const std::string& postData); void Register(const std::string& path, - GetHandler handler); + RestApiGetCall::Handler handler); void Register(const std::string& path, - PutHandler handler); + RestApiPutCall::Handler handler); void Register(const std::string& path, - PostHandler handler); + RestApiPostCall::Handler handler); void Register(const std::string& path, - DeleteHandler handler); + RestApiDeleteCall::Handler handler); }; } diff -r ab6475e33473 -r 6968356679c0 Core/RestApi/RestApiCall.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/Core/RestApi/RestApiCall.cpp Mon Jun 30 14:55:43 2014 +0200 @@ -0,0 +1,44 @@ +/** + * Orthanc - A Lightweight, RESTful DICOM Store + * Copyright (C) 2012-2014 Medical Physics Department, CHU of Liege, + * Belgium + * + * This program is free software: you can redistribute it and/or + * modify it under the terms of the GNU General Public License as + * published by the Free Software Foundation, either version 3 of the + * License, or (at your option) any later version. + * + * In addition, as a special exception, the copyright holders of this + * program give permission to link the code of its release with the + * OpenSSL project's "OpenSSL" library (or with modified versions of it + * that use the same license as the "OpenSSL" library), and distribute + * the linked executables. You must obey the GNU General Public License + * in all respects for all of the code used other than "OpenSSL". If you + * modify file(s) with this exception, you may extend this exception to + * your version of the file(s), but you are not obligated to do so. If + * you do not wish to do so, delete this exception statement from your + * version. If you delete this exception statement from all source files + * in the program, then also delete it here. + * + * This program is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + **/ + + +#include "RestApiCall.h" + +namespace Orthanc +{ + bool RestApiCall::ParseJsonRequestInternal(Json::Value& result, + const char* request) + { + result.clear(); + Json::Reader reader; + return reader.parse(request, result); + } +} diff -r ab6475e33473 -r 6968356679c0 Core/RestApi/RestApiCall.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/Core/RestApi/RestApiCall.h Mon Jun 30 14:55:43 2014 +0200 @@ -0,0 +1,117 @@ +/** + * Orthanc - A Lightweight, RESTful DICOM Store + * Copyright (C) 2012-2014 Medical Physics Department, CHU of Liege, + * Belgium + * + * This program is free software: you can redistribute it and/or + * modify it under the terms of the GNU General Public License as + * published by the Free Software Foundation, either version 3 of the + * License, or (at your option) any later version. + * + * In addition, as a special exception, the copyright holders of this + * program give permission to link the code of its release with the + * OpenSSL project's "OpenSSL" library (or with modified versions of it + * that use the same license as the "OpenSSL" library), and distribute + * the linked executables. You must obey the GNU General Public License + * in all respects for all of the code used other than "OpenSSL". If you + * modify file(s) with this exception, you may extend this exception to + * your version of the file(s), but you are not obligated to do so. If + * you do not wish to do so, delete this exception statement from your + * version. If you delete this exception statement from all source files + * in the program, then also delete it here. + * + * This program is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + **/ + + +#pragma once + +#include "../HttpServer/HttpHandler.h" +#include "RestApiPath.h" +#include "RestApiOutput.h" + +namespace Orthanc +{ + class RestApi; + + class RestApiCall + { + private: + RestApiOutput& output_; + RestApi& context_; + const HttpHandler::Arguments& httpHeaders_; + const HttpHandler::Arguments& uriComponents_; + const UriComponents& trailing_; + const UriComponents& fullUri_; + + protected: + static bool ParseJsonRequestInternal(Json::Value& result, + const char* request); + + public: + RestApiCall(RestApiOutput& output, + RestApi& context, + const HttpHandler::Arguments& httpHeaders, + const HttpHandler::Arguments& uriComponents, + const UriComponents& trailing, + const UriComponents& fullUri) : + output_(output), + context_(context), + httpHeaders_(httpHeaders), + uriComponents_(uriComponents), + trailing_(trailing), + fullUri_(fullUri) + { + } + + RestApiOutput& GetOutput() + { + return output_; + } + + RestApi& GetContext() + { + return context_; + } + + const UriComponents& GetFullUri() const + { + return fullUri_; + } + + const UriComponents& GetTrailingUri() const + { + return trailing_; + } + + std::string GetUriComponent(const std::string& name, + const std::string& defaultValue) const + { + return HttpHandler::GetArgument(uriComponents_, name, defaultValue); + } + + std::string GetHttpHeader(const std::string& name, + const std::string& defaultValue) const + { + return HttpHandler::GetArgument(httpHeaders_, name, defaultValue); + } + + const HttpHandler::Arguments& GetHttpHeaders() const + { + return httpHeaders_; + } + + void ParseCookies(HttpHandler::Arguments& result) const + { + HttpHandler::ParseCookies(result, httpHeaders_); + } + + virtual bool ParseJsonRequest(Json::Value& result) const = 0; + }; +} diff -r ab6475e33473 -r 6968356679c0 Core/RestApi/RestApiDeleteCall.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/Core/RestApi/RestApiDeleteCall.h Mon Jun 30 14:55:43 2014 +0200 @@ -0,0 +1,60 @@ +/** + * Orthanc - A Lightweight, RESTful DICOM Store + * Copyright (C) 2012-2014 Medical Physics Department, CHU of Liege, + * Belgium + * + * This program is free software: you can redistribute it and/or + * modify it under the terms of the GNU General Public License as + * published by the Free Software Foundation, either version 3 of the + * License, or (at your option) any later version. + * + * In addition, as a special exception, the copyright holders of this + * program give permission to link the code of its release with the + * OpenSSL project's "OpenSSL" library (or with modified versions of it + * that use the same license as the "OpenSSL" library), and distribute + * the linked executables. You must obey the GNU General Public License + * in all respects for all of the code used other than "OpenSSL". If you + * modify file(s) with this exception, you may extend this exception to + * your version of the file(s), but you are not obligated to do so. If + * you do not wish to do so, delete this exception statement from your + * version. If you delete this exception statement from all source files + * in the program, then also delete it here. + * + * This program is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + **/ + + +#pragma once + +#include "RestApiCall.h" + +namespace Orthanc +{ + class RestApiDeleteCall : public RestApiCall + { + public: + typedef void (*Handler) (RestApiDeleteCall& call); + + RestApiDeleteCall(RestApiOutput& output, + RestApi& context, + const HttpHandler::Arguments& httpHeaders, + const HttpHandler::Arguments& uriComponents, + const UriComponents& trailing, + const UriComponents& fullUri) : + RestApiCall(output, context, httpHeaders, uriComponents, trailing, fullUri) + { + } + + virtual bool ParseJsonRequest(Json::Value& result) const + { + result.clear(); + return true; + } + }; +} diff -r ab6475e33473 -r 6968356679c0 Core/RestApi/RestApiGetCall.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/Core/RestApi/RestApiGetCall.cpp Mon Jun 30 14:55:43 2014 +0200 @@ -0,0 +1,49 @@ +/** + * Orthanc - A Lightweight, RESTful DICOM Store + * Copyright (C) 2012-2014 Medical Physics Department, CHU of Liege, + * Belgium + * + * This program is free software: you can redistribute it and/or + * modify it under the terms of the GNU General Public License as + * published by the Free Software Foundation, either version 3 of the + * License, or (at your option) any later version. + * + * In addition, as a special exception, the copyright holders of this + * program give permission to link the code of its release with the + * OpenSSL project's "OpenSSL" library (or with modified versions of it + * that use the same license as the "OpenSSL" library), and distribute + * the linked executables. You must obey the GNU General Public License + * in all respects for all of the code used other than "OpenSSL". If you + * modify file(s) with this exception, you may extend this exception to + * your version of the file(s), but you are not obligated to do so. If + * you do not wish to do so, delete this exception statement from your + * version. If you delete this exception statement from all source files + * in the program, then also delete it here. + * + * This program is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + **/ + + +#include "RestApiGetCall.h" + +namespace Orthanc +{ + bool RestApiGetCall::ParseJsonRequest(Json::Value& result) const + { + result.clear(); + + for (HttpHandler::Arguments::const_iterator + it = getArguments_.begin(); it != getArguments_.end(); ++it) + { + result[it->first] = it->second; + } + + return true; + } +} diff -r ab6475e33473 -r 6968356679c0 Core/RestApi/RestApiGetCall.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/Core/RestApi/RestApiGetCall.h Mon Jun 30 14:55:43 2014 +0200 @@ -0,0 +1,72 @@ +/** + * Orthanc - A Lightweight, RESTful DICOM Store + * Copyright (C) 2012-2014 Medical Physics Department, CHU of Liege, + * Belgium + * + * This program is free software: you can redistribute it and/or + * modify it under the terms of the GNU General Public License as + * published by the Free Software Foundation, either version 3 of the + * License, or (at your option) any later version. + * + * In addition, as a special exception, the copyright holders of this + * program give permission to link the code of its release with the + * OpenSSL project's "OpenSSL" library (or with modified versions of it + * that use the same license as the "OpenSSL" library), and distribute + * the linked executables. You must obey the GNU General Public License + * in all respects for all of the code used other than "OpenSSL". If you + * modify file(s) with this exception, you may extend this exception to + * your version of the file(s), but you are not obligated to do so. If + * you do not wish to do so, delete this exception statement from your + * version. If you delete this exception statement from all source files + * in the program, then also delete it here. + * + * This program is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + **/ + + +#pragma once + +#include "RestApiCall.h" + +namespace Orthanc +{ + class RestApiGetCall : public RestApiCall + { + private: + const HttpHandler::Arguments& getArguments_; + + public: + typedef void (*Handler) (RestApiGetCall& call); + + RestApiGetCall(RestApiOutput& output, + RestApi& context, + const HttpHandler::Arguments& httpHeaders, + const HttpHandler::Arguments& uriComponents, + const UriComponents& trailing, + const UriComponents& fullUri, + const HttpHandler::Arguments& getArguments) : + RestApiCall(output, context, httpHeaders, uriComponents, trailing, fullUri), + getArguments_(getArguments) + { + } + + std::string GetArgument(const std::string& name, + const std::string& defaultValue) const + { + return HttpHandler::GetArgument(getArguments_, name, defaultValue); + } + + bool HasArgument(const std::string& name) const + { + return getArguments_.find(name) != getArguments_.end(); + } + + virtual bool ParseJsonRequest(Json::Value& result) const; + }; +} diff -r ab6475e33473 -r 6968356679c0 Core/RestApi/RestApiHierarchy.cpp --- a/Core/RestApi/RestApiHierarchy.cpp Mon Jun 30 14:08:51 2014 +0200 +++ b/Core/RestApi/RestApiHierarchy.cpp Mon Jun 30 14:55:43 2014 +0200 @@ -32,6 +32,8 @@ #include "RestApiHierarchy.h" +#include "../OrthancException.h" + #include namespace Orthanc @@ -76,25 +78,25 @@ } - RestApi::GetHandler RestApiHierarchy::Handlers::GetGetHandler() const + RestApiGetCall::Handler RestApiHierarchy::Handlers::GetGetHandler() const { assert(getHandler_ != NULL); return getHandler_; } - RestApi::PutHandler RestApiHierarchy::Handlers::GetPutHandler() const + RestApiPutCall::Handler RestApiHierarchy::Handlers::GetPutHandler() const { assert(putHandler_ != NULL); return putHandler_; } - RestApi::PostHandler RestApiHierarchy::Handlers::GetPostHandler() const + RestApiPostCall::Handler RestApiHierarchy::Handlers::GetPostHandler() const { assert(postHandler_ != NULL); return postHandler_; } - RestApi::DeleteHandler RestApiHierarchy::Handlers::GetDeleteHandler() const + RestApiDeleteCall::Handler RestApiHierarchy::Handlers::GetDeleteHandler() const { assert(deleteHandler_ != NULL); return deleteHandler_; @@ -163,7 +165,7 @@ } - bool RestApiHierarchy::LookupHandler(RestApiPath::Components& components, + bool RestApiHierarchy::LookupHandler(HttpHandler::Arguments& components, const UriComponents& uri, ResourceCallback callback, size_t level, @@ -198,7 +200,7 @@ for (child = wildcardChildren_.begin(); child != wildcardChildren_.end(); child++) { - RestApiPath::Components subComponents = components; + HttpHandler::Arguments subComponents = components; subComponents[child->first] = uri[level]; if (child->second->LookupHandler(components, uri, callback, level + 1, call)) @@ -280,13 +282,13 @@ bool RestApiHierarchy::GetCallback(Handlers& handlers, const UriComponents& uri, - const RestApiPath::Components& components, + const HttpHandler::Arguments& components, const UriComponents& trailing, void* call) { if (handlers.HasHandler(HttpMethod_Get)) { - handlers.GetGetHandler() (*reinterpret_cast(call)); + handlers.GetGetHandler() (*reinterpret_cast(call)); return true; } else @@ -298,13 +300,13 @@ bool RestApiHierarchy::PostCallback(Handlers& handlers, const UriComponents& uri, - const RestApiPath::Components& components, + const HttpHandler::Arguments& components, const UriComponents& trailing, void* call) { if (handlers.HasHandler(HttpMethod_Post)) { - handlers.GetPostHandler() (*reinterpret_cast(call)); + handlers.GetPostHandler() (*reinterpret_cast(call)); return true; } else @@ -316,13 +318,13 @@ bool RestApiHierarchy::PutCallback(Handlers& handlers, const UriComponents& uri, - const RestApiPath::Components& components, + const HttpHandler::Arguments& components, const UriComponents& trailing, void* call) { if (handlers.HasHandler(HttpMethod_Put)) { - handlers.GetPutHandler() (*reinterpret_cast(call)); + handlers.GetPutHandler() (*reinterpret_cast(call)); return true; } else @@ -334,13 +336,13 @@ bool RestApiHierarchy::DeleteCallback(Handlers& handlers, const UriComponents& uri, - const RestApiPath::Components& components, + const HttpHandler::Arguments& components, const UriComponents& trailing, void* call) { if (handlers.HasHandler(HttpMethod_Delete)) { - handlers.GetDeleteHandler() (*reinterpret_cast(call)); + handlers.GetDeleteHandler() (*reinterpret_cast(call)); return true; } else @@ -357,28 +359,28 @@ } void RestApiHierarchy::Register(const std::string& uri, - RestApi::GetHandler handler) + RestApiGetCall::Handler handler) { RestApiPath path(uri); RegisterInternal(path, handler, 0); } void RestApiHierarchy::Register(const std::string& uri, - RestApi::PutHandler handler) + RestApiPutCall::Handler handler) { RestApiPath path(uri); RegisterInternal(path, handler, 0); } void RestApiHierarchy::Register(const std::string& uri, - RestApi::PostHandler handler) + RestApiPostCall::Handler handler) { RestApiPath path(uri); RegisterInternal(path, handler, 0); } void RestApiHierarchy::Register(const std::string& uri, - RestApi::DeleteHandler handler) + RestApiDeleteCall::Handler handler) { RestApiPath path(uri); RegisterInternal(path, handler, 0); @@ -429,31 +431,31 @@ }*/ } - bool RestApiHierarchy::Handle(RestApi::GetCall& call, + bool RestApiHierarchy::Handle(RestApiGetCall& call, const UriComponents& uri) { - RestApiPath::Components components; + HttpHandler::Arguments components; return LookupHandler(components, uri, GetCallback, 0, &call); } - bool RestApiHierarchy::Handle(RestApi::PutCall& call, + bool RestApiHierarchy::Handle(RestApiPutCall& call, const UriComponents& uri) { - RestApiPath::Components components; + HttpHandler::Arguments components; return LookupHandler(components, uri, PutCallback, 0, &call); } - bool RestApiHierarchy::Handle(RestApi::PostCall& call, + bool RestApiHierarchy::Handle(RestApiPostCall& call, const UriComponents& uri) { - RestApiPath::Components components; + HttpHandler::Arguments components; return LookupHandler(components, uri, PostCallback, 0, &call); } - bool RestApiHierarchy::Handle(RestApi::DeleteCall& call, + bool RestApiHierarchy::Handle(RestApiDeleteCall& call, const UriComponents& uri) { - RestApiPath::Components components; + HttpHandler::Arguments components; return LookupHandler(components, uri, DeleteCallback, 0, &call); } diff -r ab6475e33473 -r 6968356679c0 Core/RestApi/RestApiHierarchy.h --- a/Core/RestApi/RestApiHierarchy.h Mon Jun 30 14:08:51 2014 +0200 +++ b/Core/RestApi/RestApiHierarchy.h Mon Jun 30 14:55:43 2014 +0200 @@ -32,12 +32,10 @@ #pragma once -#include "RestApi.h" - -#include "../OrthancException.h" - -#include -#include +#include "RestApiGetCall.h" +#include "RestApiPostCall.h" +#include "RestApiPutCall.h" +#include "RestApiDeleteCall.h" namespace Orthanc { @@ -47,40 +45,40 @@ class Handlers { private: - RestApi::GetHandler getHandler_; - RestApi::PostHandler postHandler_; - RestApi::PutHandler putHandler_; - RestApi::DeleteHandler deleteHandler_; + RestApiGetCall::Handler getHandler_; + RestApiPostCall::Handler postHandler_; + RestApiPutCall::Handler putHandler_; + RestApiDeleteCall::Handler deleteHandler_; public: Handlers(); bool HasHandler(HttpMethod method) const; - RestApi::GetHandler GetGetHandler() const; + RestApiGetCall::Handler GetGetHandler() const; - RestApi::PutHandler GetPutHandler() const; + RestApiPutCall::Handler GetPutHandler() const; - RestApi::PostHandler GetPostHandler() const; + RestApiPostCall::Handler GetPostHandler() const; - RestApi::DeleteHandler GetDeleteHandler() const; + RestApiDeleteCall::Handler GetDeleteHandler() const; - void Register(RestApi::GetHandler handler) + void Register(RestApiGetCall::Handler handler) { getHandler_ = handler; } - void Register(RestApi::PutHandler handler) + void Register(RestApiPutCall::Handler handler) { putHandler_ = handler; } - void Register(RestApi::PostHandler handler) + void Register(RestApiPostCall::Handler handler) { postHandler_ = handler; } - void Register(RestApi::DeleteHandler handler) + void Register(RestApiDeleteCall::Handler handler) { deleteHandler_ = handler; } @@ -92,7 +90,7 @@ typedef std::map Children; typedef bool (*ResourceCallback) (Handlers& handlers, const UriComponents& uri, - const RestApiPath::Components& components, + const HttpHandler::Arguments& components, const UriComponents& trailing, void* call); @@ -112,7 +110,7 @@ Handler handler, size_t level); - bool LookupHandler(RestApiPath::Components& components, + bool LookupHandler(HttpHandler::Arguments& components, const UriComponents& uri, ResourceCallback callback, size_t level, @@ -124,25 +122,25 @@ static bool GetCallback(Handlers& handlers, const UriComponents& uri, - const RestApiPath::Components& components, + const HttpHandler::Arguments& components, const UriComponents& trailing, void* call); static bool PostCallback(Handlers& handlers, const UriComponents& uri, - const RestApiPath::Components& components, + const HttpHandler::Arguments& components, const UriComponents& trailing, void* call); static bool PutCallback(Handlers& handlers, const UriComponents& uri, - const RestApiPath::Components& components, + const HttpHandler::Arguments& components, const UriComponents& trailing, void* call); static bool DeleteCallback(Handlers& handlers, const UriComponents& uri, - const RestApiPath::Components& components, + const HttpHandler::Arguments& components, const UriComponents& trailing, void* call); @@ -151,16 +149,16 @@ ~RestApiHierarchy(); void Register(const std::string& uri, - RestApi::GetHandler handler); + RestApiGetCall::Handler handler); void Register(const std::string& uri, - RestApi::PutHandler handler); + RestApiPutCall::Handler handler); void Register(const std::string& uri, - RestApi::PostHandler handler); + RestApiPostCall::Handler handler); void Register(const std::string& uri, - RestApi::DeleteHandler handler); + RestApiDeleteCall::Handler handler); void CreateSiteMap(Json::Value& target) const; @@ -170,16 +168,16 @@ return GetDirectory(result, uri, 0); } - bool Handle(RestApi::GetCall& call, + bool Handle(RestApiGetCall& call, const UriComponents& uri); - bool Handle(RestApi::PutCall& call, + bool Handle(RestApiPutCall& call, const UriComponents& uri); - bool Handle(RestApi::PostCall& call, + bool Handle(RestApiPostCall& call, const UriComponents& uri); - bool Handle(RestApi::DeleteCall& call, + bool Handle(RestApiDeleteCall& call, const UriComponents& uri); }; } diff -r ab6475e33473 -r 6968356679c0 Core/RestApi/RestApiPath.cpp --- a/Core/RestApi/RestApiPath.cpp Mon Jun 30 14:08:51 2014 +0200 +++ b/Core/RestApi/RestApiPath.cpp Mon Jun 30 14:55:43 2014 +0200 @@ -78,7 +78,7 @@ } } - bool RestApiPath::Match(Components& components, + bool RestApiPath::Match(HttpHandler::Arguments& components, UriComponents& trailing, const std::string& uriRaw) const { @@ -87,7 +87,7 @@ return Match(components, trailing, uri); } - bool RestApiPath::Match(Components& components, + bool RestApiPath::Match(HttpHandler::Arguments& components, UriComponents& trailing, const UriComponents& uri) const { @@ -135,7 +135,7 @@ bool RestApiPath::Match(const UriComponents& uri) const { - Components components; + HttpHandler::Arguments components; UriComponents trailing; return Match(components, trailing, uri); } diff -r ab6475e33473 -r 6968356679c0 Core/RestApi/RestApiPath.h --- a/Core/RestApi/RestApiPath.h Mon Jun 30 14:08:51 2014 +0200 +++ b/Core/RestApi/RestApiPath.h Mon Jun 30 14:55:43 2014 +0200 @@ -33,6 +33,8 @@ #pragma once #include "../Toolbox.h" +#include "../HttpServer/HttpHandler.h" + #include namespace Orthanc @@ -45,16 +47,14 @@ std::vector components_; public: - typedef std::map Components; - RestApiPath(const std::string& uri); // This version is slower - bool Match(Components& components, + bool Match(HttpHandler::Arguments& components, UriComponents& trailing, const std::string& uriRaw) const; - bool Match(Components& components, + bool Match(HttpHandler::Arguments& components, UriComponents& trailing, const UriComponents& uri) const; diff -r ab6475e33473 -r 6968356679c0 Core/RestApi/RestApiPostCall.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/Core/RestApi/RestApiPostCall.h Mon Jun 30 14:55:43 2014 +0200 @@ -0,0 +1,69 @@ +/** + * Orthanc - A Lightweight, RESTful DICOM Store + * Copyright (C) 2012-2014 Medical Physics Department, CHU of Liege, + * Belgium + * + * This program is free software: you can redistribute it and/or + * modify it under the terms of the GNU General Public License as + * published by the Free Software Foundation, either version 3 of the + * License, or (at your option) any later version. + * + * In addition, as a special exception, the copyright holders of this + * program give permission to link the code of its release with the + * OpenSSL project's "OpenSSL" library (or with modified versions of it + * that use the same license as the "OpenSSL" library), and distribute + * the linked executables. You must obey the GNU General Public License + * in all respects for all of the code used other than "OpenSSL". If you + * modify file(s) with this exception, you may extend this exception to + * your version of the file(s), but you are not obligated to do so. If + * you do not wish to do so, delete this exception statement from your + * version. If you delete this exception statement from all source files + * in the program, then also delete it here. + * + * This program is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + **/ + + +#pragma once + +#include "RestApiCall.h" + +namespace Orthanc +{ + class RestApiPostCall : public RestApiCall + { + private: + const std::string& data_; + + public: + typedef void (*Handler) (RestApiPostCall& call); + + RestApiPostCall(RestApiOutput& output, + RestApi& context, + const HttpHandler::Arguments& httpHeaders, + const HttpHandler::Arguments& uriComponents, + const UriComponents& trailing, + const UriComponents& fullUri, + const std::string& data) : + RestApiCall(output, context, httpHeaders, uriComponents, trailing, fullUri), + data_(data) + { + } + + const std::string& GetPostBody() const + { + return data_; + } + + virtual bool ParseJsonRequest(Json::Value& result) const + { + return ParseJsonRequestInternal(result, GetPostBody().c_str()); + } + }; +} diff -r ab6475e33473 -r 6968356679c0 Core/RestApi/RestApiPutCall.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/Core/RestApi/RestApiPutCall.h Mon Jun 30 14:55:43 2014 +0200 @@ -0,0 +1,69 @@ +/** + * Orthanc - A Lightweight, RESTful DICOM Store + * Copyright (C) 2012-2014 Medical Physics Department, CHU of Liege, + * Belgium + * + * This program is free software: you can redistribute it and/or + * modify it under the terms of the GNU General Public License as + * published by the Free Software Foundation, either version 3 of the + * License, or (at your option) any later version. + * + * In addition, as a special exception, the copyright holders of this + * program give permission to link the code of its release with the + * OpenSSL project's "OpenSSL" library (or with modified versions of it + * that use the same license as the "OpenSSL" library), and distribute + * the linked executables. You must obey the GNU General Public License + * in all respects for all of the code used other than "OpenSSL". If you + * modify file(s) with this exception, you may extend this exception to + * your version of the file(s), but you are not obligated to do so. If + * you do not wish to do so, delete this exception statement from your + * version. If you delete this exception statement from all source files + * in the program, then also delete it here. + * + * This program is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + **/ + + +#pragma once + +#include "RestApiCall.h" + +namespace Orthanc +{ + class RestApiPutCall : public RestApiCall + { + private: + const std::string& data_; + + public: + typedef void (*Handler) (RestApiPutCall& call); + + RestApiPutCall(RestApiOutput& output, + RestApi& context, + const HttpHandler::Arguments& httpHeaders, + const HttpHandler::Arguments& uriComponents, + const UriComponents& trailing, + const UriComponents& fullUri, + const std::string& data) : + RestApiCall(output, context, httpHeaders, uriComponents, trailing, fullUri), + data_(data) + { + } + + const std::string& GetPutBody() const + { + return data_; + } + + virtual bool ParseJsonRequest(Json::Value& result) const + { + return ParseJsonRequestInternal(result, GetPutBody().c_str()); + } + }; +} diff -r ab6475e33473 -r 6968356679c0 OrthancServer/OrthancRestApi/OrthancRestAnonymizeModify.cpp --- a/OrthancServer/OrthancRestApi/OrthancRestAnonymizeModify.cpp Mon Jun 30 14:08:51 2014 +0200 +++ b/OrthancServer/OrthancRestApi/OrthancRestAnonymizeModify.cpp Mon Jun 30 14:55:43 2014 +0200 @@ -112,7 +112,7 @@ static bool ParseModifyRequest(DicomModification& target, - const RestApi::PostCall& call) + const RestApiPostCall& call) { // curl http://localhost:8042/series/95a6e2bf-9296e2cc-bf614e2f-22b391ee-16e010e0/modify -X POST -d '{"Replace":{"InstitutionName":"My own clinic"}}' @@ -144,7 +144,7 @@ static bool ParseAnonymizationRequest(DicomModification& target, - RestApi::PostCall& call) + RestApiPostCall& call) { // curl http://localhost:8042/instances/6e67da51-d119d6ae-c5667437-87b9a8a5-0f07c49f/anonymize -X POST -d '{"Replace":{"PatientName":"hello","0010-0020":"world"},"Keep":["StudyDescription", "SeriesDescription"],"KeepPrivateTags": null,"Remove":["Modality"]}' > Anonymized.dcm @@ -191,7 +191,7 @@ static void AnonymizeOrModifyInstance(DicomModification& modification, - RestApi::PostCall& call) + RestApiPostCall& call) { std::string id = call.GetUriComponent("id", ""); @@ -207,7 +207,7 @@ MetadataType metadataType, ChangeType changeType, ResourceType resourceType, - RestApi::PostCall& call) + RestApiPostCall& call) { bool isFirst = true; Json::Value result(Json::objectValue); @@ -333,7 +333,7 @@ - static void ModifyInstance(RestApi::PostCall& call) + static void ModifyInstance(RestApiPostCall& call) { DicomModification modification; @@ -361,7 +361,7 @@ } - static void AnonymizeInstance(RestApi::PostCall& call) + static void AnonymizeInstance(RestApiPostCall& call) { DicomModification modification; @@ -374,7 +374,7 @@ template - static void ModifyResource(RestApi::PostCall& call) + static void ModifyResource(RestApiPostCall& call) { DicomModification modification; @@ -389,7 +389,7 @@ template - static void AnonymizeResource(RestApi::PostCall& call) + static void AnonymizeResource(RestApiPostCall& call) { DicomModification modification; @@ -401,7 +401,7 @@ } - static void Create(RestApi::PostCall& call) + static void Create(RestApiPostCall& call) { // curl http://localhost:8042/tools/create-dicom -X POST -d '{"PatientName":"Hello^World"}' // curl http://localhost:8042/tools/create-dicom -X POST -d '{"PatientName":"Hello^World","PixelData":"data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAAAAAA6mKC9AAAACXBIWXMAAAsTAAALEwEAmpwYAAAAB3RJTUUH3gUGDDcB53FulQAAAElJREFUGNNtj0sSAEEEQ1+U+185s1CtmRkblQ9CZldsKHJDk6DLGLJa6chjh0ooQmpjXMM86zPwydGEj6Ed/UGykkEM8X+p3u8/8LcOJIWLGeMAAAAASUVORK5CYII="}' diff -r ab6475e33473 -r 6968356679c0 OrthancServer/OrthancRestApi/OrthancRestApi.cpp --- a/OrthancServer/OrthancRestApi/OrthancRestApi.cpp Mon Jun 30 14:08:51 2014 +0200 +++ b/OrthancServer/OrthancRestApi/OrthancRestApi.cpp Mon Jun 30 14:55:43 2014 +0200 @@ -39,9 +39,9 @@ namespace Orthanc { - void OrthancRestApi::AnswerStoredInstance(RestApi::PostCall& call, + void OrthancRestApi::AnswerStoredInstance(RestApiPostCall& call, const std::string& publicId, - StoreStatus status) + StoreStatus status) const { Json::Value result = Json::objectValue; @@ -59,7 +59,7 @@ // Upload of DICOM files through HTTP --------------------------------------- - static void UploadDicomFile(RestApi::PostCall& call) + static void UploadDicomFile(RestApiPostCall& call) { ServerContext& context = OrthancRestApi::GetContext(call); diff -r ab6475e33473 -r 6968356679c0 OrthancServer/OrthancRestApi/OrthancRestApi.h --- a/OrthancServer/OrthancRestApi/OrthancRestApi.h Mon Jun 30 14:08:51 2014 +0200 +++ b/OrthancServer/OrthancRestApi/OrthancRestApi.h Mon Jun 30 14:55:43 2014 +0200 @@ -62,23 +62,23 @@ public: OrthancRestApi(ServerContext& context); - static OrthancRestApi& GetApi(RestApi::Call& call) + static OrthancRestApi& GetApi(RestApiCall& call) { return dynamic_cast(call.GetContext()); } - static ServerContext& GetContext(RestApi::Call& call) + static ServerContext& GetContext(RestApiCall& call) { return GetApi(call).context_; } - static ServerIndex& GetIndex(RestApi::Call& call) + static ServerIndex& GetIndex(RestApiCall& call) { return GetContext(call).GetIndex(); } - void AnswerStoredInstance(RestApi::PostCall& call, + void AnswerStoredInstance(RestApiPostCall& call, const std::string& publicId, - StoreStatus status); + StoreStatus status) const; }; } diff -r ab6475e33473 -r 6968356679c0 OrthancServer/OrthancRestApi/OrthancRestArchive.cpp --- a/OrthancServer/OrthancRestApi/OrthancRestArchive.cpp Mon Jun 30 14:08:51 2014 +0200 +++ b/OrthancServer/OrthancRestApi/OrthancRestArchive.cpp Mon Jun 30 14:55:43 2014 +0200 @@ -234,7 +234,7 @@ } template - static void GetArchive(RestApi::GetCall& call) + static void GetArchive(RestApiGetCall& call) { ServerContext& context = OrthancRestApi::GetContext(call); diff -r ab6475e33473 -r 6968356679c0 OrthancServer/OrthancRestApi/OrthancRestChanges.cpp --- a/OrthancServer/OrthancRestApi/OrthancRestChanges.cpp Mon Jun 30 14:08:51 2014 +0200 +++ b/OrthancServer/OrthancRestApi/OrthancRestChanges.cpp Mon Jun 30 14:55:43 2014 +0200 @@ -42,7 +42,7 @@ static void GetSinceAndLimit(int64_t& since, unsigned int& limit, bool& last, - const RestApi::GetCall& call) + const RestApiGetCall& call) { static const unsigned int MAX_RESULTS = 100; @@ -70,7 +70,7 @@ } } - static void GetChanges(RestApi::GetCall& call) + static void GetChanges(RestApiGetCall& call) { ServerContext& context = OrthancRestApi::GetContext(call); @@ -89,7 +89,7 @@ } - static void DeleteChanges(RestApi::DeleteCall& call) + static void DeleteChanges(RestApiDeleteCall& call) { OrthancRestApi::GetIndex(call).DeleteChanges(); call.GetOutput().AnswerBuffer("", "text/plain"); @@ -98,7 +98,7 @@ // Exports API -------------------------------------------------------------- - static void GetExports(RestApi::GetCall& call) + static void GetExports(RestApiGetCall& call) { ServerContext& context = OrthancRestApi::GetContext(call); @@ -116,7 +116,7 @@ } - static void DeleteExports(RestApi::DeleteCall& call) + static void DeleteExports(RestApiDeleteCall& call) { OrthancRestApi::GetIndex(call).DeleteExportedResources(); call.GetOutput().AnswerBuffer("", "text/plain"); diff -r ab6475e33473 -r 6968356679c0 OrthancServer/OrthancRestApi/OrthancRestModalities.cpp --- a/OrthancServer/OrthancRestApi/OrthancRestModalities.cpp Mon Jun 30 14:08:51 2014 +0200 +++ b/OrthancServer/OrthancRestApi/OrthancRestModalities.cpp Mon Jun 30 14:55:43 2014 +0200 @@ -65,7 +65,7 @@ return true; } - static void DicomFindPatient(RestApi::PostCall& call) + static void DicomFindPatient(RestApiPostCall& call) { ServerContext& context = OrthancRestApi::GetContext(call); @@ -87,7 +87,7 @@ call.GetOutput().AnswerJson(result); } - static void DicomFindStudy(RestApi::PostCall& call) + static void DicomFindStudy(RestApiPostCall& call) { ServerContext& context = OrthancRestApi::GetContext(call); @@ -115,7 +115,7 @@ call.GetOutput().AnswerJson(result); } - static void DicomFindSeries(RestApi::PostCall& call) + static void DicomFindSeries(RestApiPostCall& call) { ServerContext& context = OrthancRestApi::GetContext(call); @@ -144,7 +144,7 @@ call.GetOutput().AnswerJson(result); } - static void DicomFindInstance(RestApi::PostCall& call) + static void DicomFindInstance(RestApiPostCall& call) { ServerContext& context = OrthancRestApi::GetContext(call); @@ -174,7 +174,7 @@ call.GetOutput().AnswerJson(result); } - static void DicomFind(RestApi::PostCall& call) + static void DicomFind(RestApiPostCall& call) { ServerContext& context = OrthancRestApi::GetContext(call); @@ -248,7 +248,7 @@ static bool GetInstancesToExport(std::list& instances, const std::string& remote, - RestApi::PostCall& call) + RestApiPostCall& call) { ServerContext& context = OrthancRestApi::GetContext(call); @@ -308,7 +308,7 @@ } - static void DicomStore(RestApi::PostCall& call) + static void DicomStore(RestApiPostCall& call) { ServerContext& context = OrthancRestApi::GetContext(call); @@ -345,7 +345,7 @@ return peers.find(id) != peers.end(); } - static void ListPeers(RestApi::GetCall& call) + static void ListPeers(RestApiGetCall& call) { OrthancRestApi::SetOfStrings peers; Configuration::GetListOfOrthancPeers(peers); @@ -360,7 +360,7 @@ call.GetOutput().AnswerJson(result); } - static void ListPeerOperations(RestApi::GetCall& call) + static void ListPeerOperations(RestApiGetCall& call) { OrthancRestApi::SetOfStrings peers; Configuration::GetListOfOrthancPeers(peers); @@ -374,7 +374,7 @@ } } - static void PeerStore(RestApi::PostCall& call) + static void PeerStore(RestApiPostCall& call) { ServerContext& context = OrthancRestApi::GetContext(call); @@ -429,7 +429,7 @@ return modalities.find(id) != modalities.end(); } - static void ListModalities(RestApi::GetCall& call) + static void ListModalities(RestApiGetCall& call) { OrthancRestApi::SetOfStrings modalities; Configuration::GetListOfDicomModalities(modalities); @@ -445,7 +445,7 @@ } - static void ListModalityOperations(RestApi::GetCall& call) + static void ListModalityOperations(RestApiGetCall& call) { OrthancRestApi::SetOfStrings modalities; Configuration::GetListOfDicomModalities(modalities); @@ -465,7 +465,7 @@ } - static void UpdateModality(RestApi::PutCall& call) + static void UpdateModality(RestApiPutCall& call) { Json::Value json; Json::Reader reader; @@ -479,14 +479,14 @@ } - static void DeleteModality(RestApi::DeleteCall& call) + static void DeleteModality(RestApiDeleteCall& call) { Configuration::RemoveModality(call.GetUriComponent("id", "")); call.GetOutput().AnswerBuffer("", "text/plain"); } - static void UpdatePeer(RestApi::PutCall& call) + static void UpdatePeer(RestApiPutCall& call) { Json::Value json; Json::Reader reader; @@ -500,7 +500,7 @@ } - static void DeletePeer(RestApi::DeleteCall& call) + static void DeletePeer(RestApiDeleteCall& call) { Configuration::RemovePeer(call.GetUriComponent("id", "")); call.GetOutput().AnswerBuffer("", "text/plain"); diff -r ab6475e33473 -r 6968356679c0 OrthancServer/OrthancRestApi/OrthancRestResources.cpp --- a/OrthancServer/OrthancRestApi/OrthancRestResources.cpp Mon Jun 30 14:08:51 2014 +0200 +++ b/OrthancServer/OrthancRestApi/OrthancRestResources.cpp Mon Jun 30 14:55:43 2014 +0200 @@ -43,7 +43,7 @@ // List all the patients, studies, series or instances ---------------------- template - static void ListResources(RestApi::GetCall& call) + static void ListResources(RestApiGetCall& call) { Json::Value result; OrthancRestApi::GetIndex(call).GetAllUuids(result, resourceType); @@ -51,7 +51,7 @@ } template - static void GetSingleResource(RestApi::GetCall& call) + static void GetSingleResource(RestApiGetCall& call) { Json::Value result; if (OrthancRestApi::GetIndex(call).LookupResource(result, call.GetUriComponent("id", ""), resourceType)) @@ -61,7 +61,7 @@ } template - static void DeleteSingleResource(RestApi::DeleteCall& call) + static void DeleteSingleResource(RestApiDeleteCall& call) { Json::Value result; if (OrthancRestApi::GetIndex(call).DeleteResource(result, call.GetUriComponent("id", ""), resourceType)) @@ -73,7 +73,7 @@ // Get information about a single patient ----------------------------------- - static void IsProtectedPatient(RestApi::GetCall& call) + static void IsProtectedPatient(RestApiGetCall& call) { std::string publicId = call.GetUriComponent("id", ""); bool isProtected = OrthancRestApi::GetIndex(call).IsProtectedPatient(publicId); @@ -81,7 +81,7 @@ } - static void SetPatientProtection(RestApi::PutCall& call) + static void SetPatientProtection(RestApiPutCall& call) { ServerContext& context = OrthancRestApi::GetContext(call); @@ -107,7 +107,7 @@ // Get information about a single instance ---------------------------------- - static void GetInstanceFile(RestApi::GetCall& call) + static void GetInstanceFile(RestApiGetCall& call) { ServerContext& context = OrthancRestApi::GetContext(call); @@ -116,7 +116,7 @@ } - static void ExportInstanceFile(RestApi::PostCall& call) + static void ExportInstanceFile(RestApiPostCall& call) { ServerContext& context = OrthancRestApi::GetContext(call); @@ -132,7 +132,7 @@ template - static void GetInstanceTags(RestApi::GetCall& call) + static void GetInstanceTags(RestApiGetCall& call) { ServerContext& context = OrthancRestApi::GetContext(call); @@ -154,7 +154,7 @@ } - static void GetInstanceTagsBis(RestApi::GetCall& call) + static void GetInstanceTagsBis(RestApiGetCall& call) { bool simplify = call.HasArgument("simplify"); @@ -169,7 +169,7 @@ } - static void ListFrames(RestApi::GetCall& call) + static void ListFrames(RestApiGetCall& call) { Json::Value instance; if (OrthancRestApi::GetIndex(call).LookupResource(instance, call.GetUriComponent("id", ""), ResourceType_Instance)) @@ -197,7 +197,7 @@ template - static void GetImage(RestApi::GetCall& call) + static void GetImage(RestApiGetCall& call) { ServerContext& context = OrthancRestApi::GetContext(call); @@ -245,7 +245,7 @@ } - static void GetMatlabImage(RestApi::GetCall& call) + static void GetMatlabImage(RestApiGetCall& call) { ServerContext& context = OrthancRestApi::GetContext(call); @@ -279,7 +279,7 @@ - static void GetResourceStatistics(RestApi::GetCall& call) + static void GetResourceStatistics(RestApiGetCall& call) { std::string publicId = call.GetUriComponent("id", ""); Json::Value result; @@ -291,14 +291,14 @@ // Handling of metadata ----------------------------------------------------- - static void CheckValidResourceType(RestApi::Call& call) + static void CheckValidResourceType(RestApiCall& call) { std::string resourceType = call.GetUriComponent("resourceType", ""); StringToResourceType(resourceType.c_str()); } - static void ListMetadata(RestApi::GetCall& call) + static void ListMetadata(RestApiGetCall& call) { CheckValidResourceType(call); @@ -318,7 +318,7 @@ } - static void GetMetadata(RestApi::GetCall& call) + static void GetMetadata(RestApiGetCall& call) { CheckValidResourceType(call); @@ -334,7 +334,7 @@ } - static void DeleteMetadata(RestApi::DeleteCall& call) + static void DeleteMetadata(RestApiDeleteCall& call) { CheckValidResourceType(call); @@ -352,7 +352,7 @@ } - static void SetMetadata(RestApi::PutCall& call) + static void SetMetadata(RestApiPutCall& call) { CheckValidResourceType(call); @@ -375,7 +375,7 @@ // Handling of attached files ----------------------------------------------- - static void ListAttachments(RestApi::GetCall& call) + static void ListAttachments(RestApiGetCall& call) { std::string resourceType = call.GetUriComponent("resourceType", ""); std::string publicId = call.GetUriComponent("id", ""); @@ -394,7 +394,7 @@ } - static bool GetAttachmentInfo(FileInfo& info, RestApi::Call& call) + static bool GetAttachmentInfo(FileInfo& info, RestApiCall& call) { CheckValidResourceType(call); @@ -406,7 +406,7 @@ } - static void GetAttachmentOperations(RestApi::GetCall& call) + static void GetAttachmentOperations(RestApiGetCall& call) { FileInfo info; if (GetAttachmentInfo(info, call)) @@ -442,7 +442,7 @@ template - static void GetAttachmentData(RestApi::GetCall& call) + static void GetAttachmentData(RestApiGetCall& call) { ServerContext& context = OrthancRestApi::GetContext(call); @@ -459,7 +459,7 @@ } - static void GetAttachmentSize(RestApi::GetCall& call) + static void GetAttachmentSize(RestApiGetCall& call) { FileInfo info; if (GetAttachmentInfo(info, call)) @@ -469,7 +469,7 @@ } - static void GetAttachmentCompressedSize(RestApi::GetCall& call) + static void GetAttachmentCompressedSize(RestApiGetCall& call) { FileInfo info; if (GetAttachmentInfo(info, call)) @@ -479,7 +479,7 @@ } - static void GetAttachmentMD5(RestApi::GetCall& call) + static void GetAttachmentMD5(RestApiGetCall& call) { FileInfo info; if (GetAttachmentInfo(info, call) && @@ -490,7 +490,7 @@ } - static void GetAttachmentCompressedMD5(RestApi::GetCall& call) + static void GetAttachmentCompressedMD5(RestApiGetCall& call) { FileInfo info; if (GetAttachmentInfo(info, call) && @@ -501,7 +501,7 @@ } - static void VerifyAttachment(RestApi::PostCall& call) + static void VerifyAttachment(RestApiPostCall& call) { ServerContext& context = OrthancRestApi::GetContext(call); CheckValidResourceType(call); @@ -555,7 +555,7 @@ } - static void UploadAttachment(RestApi::PutCall& call) + static void UploadAttachment(RestApiPutCall& call) { ServerContext& context = OrthancRestApi::GetContext(call); CheckValidResourceType(call); @@ -575,7 +575,7 @@ } - static void DeleteAttachment(RestApi::DeleteCall& call) + static void DeleteAttachment(RestApiDeleteCall& call) { CheckValidResourceType(call); @@ -595,7 +595,7 @@ // Raw access to the DICOM tags of an instance ------------------------------ - static void GetRawContent(RestApi::GetCall& call) + static void GetRawContent(RestApiGetCall& call) { std::string id = call.GetUriComponent("id", ""); @@ -681,7 +681,7 @@ } - static void GetSharedTags(RestApi::GetCall& call) + static void GetSharedTags(RestApiGetCall& call) { ServerContext& context = OrthancRestApi::GetContext(call); std::string publicId = call.GetUriComponent("id", ""); @@ -706,7 +706,7 @@ template - static void GetModule(RestApi::GetCall& call) + static void GetModule(RestApiGetCall& call) { ServerContext& context = OrthancRestApi::GetContext(call); std::string publicId = call.GetUriComponent("id", ""); diff -r ab6475e33473 -r 6968356679c0 OrthancServer/OrthancRestApi/OrthancRestSystem.cpp --- a/OrthancServer/OrthancRestApi/OrthancRestSystem.cpp Mon Jun 30 14:08:51 2014 +0200 +++ b/OrthancServer/OrthancRestApi/OrthancRestSystem.cpp Mon Jun 30 14:55:43 2014 +0200 @@ -43,12 +43,12 @@ { // System information ------------------------------------------------------- - static void ServeRoot(RestApi::GetCall& call) + static void ServeRoot(RestApiGetCall& call) { call.GetOutput().Redirect("app/explorer.html"); } - static void GetSystemInformation(RestApi::GetCall& call) + static void GetSystemInformation(RestApiGetCall& call) { Json::Value result = Json::objectValue; @@ -58,14 +58,14 @@ call.GetOutput().AnswerJson(result); } - static void GetStatistics(RestApi::GetCall& call) + static void GetStatistics(RestApiGetCall& call) { Json::Value result = Json::objectValue; OrthancRestApi::GetIndex(call).ComputeStatistics(result); call.GetOutput().AnswerJson(result); } - static void GenerateUid(RestApi::GetCall& call) + static void GenerateUid(RestApiGetCall& call) { std::string level = call.GetArgument("level", ""); if (level == "patient") @@ -86,7 +86,7 @@ } } - static void ExecuteScript(RestApi::PostCall& call) + static void ExecuteScript(RestApiPostCall& call) { std::string result; ServerContext& context = OrthancRestApi::GetContext(call); @@ -94,7 +94,7 @@ call.GetOutput().AnswerBuffer(result, "text/plain"); } - static void GetNowIsoString(RestApi::GetCall& call) + static void GetNowIsoString(RestApiGetCall& call) { call.GetOutput().AnswerBuffer(Toolbox::GetNowIsoString(), "text/plain"); } diff -r ab6475e33473 -r 6968356679c0 UnitTestsSources/RestApiTests.cpp --- a/UnitTestsSources/RestApiTests.cpp Mon Jun 30 14:08:51 2014 +0200 +++ b/UnitTestsSources/RestApiTests.cpp Mon Jun 30 14:55:43 2014 +0200 @@ -122,7 +122,7 @@ TEST(RestApi, RestApiPath) { - RestApiPath::Components args; + HttpHandler::Arguments args; UriComponents trail; { @@ -196,7 +196,7 @@ static int testValue; template -static void SetValue(RestApi::GetCall& get) +static void SetValue(RestApiGetCall& get) { testValue = value; } @@ -217,7 +217,7 @@ { UriComponents p; Toolbox::SplitUriComponents(p, uri); - return hierarchy.Handle(*reinterpret_cast(NULL), p); + return hierarchy.Handle(*reinterpret_cast(NULL), p); }