# HG changeset patch # User Sebastien Jodogne # Date 1544532347 -3600 # Node ID c0a766e68d6c96a0e46c20aa905618d5d604de4d # Parent d547f998c947c2e8c46fedf7736716813a4d7513# Parent 0a52af0c66e7709f3bef99b5ab36cb9a19da3977 integration mainline->db-changes diff -r d547f998c947 -r c0a766e68d6c OrthancServer/OrthancRestApi/OrthancRestResources.cpp --- a/OrthancServer/OrthancRestApi/OrthancRestResources.cpp Mon Dec 10 20:33:13 2018 +0100 +++ b/OrthancServer/OrthancRestApi/OrthancRestResources.cpp Tue Dec 11 13:45:47 2018 +0100 @@ -1271,35 +1271,42 @@ static void Find(RestApiPostCall& call) { + static const char* const KEY_CASE_SENSITIVE = "CaseSensitive"; + static const char* const KEY_EXPAND = "Expand"; + static const char* const KEY_LEVEL = "Level"; + static const char* const KEY_LIMIT = "Limit"; + static const char* const KEY_QUERY = "Query"; + static const char* const KEY_SINCE = "Since"; + ServerContext& context = OrthancRestApi::GetContext(call); Json::Value request; if (call.ParseJsonRequest(request) && request.type() == Json::objectValue && - request.isMember("Level") && - request.isMember("Query") && - request["Level"].type() == Json::stringValue && - request["Query"].type() == Json::objectValue && - (!request.isMember("CaseSensitive") || request["CaseSensitive"].type() == Json::booleanValue) && - (!request.isMember("Limit") || request["Limit"].type() == Json::intValue) && - (!request.isMember("Since") || request["Since"].type() == Json::intValue)) + request.isMember(KEY_LEVEL) && + request.isMember(KEY_QUERY) && + request[KEY_LEVEL].type() == Json::stringValue && + request[KEY_QUERY].type() == Json::objectValue && + (!request.isMember(KEY_CASE_SENSITIVE) || request[KEY_CASE_SENSITIVE].type() == Json::booleanValue) && + (!request.isMember(KEY_LIMIT) || request[KEY_LIMIT].type() == Json::intValue) && + (!request.isMember(KEY_SINCE) || request[KEY_SINCE].type() == Json::intValue)) { bool expand = false; - if (request.isMember("Expand")) + if (request.isMember(KEY_EXPAND)) { - expand = request["Expand"].asBool(); + expand = request[KEY_EXPAND].asBool(); } bool caseSensitive = false; - if (request.isMember("CaseSensitive")) + if (request.isMember(KEY_CASE_SENSITIVE)) { - caseSensitive = request["CaseSensitive"].asBool(); + caseSensitive = request[KEY_CASE_SENSITIVE].asBool(); } size_t limit = 0; - if (request.isMember("Limit")) + if (request.isMember(KEY_LIMIT)) { - int tmp = request["Limit"].asInt(); + int tmp = request[KEY_LIMIT].asInt(); if (tmp < 0) { throw OrthancException(ErrorCode_ParameterOutOfRange); @@ -1309,9 +1316,9 @@ } size_t since = 0; - if (request.isMember("Since")) + if (request.isMember(KEY_SINCE)) { - int tmp = request["Since"].asInt(); + int tmp = request[KEY_SINCE].asInt(); if (tmp < 0) { throw OrthancException(ErrorCode_ParameterOutOfRange); @@ -1320,20 +1327,20 @@ since = static_cast(tmp); } - std::string level = request["Level"].asString(); + std::string level = request[KEY_LEVEL].asString(); LookupResource query(StringToResourceType(level.c_str())); - Json::Value::Members members = request["Query"].getMemberNames(); + Json::Value::Members members = request[KEY_QUERY].getMemberNames(); for (size_t i = 0; i < members.size(); i++) { - if (request["Query"][members[i]].type() != Json::stringValue) + if (request[KEY_QUERY][members[i]].type() != Json::stringValue) { throw OrthancException(ErrorCode_BadRequest); } query.AddDicomConstraint(FromDcmtkBridge::ParseTag(members[i]), - request["Query"][members[i]].asString(), + request[KEY_QUERY][members[i]].asString(), caseSensitive); } diff -r d547f998c947 -r c0a766e68d6c Plugins/Samples/Basic/Plugin.c --- a/Plugins/Samples/Basic/Plugin.c Mon Dec 10 20:33:13 2018 +0100 +++ b/Plugins/Samples/Basic/Plugin.c Tue Dec 11 13:45:47 2018 +0100 @@ -40,7 +40,7 @@ { // NB: Calling "OrthancPluginSendMethodNotAllowed(context, output, "GET");" // is preferable. This is a sample to demonstrate "OrthancPluginSetHttpErrorDetails()". - OrthancPluginSetHttpErrorDetails(context, output, "This Callback1() can only be used by a GET call"); + OrthancPluginSetHttpErrorDetails(context, output, "This Callback1() can only be used by a GET call", 1 /* log */); return OrthancPluginErrorCode_ParameterOutOfRange; }