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

refactoring mime types
author Sebastien Jodogne <s.jodogne@gmail.com>
date Tue, 30 Oct 2018 11:55:23 +0100
parents 73d7d95dd75e
children 9d277f8ad698
comparison
equal deleted inserted replaced
2904:0dd54ee073db 2905:ae20fccdd867
97 static void GenerateUid(RestApiGetCall& call) 97 static void GenerateUid(RestApiGetCall& call)
98 { 98 {
99 std::string level = call.GetArgument("level", ""); 99 std::string level = call.GetArgument("level", "");
100 if (level == "patient") 100 if (level == "patient")
101 { 101 {
102 call.GetOutput().AnswerBuffer(FromDcmtkBridge::GenerateUniqueIdentifier(ResourceType_Patient), "text/plain"); 102 call.GetOutput().AnswerBuffer(FromDcmtkBridge::GenerateUniqueIdentifier(ResourceType_Patient), MIME_PLAIN_TEXT);
103 } 103 }
104 else if (level == "study") 104 else if (level == "study")
105 { 105 {
106 call.GetOutput().AnswerBuffer(FromDcmtkBridge::GenerateUniqueIdentifier(ResourceType_Study), "text/plain"); 106 call.GetOutput().AnswerBuffer(FromDcmtkBridge::GenerateUniqueIdentifier(ResourceType_Study), MIME_PLAIN_TEXT);
107 } 107 }
108 else if (level == "series") 108 else if (level == "series")
109 { 109 {
110 call.GetOutput().AnswerBuffer(FromDcmtkBridge::GenerateUniqueIdentifier(ResourceType_Series), "text/plain"); 110 call.GetOutput().AnswerBuffer(FromDcmtkBridge::GenerateUniqueIdentifier(ResourceType_Series), MIME_PLAIN_TEXT);
111 } 111 }
112 else if (level == "instance") 112 else if (level == "instance")
113 { 113 {
114 call.GetOutput().AnswerBuffer(FromDcmtkBridge::GenerateUniqueIdentifier(ResourceType_Instance), "text/plain"); 114 call.GetOutput().AnswerBuffer(FromDcmtkBridge::GenerateUniqueIdentifier(ResourceType_Instance), MIME_PLAIN_TEXT);
115 } 115 }
116 } 116 }
117 117
118 static void ExecuteScript(RestApiPostCall& call) 118 static void ExecuteScript(RestApiPostCall& call)
119 { 119 {
126 { 126 {
127 LuaScripting::Lock lock(context.GetLuaScripting()); 127 LuaScripting::Lock lock(context.GetLuaScripting());
128 lock.GetLua().Execute(result, command); 128 lock.GetLua().Execute(result, command);
129 } 129 }
130 130
131 call.GetOutput().AnswerBuffer(result, "text/plain"); 131 call.GetOutput().AnswerBuffer(result, MIME_PLAIN_TEXT);
132 } 132 }
133 133
134 template <bool UTC> 134 template <bool UTC>
135 static void GetNowIsoString(RestApiGetCall& call) 135 static void GetNowIsoString(RestApiGetCall& call)
136 { 136 {
137 call.GetOutput().AnswerBuffer(SystemToolbox::GetNowIsoString(UTC), "text/plain"); 137 call.GetOutput().AnswerBuffer(SystemToolbox::GetNowIsoString(UTC), MIME_PLAIN_TEXT);
138 } 138 }
139 139
140 140
141 static void GetDicomConformanceStatement(RestApiGetCall& call) 141 static void GetDicomConformanceStatement(RestApiGetCall& call)
142 { 142 {
143 std::string statement; 143 std::string statement;
144 GetFileResource(statement, EmbeddedResources::DICOM_CONFORMANCE_STATEMENT); 144 GetFileResource(statement, EmbeddedResources::DICOM_CONFORMANCE_STATEMENT);
145 call.GetOutput().AnswerBuffer(statement, "text/plain"); 145 call.GetOutput().AnswerBuffer(statement, MIME_PLAIN_TEXT);
146 } 146 }
147 147
148 148
149 static void GetDefaultEncoding(RestApiGetCall& call) 149 static void GetDefaultEncoding(RestApiGetCall& call)
150 { 150 {
151 Encoding encoding = GetDefaultDicomEncoding(); 151 Encoding encoding = GetDefaultDicomEncoding();
152 call.GetOutput().AnswerBuffer(EnumerationToString(encoding), "text/plain"); 152 call.GetOutput().AnswerBuffer(EnumerationToString(encoding), MIME_PLAIN_TEXT);
153 } 153 }
154 154
155 155
156 static void SetDefaultEncoding(RestApiPutCall& call) 156 static void SetDefaultEncoding(RestApiPutCall& call)
157 { 157 {
158 Encoding encoding = StringToEncoding(call.GetBodyData()); 158 Encoding encoding = StringToEncoding(call.GetBodyData());
159 159
160 Configuration::SetDefaultEncoding(encoding); 160 Configuration::SetDefaultEncoding(encoding);
161 161
162 call.GetOutput().AnswerBuffer(EnumerationToString(encoding), "text/plain"); 162 call.GetOutput().AnswerBuffer(EnumerationToString(encoding), MIME_PLAIN_TEXT);
163 } 163 }
164 164
165 165
166 166
167 // Plugins information ------------------------------------------------------ 167 // Plugins information ------------------------------------------------------
355 throw OrthancException(ErrorCode_InternalError); 355 throw OrthancException(ErrorCode_InternalError);
356 } 356 }
357 357
358 if (ok) 358 if (ok)
359 { 359 {
360 call.GetOutput().AnswerBuffer("{}", "application/json"); 360 call.GetOutput().AnswerBuffer("{}", MIME_JSON);
361 } 361 }
362 } 362 }
363 363
364 364
365 void OrthancRestApi::RegisterSystem() 365 void OrthancRestApi::RegisterSystem()