comparison OrthancServer/OrthancRestApi/OrthancRestModalities.cpp @ 2871:6eebc2eb3168

refactoring serialization of RemoteModalityParameters
author Sebastien Jodogne <s.jodogne@gmail.com>
date Tue, 09 Oct 2018 12:51:20 +0200
parents abce036683cd
children ae20fccdd867
comparison
equal deleted inserted replaced
2870:716dd24974ef 2871:6eebc2eb3168
827 WebServiceParameters peer; 827 WebServiceParameters peer;
828 828
829 if (Configuration::GetOrthancPeer(peer, *it)) 829 if (Configuration::GetOrthancPeer(peer, *it))
830 { 830 {
831 Json::Value jsonPeer = Json::objectValue; 831 Json::Value jsonPeer = Json::objectValue;
832 // only return the minimum information to identify the destination, do not include "security" information like passwords 832 // only return the minimum information to identify the
833 // destination, do not include "security" information like
834 // passwords
833 jsonPeer["Url"] = peer.GetUrl(); 835 jsonPeer["Url"] = peer.GetUrl();
834 if (!peer.GetUsername().empty()) 836 if (!peer.GetUsername().empty())
835 { 837 {
836 jsonPeer["Username"] = peer.GetUsername(); 838 jsonPeer["Username"] = peer.GetUsername();
837 } 839 }
909 { 911 {
910 Json::Value result = Json::objectValue; 912 Json::Value result = Json::objectValue;
911 for (OrthancRestApi::SetOfStrings::const_iterator 913 for (OrthancRestApi::SetOfStrings::const_iterator
912 it = modalities.begin(); it != modalities.end(); ++it) 914 it = modalities.begin(); it != modalities.end(); ++it)
913 { 915 {
914 Json::Value modality; 916 const RemoteModalityParameters& remote = Configuration::GetModalityUsingSymbolicName(*it);
915 Configuration::GetModalityUsingSymbolicName(*it).ToJson(modality); 917
916 918 Json::Value info;
917 result[*it] = modality; 919 remote.Serialize(info, true /* force advanced format */);
920 result[*it] = info;
918 } 921 }
919 call.GetOutput().AnswerJson(result); 922 call.GetOutput().AnswerJson(result);
920 } 923 }
921 else // if expand is not present, keep backward compatibility and return an array of modalities ids 924 else // if expand is not present, keep backward compatibility and return an array of modalities ids
922 { 925 {
951 Json::Value json; 954 Json::Value json;
952 Json::Reader reader; 955 Json::Reader reader;
953 if (reader.parse(call.GetBodyData(), call.GetBodyData() + call.GetBodySize(), json)) 956 if (reader.parse(call.GetBodyData(), call.GetBodyData() + call.GetBodySize(), json))
954 { 957 {
955 RemoteModalityParameters modality; 958 RemoteModalityParameters modality;
956 modality.FromJson(json); 959 modality.Unserialize(json);
957 Configuration::UpdateModality(context, call.GetUriComponent("id", ""), modality); 960 Configuration::UpdateModality(context, call.GetUriComponent("id", ""), modality);
958 call.GetOutput().AnswerBuffer("", "text/plain"); 961 call.GetOutput().AnswerBuffer("", "text/plain");
959 } 962 }
960 } 963 }
961 964