comparison OrthancServer/DicomInstanceToStore.cpp @ 1572:904096e7367e

More information about the origin request in OnStoredInstance() callbacks
author Sebastien Jodogne <s.jodogne@gmail.com>
date Tue, 25 Aug 2015 12:10:12 +0200
parents f967bdf8534e
children 3309878b3e16
comparison
equal deleted inserted replaced
1571:3232f1c995a5 1572:904096e7367e
169 throw OrthancException(ErrorCode_InternalError); 169 throw OrthancException(ErrorCode_InternalError);
170 } 170 }
171 171
172 return json_.GetConstContent(); 172 return json_.GetConstContent();
173 } 173 }
174
175
176
177 void DicomInstanceToStore::GetOriginInformation(Json::Value& result) const
178 {
179 result = Json::objectValue;
180 result["RequestOrigin"] = EnumerationToString(origin_);
181
182 switch (origin_)
183 {
184 case RequestOrigin_Unknown:
185 {
186 // None of the methods "SetDicomProtocolOrigin()", "SetHttpOrigin()",
187 // "SetLuaOrigin()" or "SetPluginsOrigin()" was called!
188 throw OrthancException(ErrorCode_BadSequenceOfCalls);
189 }
190
191 case RequestOrigin_DicomProtocol:
192 {
193 result["RemoteAet"] = dicomRemoteAet_;
194 result["CalledAet"] = dicomCalledAet_;
195 break;
196 }
197
198 case RequestOrigin_Http:
199 {
200 result["RemoteIp"] = httpRemoteIp_;
201 result["Username"] = httpUsername_;
202 break;
203 }
204
205 case RequestOrigin_Lua:
206 case RequestOrigin_Plugins:
207 {
208 // No additional information available for these kinds of requests
209 break;
210 }
211
212 default:
213 throw OrthancException(ErrorCode_InternalError);
214 }
215 }
216
217
218 void DicomInstanceToStore::SetDicomProtocolOrigin(const char* remoteAet,
219 const char* calledAet)
220 {
221 origin_ = RequestOrigin_DicomProtocol;
222 dicomRemoteAet_ = remoteAet;
223 dicomCalledAet_ = calledAet;
224 }
225
226 void DicomInstanceToStore::SetRestOrigin(const RestApiCall& call)
227 {
228 origin_ = call.GetRequestOrigin();
229
230 if (origin_ == RequestOrigin_Http)
231 {
232 httpRemoteIp_ = call.GetRemoteIp();
233 httpUsername_ = call.GetUsername();
234 }
235 }
236
237 void DicomInstanceToStore::SetHttpOrigin(const char* remoteIp,
238 const char* username)
239 {
240 origin_ = RequestOrigin_Http;
241 httpRemoteIp_ = remoteIp;
242 httpUsername_ = username;
243 }
244
245 void DicomInstanceToStore::SetLuaOrigin()
246 {
247 origin_ = RequestOrigin_Lua;
248 }
249
250 void DicomInstanceToStore::SetPluginsOrigin()
251 {
252 origin_ = RequestOrigin_Plugins;
253 }
254
255 const char* DicomInstanceToStore::GetRemoteAet() const
256 {
257 if (origin_ == RequestOrigin_DicomProtocol)
258 {
259 return dicomRemoteAet_.c_str();
260 }
261 else
262 {
263 return "";
264 }
265 }
174 } 266 }