comparison OrthancServer/OrthancRestApi/OrthancRestModalities.cpp @ 2905:ae20fccdd867

refactoring mime types
author Sebastien Jodogne <s.jodogne@gmail.com>
date Tue, 30 Oct 2018 11:55:23 +0100
parents 6eebc2eb3168
children 9d277f8ad698
comparison
equal deleted inserted replaced
2904:0dd54ee073db 2905:ae20fccdd867
65 connection.Open(); 65 connection.Open();
66 66
67 if (connection.Echo()) 67 if (connection.Echo())
68 { 68 {
69 // Echo has succeeded 69 // Echo has succeeded
70 call.GetOutput().AnswerBuffer("{}", "application/json"); 70 call.GetOutput().AnswerBuffer("{}", MIME_JSON);
71 return; 71 return;
72 } 72 }
73 } 73 }
74 catch (OrthancException&) 74 catch (OrthancException&)
75 { 75 {
587 587
588 588
589 static void GetQueryLevel(RestApiGetCall& call) 589 static void GetQueryLevel(RestApiGetCall& call)
590 { 590 {
591 QueryAccessor query(call); 591 QueryAccessor query(call);
592 call.GetOutput().AnswerBuffer(EnumerationToString(query.GetHandler().GetLevel()), "text/plain"); 592 call.GetOutput().AnswerBuffer(EnumerationToString(query.GetHandler().GetLevel()), MIME_PLAIN_TEXT);
593 } 593 }
594 594
595 595
596 static void GetQueryModality(RestApiGetCall& call) 596 static void GetQueryModality(RestApiGetCall& call)
597 { 597 {
598 QueryAccessor query(call); 598 QueryAccessor query(call);
599 call.GetOutput().AnswerBuffer(query.GetHandler().GetModalitySymbolicName(), "text/plain"); 599 call.GetOutput().AnswerBuffer(query.GetHandler().GetModalitySymbolicName(), MIME_PLAIN_TEXT);
600 } 600 }
601 601
602 602
603 static void DeleteQuery(RestApiDeleteCall& call) 603 static void DeleteQuery(RestApiDeleteCall& call)
604 { 604 {
605 ServerContext& context = OrthancRestApi::GetContext(call); 605 ServerContext& context = OrthancRestApi::GetContext(call);
606 context.GetQueryRetrieveArchive().Remove(call.GetUriComponent("id", "")); 606 context.GetQueryRetrieveArchive().Remove(call.GetUriComponent("id", ""));
607 call.GetOutput().AnswerBuffer("", "text/plain"); 607 call.GetOutput().AnswerBuffer("", MIME_PLAIN_TEXT);
608 } 608 }
609 609
610 610
611 static void ListQueryOperations(RestApiGetCall& call) 611 static void ListQueryOperations(RestApiGetCall& call)
612 { 612 {
796 796
797 connection.Move(targetAet, level, resource); 797 connection.Move(targetAet, level, resource);
798 } 798 }
799 799
800 // Move has succeeded 800 // Move has succeeded
801 call.GetOutput().AnswerBuffer("{}", "application/json"); 801 call.GetOutput().AnswerBuffer("{}", MIME_JSON);
802 } 802 }
803 803
804 804
805 805
806 /*************************************************************************** 806 /***************************************************************************
956 if (reader.parse(call.GetBodyData(), call.GetBodyData() + call.GetBodySize(), json)) 956 if (reader.parse(call.GetBodyData(), call.GetBodyData() + call.GetBodySize(), json))
957 { 957 {
958 RemoteModalityParameters modality; 958 RemoteModalityParameters modality;
959 modality.Unserialize(json); 959 modality.Unserialize(json);
960 Configuration::UpdateModality(context, call.GetUriComponent("id", ""), modality); 960 Configuration::UpdateModality(context, call.GetUriComponent("id", ""), modality);
961 call.GetOutput().AnswerBuffer("", "text/plain"); 961 call.GetOutput().AnswerBuffer("", MIME_PLAIN_TEXT);
962 } 962 }
963 } 963 }
964 964
965 965
966 static void DeleteModality(RestApiDeleteCall& call) 966 static void DeleteModality(RestApiDeleteCall& call)
967 { 967 {
968 ServerContext& context = OrthancRestApi::GetContext(call); 968 ServerContext& context = OrthancRestApi::GetContext(call);
969 969
970 Configuration::RemoveModality(context, call.GetUriComponent("id", "")); 970 Configuration::RemoveModality(context, call.GetUriComponent("id", ""));
971 call.GetOutput().AnswerBuffer("", "text/plain"); 971 call.GetOutput().AnswerBuffer("", MIME_PLAIN_TEXT);
972 } 972 }
973 973
974 974
975 static void UpdatePeer(RestApiPutCall& call) 975 static void UpdatePeer(RestApiPutCall& call)
976 { 976 {
981 if (reader.parse(call.GetBodyData(), call.GetBodyData() + call.GetBodySize(), json)) 981 if (reader.parse(call.GetBodyData(), call.GetBodyData() + call.GetBodySize(), json))
982 { 982 {
983 WebServiceParameters peer; 983 WebServiceParameters peer;
984 peer.Unserialize(json); 984 peer.Unserialize(json);
985 Configuration::UpdatePeer(context, call.GetUriComponent("id", ""), peer); 985 Configuration::UpdatePeer(context, call.GetUriComponent("id", ""), peer);
986 call.GetOutput().AnswerBuffer("", "text/plain"); 986 call.GetOutput().AnswerBuffer("", MIME_PLAIN_TEXT);
987 } 987 }
988 } 988 }
989 989
990 990
991 static void DeletePeer(RestApiDeleteCall& call) 991 static void DeletePeer(RestApiDeleteCall& call)
992 { 992 {
993 ServerContext& context = OrthancRestApi::GetContext(call); 993 ServerContext& context = OrthancRestApi::GetContext(call);
994 994
995 Configuration::RemovePeer(context, call.GetUriComponent("id", "")); 995 Configuration::RemovePeer(context, call.GetUriComponent("id", ""));
996 call.GetOutput().AnswerBuffer("", "text/plain"); 996 call.GetOutput().AnswerBuffer("", MIME_PLAIN_TEXT);
997 } 997 }
998 998
999 999
1000 static void DicomFindWorklist(RestApiPostCall& call) 1000 static void DicomFindWorklist(RestApiPostCall& call)
1001 { 1001 {