Mercurial > hg > orthanc
comparison Core/DicomNetworking/RemoteModalityParameters.cpp @ 3786:3801435e34a1 SylvainRouquette/fix-issue169-95b752c
integration Orthanc-1.6.0->SylvainRouquette
author | Sebastien Jodogne <s.jodogne@gmail.com> |
---|---|
date | Thu, 19 Mar 2020 11:48:30 +0100 |
parents | 763533d6dd67 f6a73611ec5c |
children |
comparison
equal
deleted
inserted
replaced
3785:763533d6dd67 | 3786:3801435e34a1 |
---|---|
1 /** | 1 /** |
2 * Orthanc - A Lightweight, RESTful DICOM Store | 2 * Orthanc - A Lightweight, RESTful DICOM Store |
3 * Copyright (C) 2012-2016 Sebastien Jodogne, Medical Physics | 3 * Copyright (C) 2012-2016 Sebastien Jodogne, Medical Physics |
4 * Department, University Hospital of Liege, Belgium | 4 * Department, University Hospital of Liege, Belgium |
5 * Copyright (C) 2017-2019 Osimis S.A., Belgium | 5 * Copyright (C) 2017-2020 Osimis S.A., Belgium |
6 * | 6 * |
7 * This program is free software: you can redistribute it and/or | 7 * This program is free software: you can redistribute it and/or |
8 * modify it under the terms of the GNU General Public License as | 8 * modify it under the terms of the GNU General Public License as |
9 * published by the Free Software Foundation, either version 3 of the | 9 * published by the Free Software Foundation, either version 3 of the |
10 * License, or (at your option) any later version. | 10 * License, or (at your option) any later version. |
48 static const char* KEY_ALLOW_ECHO = "AllowEcho"; | 48 static const char* KEY_ALLOW_ECHO = "AllowEcho"; |
49 static const char* KEY_ALLOW_FIND = "AllowFind"; | 49 static const char* KEY_ALLOW_FIND = "AllowFind"; |
50 static const char* KEY_ALLOW_GET = "AllowGet"; | 50 static const char* KEY_ALLOW_GET = "AllowGet"; |
51 static const char* KEY_ALLOW_MOVE = "AllowMove"; | 51 static const char* KEY_ALLOW_MOVE = "AllowMove"; |
52 static const char* KEY_ALLOW_STORE = "AllowStore"; | 52 static const char* KEY_ALLOW_STORE = "AllowStore"; |
53 static const char* KEY_ALLOW_N_ACTION = "AllowNAction"; | |
54 static const char* KEY_ALLOW_N_EVENT_REPORT = "AllowEventReport"; | |
55 static const char* KEY_ALLOW_STORAGE_COMMITMENT = "AllowStorageCommitment"; | |
53 static const char* KEY_HOST = "Host"; | 56 static const char* KEY_HOST = "Host"; |
54 static const char* KEY_PREFERRED_TRANSFER_SYNTAX = "PreferredTransferSyntax"; | 57 static const char* KEY_PREFERRED_TRANSFER_SYNTAX = "PreferredTransferSyntax"; |
55 static const char* KEY_MANUFACTURER = "Manufacturer"; | 58 static const char* KEY_MANUFACTURER = "Manufacturer"; |
56 static const char* KEY_PORT = "Port"; | 59 static const char* KEY_PORT = "Port"; |
57 | 60 |
68 allowEcho_ = true; | 71 allowEcho_ = true; |
69 allowStore_ = true; | 72 allowStore_ = true; |
70 allowFind_ = true; | 73 allowFind_ = true; |
71 allowMove_ = true; | 74 allowMove_ = true; |
72 allowGet_ = true; | 75 allowGet_ = true; |
76 allowNAction_ = true; // For storage commitment | |
77 allowNEventReport_ = true; // For storage commitment | |
73 } | 78 } |
74 | 79 |
75 | 80 |
76 RemoteModalityParameters::RemoteModalityParameters(const std::string& aet, | 81 RemoteModalityParameters::RemoteModalityParameters(const std::string& aet, |
77 const std::string& host, | 82 const std::string& host, |
169 { | 174 { |
170 assert(serialized.type() == Json::objectValue); | 175 assert(serialized.type() == Json::objectValue); |
171 | 176 |
172 aet_ = SerializationToolbox::ReadString(serialized, KEY_AET); | 177 aet_ = SerializationToolbox::ReadString(serialized, KEY_AET); |
173 host_ = SerializationToolbox::ReadString(serialized, KEY_HOST); | 178 host_ = SerializationToolbox::ReadString(serialized, KEY_HOST); |
174 preferredTransferSyntax_ = SerializationToolbox::ReadString(serialized, KEY_PREFERRED_TRANSFER_SYNTAX); | 179 |
180 if (serialized.isMember(KEY_PREFERRED_TRANSFER_SYNTAX)) | |
181 { | |
182 preferredTransferSyntax_ = SerializationToolbox::ReadString(serialized, KEY_PREFERRED_TRANSFER_SYNTAX); | |
183 } | |
175 | 184 |
176 if (serialized.isMember(KEY_PORT)) | 185 if (serialized.isMember(KEY_PORT)) |
177 { | 186 { |
178 port_ = ReadPortNumber(serialized[KEY_PORT]); | 187 port_ = ReadPortNumber(serialized[KEY_PORT]); |
179 } | 188 } |
214 | 223 |
215 if (serialized.isMember(KEY_ALLOW_MOVE)) | 224 if (serialized.isMember(KEY_ALLOW_MOVE)) |
216 { | 225 { |
217 allowMove_ = SerializationToolbox::ReadBoolean(serialized, KEY_ALLOW_MOVE); | 226 allowMove_ = SerializationToolbox::ReadBoolean(serialized, KEY_ALLOW_MOVE); |
218 } | 227 } |
228 | |
229 if (serialized.isMember(KEY_ALLOW_N_ACTION)) | |
230 { | |
231 allowNAction_ = SerializationToolbox::ReadBoolean(serialized, KEY_ALLOW_N_ACTION); | |
232 } | |
233 | |
234 if (serialized.isMember(KEY_ALLOW_N_EVENT_REPORT)) | |
235 { | |
236 allowNEventReport_ = SerializationToolbox::ReadBoolean(serialized, KEY_ALLOW_N_EVENT_REPORT); | |
237 } | |
238 | |
239 if (serialized.isMember(KEY_ALLOW_STORAGE_COMMITMENT)) | |
240 { | |
241 bool allow = SerializationToolbox::ReadBoolean(serialized, KEY_ALLOW_STORAGE_COMMITMENT); | |
242 allowNAction_ = allow; | |
243 allowNEventReport_ = allow; | |
244 } | |
219 } | 245 } |
220 | 246 |
221 | 247 |
222 bool RemoteModalityParameters::IsRequestAllowed(DicomRequestType type) const | 248 bool RemoteModalityParameters::IsRequestAllowed(DicomRequestType type) const |
223 { | 249 { |
236 return allowMove_; | 262 return allowMove_; |
237 | 263 |
238 case DicomRequestType_Store: | 264 case DicomRequestType_Store: |
239 return allowStore_; | 265 return allowStore_; |
240 | 266 |
267 case DicomRequestType_NAction: | |
268 return allowNAction_; | |
269 | |
270 case DicomRequestType_NEventReport: | |
271 return allowNEventReport_; | |
272 | |
241 default: | 273 default: |
242 throw OrthancException(ErrorCode_ParameterOutOfRange); | 274 throw OrthancException(ErrorCode_ParameterOutOfRange); |
243 } | 275 } |
244 } | 276 } |
245 | 277 |
265 allowMove_ = allowed; | 297 allowMove_ = allowed; |
266 break; | 298 break; |
267 | 299 |
268 case DicomRequestType_Store: | 300 case DicomRequestType_Store: |
269 allowStore_ = allowed; | 301 allowStore_ = allowed; |
302 break; | |
303 | |
304 case DicomRequestType_NAction: | |
305 allowNAction_ = allowed; | |
306 break; | |
307 | |
308 case DicomRequestType_NEventReport: | |
309 allowNEventReport_ = allowed; | |
270 break; | 310 break; |
271 | 311 |
272 default: | 312 default: |
273 throw OrthancException(ErrorCode_ParameterOutOfRange); | 313 throw OrthancException(ErrorCode_ParameterOutOfRange); |
274 } | 314 } |
279 { | 319 { |
280 return (!allowEcho_ || | 320 return (!allowEcho_ || |
281 !allowStore_ || | 321 !allowStore_ || |
282 !allowFind_ || | 322 !allowFind_ || |
283 !allowGet_ || | 323 !allowGet_ || |
284 !allowMove_); | 324 !allowMove_ || |
325 !allowNAction_ || | |
326 !allowNEventReport_); | |
285 } | 327 } |
286 | 328 |
287 | 329 |
288 void RemoteModalityParameters::Serialize(Json::Value& target, | 330 void RemoteModalityParameters::Serialize(Json::Value& target, |
289 bool forceAdvancedFormat) const | 331 bool forceAdvancedFormat) const |
300 target[KEY_ALLOW_ECHO] = allowEcho_; | 342 target[KEY_ALLOW_ECHO] = allowEcho_; |
301 target[KEY_ALLOW_STORE] = allowStore_; | 343 target[KEY_ALLOW_STORE] = allowStore_; |
302 target[KEY_ALLOW_FIND] = allowFind_; | 344 target[KEY_ALLOW_FIND] = allowFind_; |
303 target[KEY_ALLOW_GET] = allowGet_; | 345 target[KEY_ALLOW_GET] = allowGet_; |
304 target[KEY_ALLOW_MOVE] = allowMove_; | 346 target[KEY_ALLOW_MOVE] = allowMove_; |
347 target[KEY_ALLOW_N_ACTION] = allowNAction_; | |
348 target[KEY_ALLOW_N_EVENT_REPORT] = allowNEventReport_; | |
305 } | 349 } |
306 else | 350 else |
307 { | 351 { |
308 target = Json::arrayValue; | 352 target = Json::arrayValue; |
309 target.append(GetApplicationEntityTitle()); | 353 target.append(GetApplicationEntityTitle()); |