Mercurial > hg > orthanc
annotate OrthancServer/DicomInstanceToStore.cpp @ 2579:010577b52f5f
fix
author | Sebastien Jodogne <s.jodogne@gmail.com> |
---|---|
date | Fri, 11 May 2018 09:32:15 +0200 |
parents | 878b59270859 |
children | c691fcf66071 |
rev | line source |
---|---|
1003 | 1 /** |
2 * Orthanc - A Lightweight, RESTful DICOM Store | |
1900 | 3 * Copyright (C) 2012-2016 Sebastien Jodogne, Medical Physics |
1288
6e7e5ed91c2d
upgrade to year 2015
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1005
diff
changeset
|
4 * Department, University Hospital of Liege, Belgium |
2447
878b59270859
upgrade to year 2018
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2409
diff
changeset
|
5 * Copyright (C) 2017-2018 Osimis S.A., Belgium |
1003 | 6 * |
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 | |
9 * published by the Free Software Foundation, either version 3 of the | |
10 * License, or (at your option) any later version. | |
11 * | |
12 * In addition, as a special exception, the copyright holders of this | |
13 * program give permission to link the code of its release with the | |
14 * OpenSSL project's "OpenSSL" library (or with modified versions of it | |
15 * that use the same license as the "OpenSSL" library), and distribute | |
16 * the linked executables. You must obey the GNU General Public License | |
17 * in all respects for all of the code used other than "OpenSSL". If you | |
18 * modify file(s) with this exception, you may extend this exception to | |
19 * your version of the file(s), but you are not obligated to do so. If | |
20 * you do not wish to do so, delete this exception statement from your | |
21 * version. If you delete this exception statement from all source files | |
22 * in the program, then also delete it here. | |
23 * | |
24 * This program is distributed in the hope that it will be useful, but | |
25 * WITHOUT ANY WARRANTY; without even the implied warranty of | |
26 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | |
27 * General Public License for more details. | |
28 * | |
29 * You should have received a copy of the GNU General Public License | |
30 * along with this program. If not, see <http://www.gnu.org/licenses/>. | |
31 **/ | |
32 | |
33 | |
1624
0a2ad4a6858f
fix missing precompiled headers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1573
diff
changeset
|
34 #include "PrecompiledHeadersServer.h" |
1003 | 35 #include "DicomInstanceToStore.h" |
36 | |
2382
7284093111b0
big reorganization to cleanly separate framework vs. server
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2381
diff
changeset
|
37 #include "../Core/DicomParsing/FromDcmtkBridge.h" |
1486
f967bdf8534e
refactoring to Logging.h
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1288
diff
changeset
|
38 #include "../Core/Logging.h" |
1004
a226e0959d8b
DicomInstanceToStore
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1003
diff
changeset
|
39 |
a226e0959d8b
DicomInstanceToStore
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1003
diff
changeset
|
40 #include <dcmtk/dcmdata/dcfilefo.h> |
2189
c4b3259c8bce
New metadata automatically computed at the instance level: "TransferSyntax"
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2131
diff
changeset
|
41 #include <dcmtk/dcmdata/dcdeftag.h> |
1004
a226e0959d8b
DicomInstanceToStore
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1003
diff
changeset
|
42 |
a226e0959d8b
DicomInstanceToStore
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1003
diff
changeset
|
43 |
1003 | 44 namespace Orthanc |
45 { | |
1004
a226e0959d8b
DicomInstanceToStore
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1003
diff
changeset
|
46 void DicomInstanceToStore::AddMetadata(ResourceType level, |
1003 | 47 MetadataType metadata, |
48 const std::string& value) | |
49 { | |
50 metadata_[std::make_pair(level, metadata)] = value; | |
51 } | |
52 | |
53 | |
54 void DicomInstanceToStore::ComputeMissingInformation() | |
55 { | |
1004
a226e0959d8b
DicomInstanceToStore
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1003
diff
changeset
|
56 if (buffer_.HasContent() && |
a226e0959d8b
DicomInstanceToStore
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1003
diff
changeset
|
57 summary_.HasContent() && |
a226e0959d8b
DicomInstanceToStore
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1003
diff
changeset
|
58 json_.HasContent()) |
a226e0959d8b
DicomInstanceToStore
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1003
diff
changeset
|
59 { |
a226e0959d8b
DicomInstanceToStore
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1003
diff
changeset
|
60 // Fine, everything is available |
a226e0959d8b
DicomInstanceToStore
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1003
diff
changeset
|
61 return; |
a226e0959d8b
DicomInstanceToStore
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1003
diff
changeset
|
62 } |
a226e0959d8b
DicomInstanceToStore
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1003
diff
changeset
|
63 |
a226e0959d8b
DicomInstanceToStore
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1003
diff
changeset
|
64 if (!buffer_.HasContent()) |
a226e0959d8b
DicomInstanceToStore
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1003
diff
changeset
|
65 { |
a226e0959d8b
DicomInstanceToStore
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1003
diff
changeset
|
66 if (!parsed_.HasContent()) |
a226e0959d8b
DicomInstanceToStore
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1003
diff
changeset
|
67 { |
1822 | 68 if (!summary_.HasContent()) |
69 { | |
70 throw OrthancException(ErrorCode_NotImplemented); | |
71 } | |
72 else | |
73 { | |
74 parsed_.TakeOwnership(new ParsedDicomFile(summary_.GetConstContent())); | |
75 } | |
1004
a226e0959d8b
DicomInstanceToStore
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1003
diff
changeset
|
76 } |
1822 | 77 |
78 // Serialize the parsed DICOM file | |
79 buffer_.Allocate(); | |
80 if (!FromDcmtkBridge::SaveToMemoryBuffer(buffer_.GetContent(), | |
81 *parsed_.GetContent().GetDcmtkObject().getDataset())) | |
1004
a226e0959d8b
DicomInstanceToStore
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1003
diff
changeset
|
82 { |
1822 | 83 LOG(ERROR) << "Unable to serialize a DICOM file to a memory buffer"; |
84 throw OrthancException(ErrorCode_InternalError); | |
1004
a226e0959d8b
DicomInstanceToStore
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1003
diff
changeset
|
85 } |
a226e0959d8b
DicomInstanceToStore
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1003
diff
changeset
|
86 } |
1003 | 87 |
1004
a226e0959d8b
DicomInstanceToStore
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1003
diff
changeset
|
88 if (summary_.HasContent() && |
a226e0959d8b
DicomInstanceToStore
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1003
diff
changeset
|
89 json_.HasContent()) |
a226e0959d8b
DicomInstanceToStore
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1003
diff
changeset
|
90 { |
a226e0959d8b
DicomInstanceToStore
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1003
diff
changeset
|
91 return; |
a226e0959d8b
DicomInstanceToStore
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1003
diff
changeset
|
92 } |
a226e0959d8b
DicomInstanceToStore
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1003
diff
changeset
|
93 |
a226e0959d8b
DicomInstanceToStore
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1003
diff
changeset
|
94 // At this point, we know that the DICOM file is available as a |
a226e0959d8b
DicomInstanceToStore
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1003
diff
changeset
|
95 // memory buffer, but that its summary or its JSON version is |
a226e0959d8b
DicomInstanceToStore
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1003
diff
changeset
|
96 // missing |
a226e0959d8b
DicomInstanceToStore
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1003
diff
changeset
|
97 |
a226e0959d8b
DicomInstanceToStore
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1003
diff
changeset
|
98 if (!parsed_.HasContent()) |
a226e0959d8b
DicomInstanceToStore
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1003
diff
changeset
|
99 { |
1005
84b6d7bca6db
refactoring of ServerContext::Store
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1004
diff
changeset
|
100 parsed_.TakeOwnership(new ParsedDicomFile(buffer_.GetConstContent())); |
1004
a226e0959d8b
DicomInstanceToStore
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1003
diff
changeset
|
101 } |
a226e0959d8b
DicomInstanceToStore
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1003
diff
changeset
|
102 |
a226e0959d8b
DicomInstanceToStore
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1003
diff
changeset
|
103 // At this point, we have parsed the DICOM file |
a226e0959d8b
DicomInstanceToStore
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1003
diff
changeset
|
104 |
a226e0959d8b
DicomInstanceToStore
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1003
diff
changeset
|
105 if (!summary_.HasContent()) |
a226e0959d8b
DicomInstanceToStore
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1003
diff
changeset
|
106 { |
a226e0959d8b
DicomInstanceToStore
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1003
diff
changeset
|
107 summary_.Allocate(); |
2381
b8969010b534
uncoupling DCMTK primitives from Orthanc::Configuration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2244
diff
changeset
|
108 FromDcmtkBridge::ExtractDicomSummary(summary_.GetContent(), |
b8969010b534
uncoupling DCMTK primitives from Orthanc::Configuration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2244
diff
changeset
|
109 *parsed_.GetContent().GetDcmtkObject().getDataset()); |
1004
a226e0959d8b
DicomInstanceToStore
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1003
diff
changeset
|
110 } |
a226e0959d8b
DicomInstanceToStore
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1003
diff
changeset
|
111 |
a226e0959d8b
DicomInstanceToStore
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1003
diff
changeset
|
112 if (!json_.HasContent()) |
a226e0959d8b
DicomInstanceToStore
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1003
diff
changeset
|
113 { |
a226e0959d8b
DicomInstanceToStore
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1003
diff
changeset
|
114 json_.Allocate(); |
2409
e4045b3c9772
ignore-length argument if retrieving DICOM tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2382
diff
changeset
|
115 |
e4045b3c9772
ignore-length argument if retrieving DICOM tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2382
diff
changeset
|
116 std::set<DicomTag> ignoreTagLength; |
2381
b8969010b534
uncoupling DCMTK primitives from Orthanc::Configuration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2244
diff
changeset
|
117 FromDcmtkBridge::ExtractDicomAsJson(json_.GetContent(), |
2409
e4045b3c9772
ignore-length argument if retrieving DICOM tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2382
diff
changeset
|
118 *parsed_.GetContent().GetDcmtkObject().getDataset(), |
e4045b3c9772
ignore-length argument if retrieving DICOM tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2382
diff
changeset
|
119 ignoreTagLength); |
1004
a226e0959d8b
DicomInstanceToStore
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1003
diff
changeset
|
120 } |
1003 | 121 } |
122 | |
123 | |
124 | |
1004
a226e0959d8b
DicomInstanceToStore
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1003
diff
changeset
|
125 const char* DicomInstanceToStore::GetBufferData() |
1003 | 126 { |
127 ComputeMissingInformation(); | |
1004
a226e0959d8b
DicomInstanceToStore
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1003
diff
changeset
|
128 |
a226e0959d8b
DicomInstanceToStore
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1003
diff
changeset
|
129 if (!buffer_.HasContent()) |
a226e0959d8b
DicomInstanceToStore
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1003
diff
changeset
|
130 { |
a226e0959d8b
DicomInstanceToStore
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1003
diff
changeset
|
131 throw OrthancException(ErrorCode_InternalError); |
a226e0959d8b
DicomInstanceToStore
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1003
diff
changeset
|
132 } |
a226e0959d8b
DicomInstanceToStore
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1003
diff
changeset
|
133 |
a226e0959d8b
DicomInstanceToStore
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1003
diff
changeset
|
134 if (buffer_.GetConstContent().size() == 0) |
a226e0959d8b
DicomInstanceToStore
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1003
diff
changeset
|
135 { |
a226e0959d8b
DicomInstanceToStore
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1003
diff
changeset
|
136 return NULL; |
a226e0959d8b
DicomInstanceToStore
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1003
diff
changeset
|
137 } |
a226e0959d8b
DicomInstanceToStore
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1003
diff
changeset
|
138 else |
a226e0959d8b
DicomInstanceToStore
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1003
diff
changeset
|
139 { |
a226e0959d8b
DicomInstanceToStore
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1003
diff
changeset
|
140 return buffer_.GetConstContent().c_str(); |
a226e0959d8b
DicomInstanceToStore
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1003
diff
changeset
|
141 } |
1003 | 142 } |
143 | |
144 | |
145 size_t DicomInstanceToStore::GetBufferSize() | |
146 { | |
147 ComputeMissingInformation(); | |
1004
a226e0959d8b
DicomInstanceToStore
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1003
diff
changeset
|
148 |
a226e0959d8b
DicomInstanceToStore
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1003
diff
changeset
|
149 if (!buffer_.HasContent()) |
a226e0959d8b
DicomInstanceToStore
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1003
diff
changeset
|
150 { |
a226e0959d8b
DicomInstanceToStore
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1003
diff
changeset
|
151 throw OrthancException(ErrorCode_InternalError); |
a226e0959d8b
DicomInstanceToStore
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1003
diff
changeset
|
152 } |
a226e0959d8b
DicomInstanceToStore
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1003
diff
changeset
|
153 |
a226e0959d8b
DicomInstanceToStore
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1003
diff
changeset
|
154 return buffer_.GetConstContent().size(); |
a226e0959d8b
DicomInstanceToStore
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1003
diff
changeset
|
155 } |
a226e0959d8b
DicomInstanceToStore
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1003
diff
changeset
|
156 |
a226e0959d8b
DicomInstanceToStore
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1003
diff
changeset
|
157 |
a226e0959d8b
DicomInstanceToStore
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1003
diff
changeset
|
158 const DicomMap& DicomInstanceToStore::GetSummary() |
a226e0959d8b
DicomInstanceToStore
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1003
diff
changeset
|
159 { |
a226e0959d8b
DicomInstanceToStore
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1003
diff
changeset
|
160 ComputeMissingInformation(); |
a226e0959d8b
DicomInstanceToStore
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1003
diff
changeset
|
161 |
a226e0959d8b
DicomInstanceToStore
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1003
diff
changeset
|
162 if (!summary_.HasContent()) |
a226e0959d8b
DicomInstanceToStore
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1003
diff
changeset
|
163 { |
a226e0959d8b
DicomInstanceToStore
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1003
diff
changeset
|
164 throw OrthancException(ErrorCode_InternalError); |
a226e0959d8b
DicomInstanceToStore
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1003
diff
changeset
|
165 } |
a226e0959d8b
DicomInstanceToStore
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1003
diff
changeset
|
166 |
a226e0959d8b
DicomInstanceToStore
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1003
diff
changeset
|
167 return summary_.GetConstContent(); |
a226e0959d8b
DicomInstanceToStore
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1003
diff
changeset
|
168 } |
a226e0959d8b
DicomInstanceToStore
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1003
diff
changeset
|
169 |
a226e0959d8b
DicomInstanceToStore
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1003
diff
changeset
|
170 |
a226e0959d8b
DicomInstanceToStore
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1003
diff
changeset
|
171 const Json::Value& DicomInstanceToStore::GetJson() |
a226e0959d8b
DicomInstanceToStore
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1003
diff
changeset
|
172 { |
a226e0959d8b
DicomInstanceToStore
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1003
diff
changeset
|
173 ComputeMissingInformation(); |
a226e0959d8b
DicomInstanceToStore
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1003
diff
changeset
|
174 |
a226e0959d8b
DicomInstanceToStore
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1003
diff
changeset
|
175 if (!json_.HasContent()) |
a226e0959d8b
DicomInstanceToStore
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1003
diff
changeset
|
176 { |
a226e0959d8b
DicomInstanceToStore
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1003
diff
changeset
|
177 throw OrthancException(ErrorCode_InternalError); |
a226e0959d8b
DicomInstanceToStore
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1003
diff
changeset
|
178 } |
a226e0959d8b
DicomInstanceToStore
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1003
diff
changeset
|
179 |
a226e0959d8b
DicomInstanceToStore
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1003
diff
changeset
|
180 return json_.GetConstContent(); |
1003 | 181 } |
1572
904096e7367e
More information about the origin request in OnStoredInstance() callbacks
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1486
diff
changeset
|
182 |
904096e7367e
More information about the origin request in OnStoredInstance() callbacks
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1486
diff
changeset
|
183 |
904096e7367e
More information about the origin request in OnStoredInstance() callbacks
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1486
diff
changeset
|
184 |
904096e7367e
More information about the origin request in OnStoredInstance() callbacks
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1486
diff
changeset
|
185 void DicomInstanceToStore::GetOriginInformation(Json::Value& result) const |
904096e7367e
More information about the origin request in OnStoredInstance() callbacks
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1486
diff
changeset
|
186 { |
904096e7367e
More information about the origin request in OnStoredInstance() callbacks
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1486
diff
changeset
|
187 result = Json::objectValue; |
904096e7367e
More information about the origin request in OnStoredInstance() callbacks
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1486
diff
changeset
|
188 result["RequestOrigin"] = EnumerationToString(origin_); |
904096e7367e
More information about the origin request in OnStoredInstance() callbacks
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1486
diff
changeset
|
189 |
904096e7367e
More information about the origin request in OnStoredInstance() callbacks
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1486
diff
changeset
|
190 switch (origin_) |
904096e7367e
More information about the origin request in OnStoredInstance() callbacks
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1486
diff
changeset
|
191 { |
904096e7367e
More information about the origin request in OnStoredInstance() callbacks
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1486
diff
changeset
|
192 case RequestOrigin_Unknown: |
904096e7367e
More information about the origin request in OnStoredInstance() callbacks
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1486
diff
changeset
|
193 { |
904096e7367e
More information about the origin request in OnStoredInstance() callbacks
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1486
diff
changeset
|
194 // None of the methods "SetDicomProtocolOrigin()", "SetHttpOrigin()", |
904096e7367e
More information about the origin request in OnStoredInstance() callbacks
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1486
diff
changeset
|
195 // "SetLuaOrigin()" or "SetPluginsOrigin()" was called! |
904096e7367e
More information about the origin request in OnStoredInstance() callbacks
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1486
diff
changeset
|
196 throw OrthancException(ErrorCode_BadSequenceOfCalls); |
904096e7367e
More information about the origin request in OnStoredInstance() callbacks
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1486
diff
changeset
|
197 } |
904096e7367e
More information about the origin request in OnStoredInstance() callbacks
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1486
diff
changeset
|
198 |
904096e7367e
More information about the origin request in OnStoredInstance() callbacks
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1486
diff
changeset
|
199 case RequestOrigin_DicomProtocol: |
904096e7367e
More information about the origin request in OnStoredInstance() callbacks
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1486
diff
changeset
|
200 { |
1573
3309878b3e16
more information about the origin of requests submitted to the DICOM handlers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1572
diff
changeset
|
201 result["RemoteIp"] = remoteIp_; |
1572
904096e7367e
More information about the origin request in OnStoredInstance() callbacks
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1486
diff
changeset
|
202 result["RemoteAet"] = dicomRemoteAet_; |
904096e7367e
More information about the origin request in OnStoredInstance() callbacks
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1486
diff
changeset
|
203 result["CalledAet"] = dicomCalledAet_; |
904096e7367e
More information about the origin request in OnStoredInstance() callbacks
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1486
diff
changeset
|
204 break; |
904096e7367e
More information about the origin request in OnStoredInstance() callbacks
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1486
diff
changeset
|
205 } |
904096e7367e
More information about the origin request in OnStoredInstance() callbacks
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1486
diff
changeset
|
206 |
1823
0ef4e6e66b56
"Origin" metadata for the instances
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1822
diff
changeset
|
207 case RequestOrigin_RestApi: |
1572
904096e7367e
More information about the origin request in OnStoredInstance() callbacks
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1486
diff
changeset
|
208 { |
1573
3309878b3e16
more information about the origin of requests submitted to the DICOM handlers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1572
diff
changeset
|
209 result["RemoteIp"] = remoteIp_; |
1572
904096e7367e
More information about the origin request in OnStoredInstance() callbacks
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1486
diff
changeset
|
210 result["Username"] = httpUsername_; |
904096e7367e
More information about the origin request in OnStoredInstance() callbacks
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1486
diff
changeset
|
211 break; |
904096e7367e
More information about the origin request in OnStoredInstance() callbacks
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1486
diff
changeset
|
212 } |
904096e7367e
More information about the origin request in OnStoredInstance() callbacks
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1486
diff
changeset
|
213 |
904096e7367e
More information about the origin request in OnStoredInstance() callbacks
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1486
diff
changeset
|
214 case RequestOrigin_Lua: |
904096e7367e
More information about the origin request in OnStoredInstance() callbacks
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1486
diff
changeset
|
215 case RequestOrigin_Plugins: |
904096e7367e
More information about the origin request in OnStoredInstance() callbacks
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1486
diff
changeset
|
216 { |
904096e7367e
More information about the origin request in OnStoredInstance() callbacks
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1486
diff
changeset
|
217 // No additional information available for these kinds of requests |
904096e7367e
More information about the origin request in OnStoredInstance() callbacks
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1486
diff
changeset
|
218 break; |
904096e7367e
More information about the origin request in OnStoredInstance() callbacks
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1486
diff
changeset
|
219 } |
904096e7367e
More information about the origin request in OnStoredInstance() callbacks
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1486
diff
changeset
|
220 |
904096e7367e
More information about the origin request in OnStoredInstance() callbacks
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1486
diff
changeset
|
221 default: |
904096e7367e
More information about the origin request in OnStoredInstance() callbacks
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1486
diff
changeset
|
222 throw OrthancException(ErrorCode_InternalError); |
904096e7367e
More information about the origin request in OnStoredInstance() callbacks
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1486
diff
changeset
|
223 } |
904096e7367e
More information about the origin request in OnStoredInstance() callbacks
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1486
diff
changeset
|
224 } |
904096e7367e
More information about the origin request in OnStoredInstance() callbacks
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1486
diff
changeset
|
225 |
904096e7367e
More information about the origin request in OnStoredInstance() callbacks
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1486
diff
changeset
|
226 |
1573
3309878b3e16
more information about the origin of requests submitted to the DICOM handlers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1572
diff
changeset
|
227 void DicomInstanceToStore::SetDicomProtocolOrigin(const char* remoteIp, |
3309878b3e16
more information about the origin of requests submitted to the DICOM handlers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1572
diff
changeset
|
228 const char* remoteAet, |
1572
904096e7367e
More information about the origin request in OnStoredInstance() callbacks
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1486
diff
changeset
|
229 const char* calledAet) |
904096e7367e
More information about the origin request in OnStoredInstance() callbacks
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1486
diff
changeset
|
230 { |
904096e7367e
More information about the origin request in OnStoredInstance() callbacks
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1486
diff
changeset
|
231 origin_ = RequestOrigin_DicomProtocol; |
1573
3309878b3e16
more information about the origin of requests submitted to the DICOM handlers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1572
diff
changeset
|
232 remoteIp_ = remoteIp; |
1572
904096e7367e
More information about the origin request in OnStoredInstance() callbacks
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1486
diff
changeset
|
233 dicomRemoteAet_ = remoteAet; |
904096e7367e
More information about the origin request in OnStoredInstance() callbacks
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1486
diff
changeset
|
234 dicomCalledAet_ = calledAet; |
904096e7367e
More information about the origin request in OnStoredInstance() callbacks
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1486
diff
changeset
|
235 } |
904096e7367e
More information about the origin request in OnStoredInstance() callbacks
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1486
diff
changeset
|
236 |
904096e7367e
More information about the origin request in OnStoredInstance() callbacks
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1486
diff
changeset
|
237 void DicomInstanceToStore::SetRestOrigin(const RestApiCall& call) |
904096e7367e
More information about the origin request in OnStoredInstance() callbacks
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1486
diff
changeset
|
238 { |
904096e7367e
More information about the origin request in OnStoredInstance() callbacks
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1486
diff
changeset
|
239 origin_ = call.GetRequestOrigin(); |
904096e7367e
More information about the origin request in OnStoredInstance() callbacks
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1486
diff
changeset
|
240 |
1823
0ef4e6e66b56
"Origin" metadata for the instances
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1822
diff
changeset
|
241 if (origin_ == RequestOrigin_RestApi) |
1572
904096e7367e
More information about the origin request in OnStoredInstance() callbacks
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1486
diff
changeset
|
242 { |
1573
3309878b3e16
more information about the origin of requests submitted to the DICOM handlers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1572
diff
changeset
|
243 remoteIp_ = call.GetRemoteIp(); |
1572
904096e7367e
More information about the origin request in OnStoredInstance() callbacks
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1486
diff
changeset
|
244 httpUsername_ = call.GetUsername(); |
904096e7367e
More information about the origin request in OnStoredInstance() callbacks
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1486
diff
changeset
|
245 } |
904096e7367e
More information about the origin request in OnStoredInstance() callbacks
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1486
diff
changeset
|
246 } |
904096e7367e
More information about the origin request in OnStoredInstance() callbacks
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1486
diff
changeset
|
247 |
904096e7367e
More information about the origin request in OnStoredInstance() callbacks
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1486
diff
changeset
|
248 void DicomInstanceToStore::SetHttpOrigin(const char* remoteIp, |
904096e7367e
More information about the origin request in OnStoredInstance() callbacks
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1486
diff
changeset
|
249 const char* username) |
904096e7367e
More information about the origin request in OnStoredInstance() callbacks
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1486
diff
changeset
|
250 { |
1823
0ef4e6e66b56
"Origin" metadata for the instances
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1822
diff
changeset
|
251 origin_ = RequestOrigin_RestApi; |
1573
3309878b3e16
more information about the origin of requests submitted to the DICOM handlers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1572
diff
changeset
|
252 remoteIp_ = remoteIp; |
1572
904096e7367e
More information about the origin request in OnStoredInstance() callbacks
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1486
diff
changeset
|
253 httpUsername_ = username; |
904096e7367e
More information about the origin request in OnStoredInstance() callbacks
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1486
diff
changeset
|
254 } |
904096e7367e
More information about the origin request in OnStoredInstance() callbacks
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1486
diff
changeset
|
255 |
904096e7367e
More information about the origin request in OnStoredInstance() callbacks
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1486
diff
changeset
|
256 void DicomInstanceToStore::SetLuaOrigin() |
904096e7367e
More information about the origin request in OnStoredInstance() callbacks
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1486
diff
changeset
|
257 { |
904096e7367e
More information about the origin request in OnStoredInstance() callbacks
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1486
diff
changeset
|
258 origin_ = RequestOrigin_Lua; |
904096e7367e
More information about the origin request in OnStoredInstance() callbacks
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1486
diff
changeset
|
259 } |
904096e7367e
More information about the origin request in OnStoredInstance() callbacks
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1486
diff
changeset
|
260 |
904096e7367e
More information about the origin request in OnStoredInstance() callbacks
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1486
diff
changeset
|
261 void DicomInstanceToStore::SetPluginsOrigin() |
904096e7367e
More information about the origin request in OnStoredInstance() callbacks
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1486
diff
changeset
|
262 { |
904096e7367e
More information about the origin request in OnStoredInstance() callbacks
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1486
diff
changeset
|
263 origin_ = RequestOrigin_Plugins; |
904096e7367e
More information about the origin request in OnStoredInstance() callbacks
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1486
diff
changeset
|
264 } |
904096e7367e
More information about the origin request in OnStoredInstance() callbacks
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1486
diff
changeset
|
265 |
904096e7367e
More information about the origin request in OnStoredInstance() callbacks
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1486
diff
changeset
|
266 const char* DicomInstanceToStore::GetRemoteAet() const |
904096e7367e
More information about the origin request in OnStoredInstance() callbacks
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1486
diff
changeset
|
267 { |
904096e7367e
More information about the origin request in OnStoredInstance() callbacks
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1486
diff
changeset
|
268 if (origin_ == RequestOrigin_DicomProtocol) |
904096e7367e
More information about the origin request in OnStoredInstance() callbacks
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1486
diff
changeset
|
269 { |
904096e7367e
More information about the origin request in OnStoredInstance() callbacks
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1486
diff
changeset
|
270 return dicomRemoteAet_.c_str(); |
904096e7367e
More information about the origin request in OnStoredInstance() callbacks
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1486
diff
changeset
|
271 } |
904096e7367e
More information about the origin request in OnStoredInstance() callbacks
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1486
diff
changeset
|
272 else |
904096e7367e
More information about the origin request in OnStoredInstance() callbacks
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1486
diff
changeset
|
273 { |
904096e7367e
More information about the origin request in OnStoredInstance() callbacks
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1486
diff
changeset
|
274 return ""; |
904096e7367e
More information about the origin request in OnStoredInstance() callbacks
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1486
diff
changeset
|
275 } |
904096e7367e
More information about the origin request in OnStoredInstance() callbacks
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1486
diff
changeset
|
276 } |
2189
c4b3259c8bce
New metadata automatically computed at the instance level: "TransferSyntax"
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2131
diff
changeset
|
277 |
c4b3259c8bce
New metadata automatically computed at the instance level: "TransferSyntax"
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2131
diff
changeset
|
278 |
c4b3259c8bce
New metadata automatically computed at the instance level: "TransferSyntax"
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2131
diff
changeset
|
279 bool DicomInstanceToStore::LookupTransferSyntax(std::string& result) |
c4b3259c8bce
New metadata automatically computed at the instance level: "TransferSyntax"
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2131
diff
changeset
|
280 { |
c4b3259c8bce
New metadata automatically computed at the instance level: "TransferSyntax"
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2131
diff
changeset
|
281 ComputeMissingInformation(); |
c4b3259c8bce
New metadata automatically computed at the instance level: "TransferSyntax"
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2131
diff
changeset
|
282 |
c4b3259c8bce
New metadata automatically computed at the instance level: "TransferSyntax"
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2131
diff
changeset
|
283 DicomMap header; |
c4b3259c8bce
New metadata automatically computed at the instance level: "TransferSyntax"
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2131
diff
changeset
|
284 if (DicomMap::ParseDicomMetaInformation(header, GetBufferData(), GetBufferSize())) |
c4b3259c8bce
New metadata automatically computed at the instance level: "TransferSyntax"
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2131
diff
changeset
|
285 { |
c4b3259c8bce
New metadata automatically computed at the instance level: "TransferSyntax"
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2131
diff
changeset
|
286 const DicomValue* value = header.TestAndGetValue(DICOM_TAG_TRANSFER_SYNTAX_UID); |
c4b3259c8bce
New metadata automatically computed at the instance level: "TransferSyntax"
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2131
diff
changeset
|
287 if (value != NULL && |
c4b3259c8bce
New metadata automatically computed at the instance level: "TransferSyntax"
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2131
diff
changeset
|
288 !value->IsBinary() && |
c4b3259c8bce
New metadata automatically computed at the instance level: "TransferSyntax"
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2131
diff
changeset
|
289 !value->IsNull()) |
c4b3259c8bce
New metadata automatically computed at the instance level: "TransferSyntax"
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2131
diff
changeset
|
290 { |
c4b3259c8bce
New metadata automatically computed at the instance level: "TransferSyntax"
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2131
diff
changeset
|
291 result = Toolbox::StripSpaces(value->GetContent()); |
c4b3259c8bce
New metadata automatically computed at the instance level: "TransferSyntax"
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2131
diff
changeset
|
292 return true; |
c4b3259c8bce
New metadata automatically computed at the instance level: "TransferSyntax"
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2131
diff
changeset
|
293 } |
c4b3259c8bce
New metadata automatically computed at the instance level: "TransferSyntax"
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2131
diff
changeset
|
294 } |
c4b3259c8bce
New metadata automatically computed at the instance level: "TransferSyntax"
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2131
diff
changeset
|
295 |
c4b3259c8bce
New metadata automatically computed at the instance level: "TransferSyntax"
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2131
diff
changeset
|
296 return false; |
c4b3259c8bce
New metadata automatically computed at the instance level: "TransferSyntax"
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2131
diff
changeset
|
297 } |
1003 | 298 } |