comparison OrthancServer/OrthancRestApi/OrthancRestModalities.cpp @ 1997:f9f2aa1cc594

"MoveOriginatorID" can be specified for /modalities/.../store
author Sebastien Jodogne <s.jodogne@gmail.com>
date Wed, 25 May 2016 11:50:35 +0200
parents 5011a597b6ce
children 9b61701c35f2
comparison
equal deleted inserted replaced
1996:66957f5c69ab 1997:f9f2aa1cc594
681 if (!GetInstancesToExport(request, instances, remote, call)) 681 if (!GetInstancesToExport(request, instances, remote, call))
682 { 682 {
683 return; 683 return;
684 } 684 }
685 685
686 static const char* LOCAL_AET = "LocalAet";
686 std::string localAet = context.GetDefaultLocalApplicationEntityTitle(); 687 std::string localAet = context.GetDefaultLocalApplicationEntityTitle();
687 if (request.isMember("LocalAet")) 688 if (request.type() == Json::objectValue &&
688 { 689 request.isMember(LOCAL_AET))
689 localAet = request["LocalAet"].asString(); 690 {
691 if (request[LOCAL_AET].type() == Json::stringValue)
692 {
693 localAet = request[LOCAL_AET].asString();
694 }
695 else
696 {
697 throw OrthancException(ErrorCode_BadFileFormat);
698 }
699 }
700
701 uint16_t moveOriginatorID = 0; /* By default, not a C-MOVE */
702
703 static const char* MOVE_ORIGINATOR_ID = "MoveOriginatorID";
704 if (request.type() == Json::objectValue &&
705 request.isMember(MOVE_ORIGINATOR_ID))
706 {
707 if (request[MOVE_ORIGINATOR_ID].type() != Json::intValue)
708 {
709 throw OrthancException(ErrorCode_BadFileFormat);
710 }
711
712 int v = request[MOVE_ORIGINATOR_ID].asInt();
713 if (v <= 0 || v >= 65536)
714 {
715 throw OrthancException(ErrorCode_ParameterOutOfRange);
716 }
717 else
718 {
719 moveOriginatorID = boost::lexical_cast<uint16_t>(v);
720 }
690 } 721 }
691 722
692 RemoteModalityParameters p = Configuration::GetModalityUsingSymbolicName(remote); 723 RemoteModalityParameters p = Configuration::GetModalityUsingSymbolicName(remote);
693 724
694 ServerJob job; 725 ServerJob job;
695 for (std::list<std::string>::const_iterator 726 for (std::list<std::string>::const_iterator
696 it = instances.begin(); it != instances.end(); ++it) 727 it = instances.begin(); it != instances.end(); ++it)
697 { 728 {
698 job.AddCommand(new StoreScuCommand(context, localAet, p, false, 729 job.AddCommand(new StoreScuCommand(context, localAet, p, false,
699 0 /* not a C-MOVE */)).AddInput(*it); 730 moveOriginatorID)).AddInput(*it);
700 } 731 }
701 732
702 job.SetDescription("HTTP request: Store-SCU to peer \"" + remote + "\""); 733 job.SetDescription("HTTP request: Store-SCU to peer \"" + remote + "\"");
703 734
704 if (context.GetScheduler().SubmitAndWait(job)) 735 if (context.GetScheduler().SubmitAndWait(job))