Mercurial > hg > orthanc
comparison OrthancServer/OrthancRestApi/OrthancRestModalities.cpp @ 1428:0a355eeeb351
optimization
author | Sebastien Jodogne <s.jodogne@gmail.com> |
---|---|
date | Mon, 29 Jun 2015 13:26:34 +0200 |
parents | d710ea64f0fd |
children | 8dc80ba768aa |
comparison
equal
deleted
inserted
replaced
1427:d710ea64f0fd | 1428:0a355eeeb351 |
---|---|
551 | 551 |
552 /*************************************************************************** | 552 /*************************************************************************** |
553 * DICOM C-Store SCU | 553 * DICOM C-Store SCU |
554 ***************************************************************************/ | 554 ***************************************************************************/ |
555 | 555 |
556 static bool GetInstancesToExport(Json::Value& request, | 556 static bool GetInstancesToExport(Json::Value& otherArguments, |
557 std::list<std::string>& instances, | 557 std::list<std::string>& instances, |
558 const std::string& remote, | 558 const std::string& remote, |
559 RestApiPostCall& call) | 559 RestApiPostCall& call) |
560 { | 560 { |
561 ServerContext& context = OrthancRestApi::GetContext(call); | 561 otherArguments = Json::objectValue; |
562 | 562 ServerContext& context = OrthancRestApi::GetContext(call); |
563 std::string stripped = Toolbox::StripSpaces(call.GetPostBody()); | 563 |
564 | 564 Json::Value request; |
565 request = Json::objectValue; | 565 if (Toolbox::IsSHA1(call.GetPostBody())) |
566 if (Toolbox::IsSHA1(stripped)) | |
567 { | 566 { |
568 // This is for compatibility with Orthanc <= 0.5.1. | 567 // This is for compatibility with Orthanc <= 0.5.1. |
569 request = stripped; | 568 request = Json::arrayValue; |
569 request.append(Toolbox::StripSpaces(call.GetPostBody())); | |
570 } | 570 } |
571 else if (!call.ParseJsonRequest(request)) | 571 else if (!call.ParseJsonRequest(request)) |
572 { | 572 { |
573 // Bad JSON request | 573 // Bad JSON request |
574 return false; | 574 return false; |
575 } | 575 } |
576 | 576 |
577 if (request.isString()) | 577 if (request.isString()) |
578 { | 578 { |
579 if (Configuration::GetGlobalBoolParameter("LogExportedResources", true)) | 579 std::string item = request.asString(); |
580 { | 580 request = Json::arrayValue; |
581 context.GetIndex().LogExportedResource(request.asString(), remote); | 581 request.append(item); |
582 } | |
583 | |
584 context.GetIndex().GetChildInstances(instances, request.asString()); | |
585 return true; | |
586 } | 582 } |
587 | 583 |
588 const Json::Value* resources; | 584 const Json::Value* resources; |
589 if (request.isArray()) | 585 if (request.isArray()) |
590 { | 586 { |
600 | 596 |
601 resources = &request["Resources"]; | 597 resources = &request["Resources"]; |
602 if (!resources->isArray()) | 598 if (!resources->isArray()) |
603 { | 599 { |
604 return false; | 600 return false; |
601 } | |
602 | |
603 // Copy the remaining arguments | |
604 Json::Value::Members members = request.getMemberNames(); | |
605 for (Json::Value::ArrayIndex i = 0; i < members.size(); i++) | |
606 { | |
607 otherArguments[members[i]] = request[members[i]]; | |
605 } | 608 } |
606 } | 609 } |
607 | 610 |
608 for (Json::Value::ArrayIndex i = 0; i < resources->size(); i++) | 611 for (Json::Value::ArrayIndex i = 0; i < resources->size(); i++) |
609 { | 612 { |