comparison OrthancServer/DicomInstanceToStore.cpp @ 2640:c691fcf66071 jobs

ResourceModificationJob
author Sebastien Jodogne <s.jodogne@gmail.com>
date Mon, 28 May 2018 16:30:17 +0200
parents 878b59270859
children a27b0e9a3fd9
comparison
equal deleted inserted replaced
2639:75a404e40323 2640:c691fcf66071
179 179
180 return json_.GetConstContent(); 180 return json_.GetConstContent();
181 } 181 }
182 182
183 183
184
185 void DicomInstanceToStore::GetOriginInformation(Json::Value& result) const
186 {
187 result = Json::objectValue;
188 result["RequestOrigin"] = EnumerationToString(origin_);
189
190 switch (origin_)
191 {
192 case RequestOrigin_Unknown:
193 {
194 // None of the methods "SetDicomProtocolOrigin()", "SetHttpOrigin()",
195 // "SetLuaOrigin()" or "SetPluginsOrigin()" was called!
196 throw OrthancException(ErrorCode_BadSequenceOfCalls);
197 }
198
199 case RequestOrigin_DicomProtocol:
200 {
201 result["RemoteIp"] = remoteIp_;
202 result["RemoteAet"] = dicomRemoteAet_;
203 result["CalledAet"] = dicomCalledAet_;
204 break;
205 }
206
207 case RequestOrigin_RestApi:
208 {
209 result["RemoteIp"] = remoteIp_;
210 result["Username"] = httpUsername_;
211 break;
212 }
213
214 case RequestOrigin_Lua:
215 case RequestOrigin_Plugins:
216 {
217 // No additional information available for these kinds of requests
218 break;
219 }
220
221 default:
222 throw OrthancException(ErrorCode_InternalError);
223 }
224 }
225
226
227 void DicomInstanceToStore::SetDicomProtocolOrigin(const char* remoteIp,
228 const char* remoteAet,
229 const char* calledAet)
230 {
231 origin_ = RequestOrigin_DicomProtocol;
232 remoteIp_ = remoteIp;
233 dicomRemoteAet_ = remoteAet;
234 dicomCalledAet_ = calledAet;
235 }
236
237 void DicomInstanceToStore::SetRestOrigin(const RestApiCall& call)
238 {
239 origin_ = call.GetRequestOrigin();
240
241 if (origin_ == RequestOrigin_RestApi)
242 {
243 remoteIp_ = call.GetRemoteIp();
244 httpUsername_ = call.GetUsername();
245 }
246 }
247
248 void DicomInstanceToStore::SetHttpOrigin(const char* remoteIp,
249 const char* username)
250 {
251 origin_ = RequestOrigin_RestApi;
252 remoteIp_ = remoteIp;
253 httpUsername_ = username;
254 }
255
256 void DicomInstanceToStore::SetLuaOrigin()
257 {
258 origin_ = RequestOrigin_Lua;
259 }
260
261 void DicomInstanceToStore::SetPluginsOrigin()
262 {
263 origin_ = RequestOrigin_Plugins;
264 }
265
266 const char* DicomInstanceToStore::GetRemoteAet() const
267 {
268 if (origin_ == RequestOrigin_DicomProtocol)
269 {
270 return dicomRemoteAet_.c_str();
271 }
272 else
273 {
274 return "";
275 }
276 }
277
278
279 bool DicomInstanceToStore::LookupTransferSyntax(std::string& result) 184 bool DicomInstanceToStore::LookupTransferSyntax(std::string& result)
280 { 185 {
281 ComputeMissingInformation(); 186 ComputeMissingInformation();
282 187
283 DicomMap header; 188 DicomMap header;