annotate OrthancServer/ServerJobs/ResourceModificationJob.cpp @ 3167:860aed8258c3

Fix issue #73 (/modalities/{modalityId}/store raises 500 errors instead of 404)
author Sebastien Jodogne <s.jodogne@gmail.com>
date Fri, 25 Jan 2019 13:10:52 +0100
parents beeeb6096f27
children 4c45e018bd3d
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
2642
ccc470091ea6 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1 /**
ccc470091ea6 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
2 * Orthanc - A Lightweight, RESTful DICOM Store
ccc470091ea6 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
3 * Copyright (C) 2012-2016 Sebastien Jodogne, Medical Physics
ccc470091ea6 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
4 * Department, University Hospital of Liege, Belgium
3060
4e43e67f8ecf preparing for 2019
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2955
diff changeset
5 * Copyright (C) 2017-2019 Osimis S.A., Belgium
2642
ccc470091ea6 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
6 *
ccc470091ea6 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
7 * This program is free software: you can redistribute it and/or
ccc470091ea6 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
8 * modify it under the terms of the GNU General Public License as
ccc470091ea6 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
9 * published by the Free Software Foundation, either version 3 of the
ccc470091ea6 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
10 * License, or (at your option) any later version.
ccc470091ea6 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
11 *
ccc470091ea6 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
12 * In addition, as a special exception, the copyright holders of this
ccc470091ea6 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
13 * program give permission to link the code of its release with the
ccc470091ea6 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
14 * OpenSSL project's "OpenSSL" library (or with modified versions of it
ccc470091ea6 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
15 * that use the same license as the "OpenSSL" library), and distribute
ccc470091ea6 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
16 * the linked executables. You must obey the GNU General Public License
ccc470091ea6 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
17 * in all respects for all of the code used other than "OpenSSL". If you
ccc470091ea6 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
18 * modify file(s) with this exception, you may extend this exception to
ccc470091ea6 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
19 * your version of the file(s), but you are not obligated to do so. If
ccc470091ea6 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
20 * you do not wish to do so, delete this exception statement from your
ccc470091ea6 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
21 * version. If you delete this exception statement from all source files
ccc470091ea6 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
22 * in the program, then also delete it here.
ccc470091ea6 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
23 *
ccc470091ea6 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
24 * This program is distributed in the hope that it will be useful, but
ccc470091ea6 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
25 * WITHOUT ANY WARRANTY; without even the implied warranty of
ccc470091ea6 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
26 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
ccc470091ea6 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
27 * General Public License for more details.
ccc470091ea6 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
28 *
ccc470091ea6 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
29 * You should have received a copy of the GNU General Public License
ccc470091ea6 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
30 * along with this program. If not, see <http://www.gnu.org/licenses/>.
ccc470091ea6 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
31 **/
ccc470091ea6 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
32
ccc470091ea6 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
33
ccc470091ea6 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
34 #include "../PrecompiledHeadersServer.h"
ccc470091ea6 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
35 #include "ResourceModificationJob.h"
ccc470091ea6 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
36
ccc470091ea6 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
37 #include "../../Core/Logging.h"
2664
a21b244efb37 serialization of DicomModalityStoreJob, OrthancPeerStoreJob and ResourceModificationJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2663
diff changeset
38 #include "../../Core/SerializationToolbox.h"
3095
beeeb6096f27 removing dependencies upon ServerContext
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3060
diff changeset
39 #include "../ServerContext.h"
2642
ccc470091ea6 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
40
ccc470091ea6 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
41 namespace Orthanc
ccc470091ea6 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
42 {
2868
abce036683cd sharing code within OrthancRestAnonymizeModify
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2842
diff changeset
43 class ResourceModificationJob::Output : public boost::noncopyable
2642
ccc470091ea6 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
44 {
2868
abce036683cd sharing code within OrthancRestAnonymizeModify
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2842
diff changeset
45 private:
abce036683cd sharing code within OrthancRestAnonymizeModify
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2842
diff changeset
46 ResourceType level_;
abce036683cd sharing code within OrthancRestAnonymizeModify
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2842
diff changeset
47 bool isFirst_;
abce036683cd sharing code within OrthancRestAnonymizeModify
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2842
diff changeset
48 std::string id_;
abce036683cd sharing code within OrthancRestAnonymizeModify
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2842
diff changeset
49 std::string patientId_;
abce036683cd sharing code within OrthancRestAnonymizeModify
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2842
diff changeset
50
abce036683cd sharing code within OrthancRestAnonymizeModify
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2842
diff changeset
51 public:
abce036683cd sharing code within OrthancRestAnonymizeModify
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2842
diff changeset
52 Output(ResourceType level) :
abce036683cd sharing code within OrthancRestAnonymizeModify
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2842
diff changeset
53 level_(level),
abce036683cd sharing code within OrthancRestAnonymizeModify
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2842
diff changeset
54 isFirst_(true)
abce036683cd sharing code within OrthancRestAnonymizeModify
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2842
diff changeset
55 {
abce036683cd sharing code within OrthancRestAnonymizeModify
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2842
diff changeset
56 if (level_ != ResourceType_Patient &&
abce036683cd sharing code within OrthancRestAnonymizeModify
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2842
diff changeset
57 level_ != ResourceType_Study &&
abce036683cd sharing code within OrthancRestAnonymizeModify
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2842
diff changeset
58 level_ != ResourceType_Series)
abce036683cd sharing code within OrthancRestAnonymizeModify
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2842
diff changeset
59 {
abce036683cd sharing code within OrthancRestAnonymizeModify
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2842
diff changeset
60 throw OrthancException(ErrorCode_ParameterOutOfRange);
abce036683cd sharing code within OrthancRestAnonymizeModify
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2842
diff changeset
61 }
abce036683cd sharing code within OrthancRestAnonymizeModify
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2842
diff changeset
62 }
abce036683cd sharing code within OrthancRestAnonymizeModify
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2842
diff changeset
63
abce036683cd sharing code within OrthancRestAnonymizeModify
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2842
diff changeset
64 ResourceType GetLevel() const
2642
ccc470091ea6 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
65 {
2868
abce036683cd sharing code within OrthancRestAnonymizeModify
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2842
diff changeset
66 return level_;
abce036683cd sharing code within OrthancRestAnonymizeModify
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2842
diff changeset
67 }
abce036683cd sharing code within OrthancRestAnonymizeModify
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2842
diff changeset
68
abce036683cd sharing code within OrthancRestAnonymizeModify
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2842
diff changeset
69
abce036683cd sharing code within OrthancRestAnonymizeModify
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2842
diff changeset
70 void Update(DicomInstanceHasher& hasher)
abce036683cd sharing code within OrthancRestAnonymizeModify
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2842
diff changeset
71 {
abce036683cd sharing code within OrthancRestAnonymizeModify
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2842
diff changeset
72 if (isFirst_)
abce036683cd sharing code within OrthancRestAnonymizeModify
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2842
diff changeset
73 {
abce036683cd sharing code within OrthancRestAnonymizeModify
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2842
diff changeset
74 switch (level_)
abce036683cd sharing code within OrthancRestAnonymizeModify
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2842
diff changeset
75 {
abce036683cd sharing code within OrthancRestAnonymizeModify
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2842
diff changeset
76 case ResourceType_Series:
abce036683cd sharing code within OrthancRestAnonymizeModify
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2842
diff changeset
77 id_ = hasher.HashSeries();
abce036683cd sharing code within OrthancRestAnonymizeModify
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2842
diff changeset
78 break;
abce036683cd sharing code within OrthancRestAnonymizeModify
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2842
diff changeset
79
abce036683cd sharing code within OrthancRestAnonymizeModify
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2842
diff changeset
80 case ResourceType_Study:
abce036683cd sharing code within OrthancRestAnonymizeModify
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2842
diff changeset
81 id_ = hasher.HashStudy();
abce036683cd sharing code within OrthancRestAnonymizeModify
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2842
diff changeset
82 break;
abce036683cd sharing code within OrthancRestAnonymizeModify
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2842
diff changeset
83
abce036683cd sharing code within OrthancRestAnonymizeModify
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2842
diff changeset
84 case ResourceType_Patient:
abce036683cd sharing code within OrthancRestAnonymizeModify
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2842
diff changeset
85 id_ = hasher.HashPatient();
abce036683cd sharing code within OrthancRestAnonymizeModify
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2842
diff changeset
86 break;
abce036683cd sharing code within OrthancRestAnonymizeModify
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2842
diff changeset
87
abce036683cd sharing code within OrthancRestAnonymizeModify
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2842
diff changeset
88 default:
abce036683cd sharing code within OrthancRestAnonymizeModify
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2842
diff changeset
89 throw OrthancException(ErrorCode_InternalError);
abce036683cd sharing code within OrthancRestAnonymizeModify
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2842
diff changeset
90 }
abce036683cd sharing code within OrthancRestAnonymizeModify
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2842
diff changeset
91
abce036683cd sharing code within OrthancRestAnonymizeModify
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2842
diff changeset
92 patientId_ = hasher.HashPatient();
abce036683cd sharing code within OrthancRestAnonymizeModify
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2842
diff changeset
93 isFirst_ = false;
abce036683cd sharing code within OrthancRestAnonymizeModify
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2842
diff changeset
94 }
abce036683cd sharing code within OrthancRestAnonymizeModify
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2842
diff changeset
95 }
2642
ccc470091ea6 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
96
ccc470091ea6 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
97
2868
abce036683cd sharing code within OrthancRestAnonymizeModify
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2842
diff changeset
98 bool Format(Json::Value& target)
2642
ccc470091ea6 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
99 {
2868
abce036683cd sharing code within OrthancRestAnonymizeModify
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2842
diff changeset
100 if (isFirst_)
2642
ccc470091ea6 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
101 {
2868
abce036683cd sharing code within OrthancRestAnonymizeModify
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2842
diff changeset
102 return false;
2642
ccc470091ea6 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
103 }
2868
abce036683cd sharing code within OrthancRestAnonymizeModify
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2842
diff changeset
104 else
abce036683cd sharing code within OrthancRestAnonymizeModify
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2842
diff changeset
105 {
abce036683cd sharing code within OrthancRestAnonymizeModify
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2842
diff changeset
106 target = Json::objectValue;
abce036683cd sharing code within OrthancRestAnonymizeModify
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2842
diff changeset
107 target["Type"] = EnumerationToString(level_);
abce036683cd sharing code within OrthancRestAnonymizeModify
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2842
diff changeset
108 target["ID"] = id_;
abce036683cd sharing code within OrthancRestAnonymizeModify
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2842
diff changeset
109 target["Path"] = GetBasePath(level_, id_);
abce036683cd sharing code within OrthancRestAnonymizeModify
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2842
diff changeset
110 target["PatientID"] = patientId_;
abce036683cd sharing code within OrthancRestAnonymizeModify
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2842
diff changeset
111 return true;
abce036683cd sharing code within OrthancRestAnonymizeModify
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2842
diff changeset
112 }
2642
ccc470091ea6 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
113 }
ccc470091ea6 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
114
ccc470091ea6 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
115
2868
abce036683cd sharing code within OrthancRestAnonymizeModify
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2842
diff changeset
116 bool GetIdentifier(std::string& id)
2642
ccc470091ea6 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
117 {
2868
abce036683cd sharing code within OrthancRestAnonymizeModify
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2842
diff changeset
118 if (isFirst_)
abce036683cd sharing code within OrthancRestAnonymizeModify
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2842
diff changeset
119 {
abce036683cd sharing code within OrthancRestAnonymizeModify
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2842
diff changeset
120 return false;
abce036683cd sharing code within OrthancRestAnonymizeModify
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2842
diff changeset
121 }
abce036683cd sharing code within OrthancRestAnonymizeModify
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2842
diff changeset
122 else
abce036683cd sharing code within OrthancRestAnonymizeModify
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2842
diff changeset
123 {
abce036683cd sharing code within OrthancRestAnonymizeModify
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2842
diff changeset
124 id = id_;
abce036683cd sharing code within OrthancRestAnonymizeModify
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2842
diff changeset
125 return true;
abce036683cd sharing code within OrthancRestAnonymizeModify
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2842
diff changeset
126 }
2642
ccc470091ea6 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
127 }
2868
abce036683cd sharing code within OrthancRestAnonymizeModify
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2842
diff changeset
128 };
abce036683cd sharing code within OrthancRestAnonymizeModify
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2842
diff changeset
129
abce036683cd sharing code within OrthancRestAnonymizeModify
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2842
diff changeset
130
2642
ccc470091ea6 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
131
ccc470091ea6 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
132
ccc470091ea6 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
133 bool ResourceModificationJob::HandleInstance(const std::string& instance)
ccc470091ea6 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
134 {
2868
abce036683cd sharing code within OrthancRestAnonymizeModify
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2842
diff changeset
135 if (modification_.get() == NULL ||
abce036683cd sharing code within OrthancRestAnonymizeModify
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2842
diff changeset
136 output_.get() == NULL)
2642
ccc470091ea6 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
137 {
2955
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2868
diff changeset
138 throw OrthancException(ErrorCode_BadSequenceOfCalls,
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2868
diff changeset
139 "No modification was provided for this job");
2642
ccc470091ea6 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
140 }
ccc470091ea6 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
141
ccc470091ea6 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
142
ccc470091ea6 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
143 LOG(INFO) << "Modifying instance in a job: " << instance;
ccc470091ea6 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
144
2825
8aa6aef11b70 New configuration option "OverwriteInstances" to choose how duplicate SOPInstanceUID are handled
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2664
diff changeset
145
8aa6aef11b70 New configuration option "OverwriteInstances" to choose how duplicate SOPInstanceUID are handled
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2664
diff changeset
146 /**
8aa6aef11b70 New configuration option "OverwriteInstances" to choose how duplicate SOPInstanceUID are handled
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2664
diff changeset
147 * Retrieve the original instance from the DICOM cache.
8aa6aef11b70 New configuration option "OverwriteInstances" to choose how duplicate SOPInstanceUID are handled
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2664
diff changeset
148 **/
8aa6aef11b70 New configuration option "OverwriteInstances" to choose how duplicate SOPInstanceUID are handled
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2664
diff changeset
149
8aa6aef11b70 New configuration option "OverwriteInstances" to choose how duplicate SOPInstanceUID are handled
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2664
diff changeset
150 std::auto_ptr<DicomInstanceHasher> originalHasher;
8aa6aef11b70 New configuration option "OverwriteInstances" to choose how duplicate SOPInstanceUID are handled
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2664
diff changeset
151 std::auto_ptr<ParsedDicomFile> modified;
2642
ccc470091ea6 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
152
ccc470091ea6 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
153 try
ccc470091ea6 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
154 {
2825
8aa6aef11b70 New configuration option "OverwriteInstances" to choose how duplicate SOPInstanceUID are handled
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2664
diff changeset
155 ServerContext::DicomCacheLocker locker(context_, instance);
8aa6aef11b70 New configuration option "OverwriteInstances" to choose how duplicate SOPInstanceUID are handled
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2664
diff changeset
156 ParsedDicomFile& original = locker.GetDicom();
8aa6aef11b70 New configuration option "OverwriteInstances" to choose how duplicate SOPInstanceUID are handled
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2664
diff changeset
157
8aa6aef11b70 New configuration option "OverwriteInstances" to choose how duplicate SOPInstanceUID are handled
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2664
diff changeset
158 originalHasher.reset(new DicomInstanceHasher(original.GetHasher()));
8aa6aef11b70 New configuration option "OverwriteInstances" to choose how duplicate SOPInstanceUID are handled
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2664
diff changeset
159 modified.reset(original.Clone(true));
2642
ccc470091ea6 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
160 }
ccc470091ea6 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
161 catch (OrthancException&)
ccc470091ea6 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
162 {
ccc470091ea6 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
163 LOG(WARNING) << "An instance was removed after the job was issued: " << instance;
ccc470091ea6 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
164 return false;
ccc470091ea6 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
165 }
ccc470091ea6 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
166
ccc470091ea6 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
167
ccc470091ea6 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
168 /**
ccc470091ea6 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
169 * Compute the resulting DICOM instance.
ccc470091ea6 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
170 **/
ccc470091ea6 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
171
ccc470091ea6 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
172 modification_->Apply(*modified);
ccc470091ea6 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
173
ccc470091ea6 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
174 DicomInstanceToStore toStore;
ccc470091ea6 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
175 toStore.SetOrigin(origin_);
ccc470091ea6 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
176 toStore.SetParsedDicomFile(*modified);
ccc470091ea6 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
177
ccc470091ea6 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
178
ccc470091ea6 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
179 /**
ccc470091ea6 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
180 * Prepare the metadata information to associate with the
ccc470091ea6 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
181 * resulting DICOM instance (AnonymizedFrom/ModifiedFrom).
ccc470091ea6 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
182 **/
ccc470091ea6 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
183
ccc470091ea6 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
184 DicomInstanceHasher modifiedHasher = modified->GetHasher();
ccc470091ea6 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
185
ccc470091ea6 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
186 MetadataType metadataType = (isAnonymization_ ?
ccc470091ea6 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
187 MetadataType_AnonymizedFrom :
ccc470091ea6 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
188 MetadataType_ModifiedFrom);
ccc470091ea6 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
189
2825
8aa6aef11b70 New configuration option "OverwriteInstances" to choose how duplicate SOPInstanceUID are handled
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2664
diff changeset
190 if (originalHasher->HashSeries() != modifiedHasher.HashSeries())
2642
ccc470091ea6 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
191 {
2825
8aa6aef11b70 New configuration option "OverwriteInstances" to choose how duplicate SOPInstanceUID are handled
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2664
diff changeset
192 toStore.AddMetadata(ResourceType_Series, metadataType, originalHasher->HashSeries());
2642
ccc470091ea6 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
193 }
ccc470091ea6 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
194
2825
8aa6aef11b70 New configuration option "OverwriteInstances" to choose how duplicate SOPInstanceUID are handled
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2664
diff changeset
195 if (originalHasher->HashStudy() != modifiedHasher.HashStudy())
2642
ccc470091ea6 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
196 {
2825
8aa6aef11b70 New configuration option "OverwriteInstances" to choose how duplicate SOPInstanceUID are handled
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2664
diff changeset
197 toStore.AddMetadata(ResourceType_Study, metadataType, originalHasher->HashStudy());
2642
ccc470091ea6 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
198 }
ccc470091ea6 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
199
2825
8aa6aef11b70 New configuration option "OverwriteInstances" to choose how duplicate SOPInstanceUID are handled
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2664
diff changeset
200 if (originalHasher->HashPatient() != modifiedHasher.HashPatient())
2642
ccc470091ea6 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
201 {
2825
8aa6aef11b70 New configuration option "OverwriteInstances" to choose how duplicate SOPInstanceUID are handled
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2664
diff changeset
202 toStore.AddMetadata(ResourceType_Patient, metadataType, originalHasher->HashPatient());
2642
ccc470091ea6 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
203 }
ccc470091ea6 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
204
2825
8aa6aef11b70 New configuration option "OverwriteInstances" to choose how duplicate SOPInstanceUID are handled
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2664
diff changeset
205 assert(instance == originalHasher->HashInstance());
2642
ccc470091ea6 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
206 toStore.AddMetadata(ResourceType_Instance, metadataType, instance);
ccc470091ea6 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
207
ccc470091ea6 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
208
ccc470091ea6 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
209 /**
ccc470091ea6 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
210 * Store the resulting DICOM instance into the Orthanc store.
ccc470091ea6 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
211 **/
ccc470091ea6 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
212
ccc470091ea6 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
213 std::string modifiedInstance;
ccc470091ea6 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
214 if (context_.Store(modifiedInstance, toStore) != StoreStatus_Success)
ccc470091ea6 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
215 {
2955
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2868
diff changeset
216 throw OrthancException(ErrorCode_CannotStoreInstance,
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2868
diff changeset
217 "Error while storing a modified instance " + instance);
2642
ccc470091ea6 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
218 }
ccc470091ea6 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
219
ccc470091ea6 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
220 assert(modifiedInstance == modifiedHasher.HashInstance());
ccc470091ea6 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
221
2868
abce036683cd sharing code within OrthancRestAnonymizeModify
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2842
diff changeset
222 output_->Update(modifiedHasher);
2642
ccc470091ea6 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
223
ccc470091ea6 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
224 return true;
ccc470091ea6 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
225 }
ccc470091ea6 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
226
ccc470091ea6 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
227
2842
ff0ed5ea9e4e trailing step in SetOfInstancesJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2825
diff changeset
228 bool ResourceModificationJob::HandleTrailingStep()
ff0ed5ea9e4e trailing step in SetOfInstancesJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2825
diff changeset
229 {
ff0ed5ea9e4e trailing step in SetOfInstancesJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2825
diff changeset
230 throw OrthancException(ErrorCode_InternalError);
ff0ed5ea9e4e trailing step in SetOfInstancesJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2825
diff changeset
231 }
ff0ed5ea9e4e trailing step in SetOfInstancesJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2825
diff changeset
232
ff0ed5ea9e4e trailing step in SetOfInstancesJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2825
diff changeset
233
2642
ccc470091ea6 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
234 void ResourceModificationJob::SetModification(DicomModification* modification,
2868
abce036683cd sharing code within OrthancRestAnonymizeModify
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2842
diff changeset
235 ResourceType level,
2642
ccc470091ea6 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
236 bool isAnonymization)
ccc470091ea6 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
237 {
ccc470091ea6 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
238 if (modification == NULL)
ccc470091ea6 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
239 {
ccc470091ea6 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
240 throw OrthancException(ErrorCode_NullPointer);
ccc470091ea6 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
241 }
ccc470091ea6 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
242 else if (IsStarted())
ccc470091ea6 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
243 {
ccc470091ea6 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
244 throw OrthancException(ErrorCode_BadSequenceOfCalls);
ccc470091ea6 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
245 }
ccc470091ea6 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
246 else
ccc470091ea6 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
247 {
ccc470091ea6 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
248 modification_.reset(modification);
2868
abce036683cd sharing code within OrthancRestAnonymizeModify
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2842
diff changeset
249 output_.reset(new Output(level));
2642
ccc470091ea6 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
250 isAnonymization_ = isAnonymization;
ccc470091ea6 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
251 }
ccc470091ea6 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
252 }
ccc470091ea6 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
253
ccc470091ea6 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
254
ccc470091ea6 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
255 void ResourceModificationJob::SetOrigin(const DicomInstanceOrigin& origin)
ccc470091ea6 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
256 {
ccc470091ea6 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
257 if (IsStarted())
ccc470091ea6 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
258 {
ccc470091ea6 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
259 throw OrthancException(ErrorCode_BadSequenceOfCalls);
ccc470091ea6 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
260 }
ccc470091ea6 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
261 else
ccc470091ea6 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
262 {
ccc470091ea6 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
263 origin_ = origin;
ccc470091ea6 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
264 }
ccc470091ea6 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
265 }
ccc470091ea6 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
266
ccc470091ea6 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
267
ccc470091ea6 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
268 void ResourceModificationJob::SetOrigin(const RestApiCall& call)
ccc470091ea6 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
269 {
2664
a21b244efb37 serialization of DicomModalityStoreJob, OrthancPeerStoreJob and ResourceModificationJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2663
diff changeset
270 SetOrigin(DicomInstanceOrigin::FromRest(call));
a21b244efb37 serialization of DicomModalityStoreJob, OrthancPeerStoreJob and ResourceModificationJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2663
diff changeset
271 }
a21b244efb37 serialization of DicomModalityStoreJob, OrthancPeerStoreJob and ResourceModificationJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2663
diff changeset
272
a21b244efb37 serialization of DicomModalityStoreJob, OrthancPeerStoreJob and ResourceModificationJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2663
diff changeset
273
a21b244efb37 serialization of DicomModalityStoreJob, OrthancPeerStoreJob and ResourceModificationJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2663
diff changeset
274 const DicomModification& ResourceModificationJob::GetModification() const
a21b244efb37 serialization of DicomModalityStoreJob, OrthancPeerStoreJob and ResourceModificationJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2663
diff changeset
275 {
a21b244efb37 serialization of DicomModalityStoreJob, OrthancPeerStoreJob and ResourceModificationJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2663
diff changeset
276 if (modification_.get() == NULL)
a21b244efb37 serialization of DicomModalityStoreJob, OrthancPeerStoreJob and ResourceModificationJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2663
diff changeset
277 {
a21b244efb37 serialization of DicomModalityStoreJob, OrthancPeerStoreJob and ResourceModificationJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2663
diff changeset
278 throw OrthancException(ErrorCode_BadSequenceOfCalls);
a21b244efb37 serialization of DicomModalityStoreJob, OrthancPeerStoreJob and ResourceModificationJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2663
diff changeset
279 }
a21b244efb37 serialization of DicomModalityStoreJob, OrthancPeerStoreJob and ResourceModificationJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2663
diff changeset
280 else
a21b244efb37 serialization of DicomModalityStoreJob, OrthancPeerStoreJob and ResourceModificationJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2663
diff changeset
281 {
a21b244efb37 serialization of DicomModalityStoreJob, OrthancPeerStoreJob and ResourceModificationJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2663
diff changeset
282 return *modification_;
a21b244efb37 serialization of DicomModalityStoreJob, OrthancPeerStoreJob and ResourceModificationJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2663
diff changeset
283 }
2642
ccc470091ea6 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
284 }
ccc470091ea6 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
285
ccc470091ea6 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
286
ccc470091ea6 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
287 void ResourceModificationJob::GetPublicContent(Json::Value& value)
ccc470091ea6 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
288 {
ccc470091ea6 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
289 SetOfInstancesJob::GetPublicContent(value);
ccc470091ea6 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
290
ccc470091ea6 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
291 value["IsAnonymization"] = isAnonymization_;
2868
abce036683cd sharing code within OrthancRestAnonymizeModify
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2842
diff changeset
292
abce036683cd sharing code within OrthancRestAnonymizeModify
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2842
diff changeset
293 if (output_.get() != NULL)
abce036683cd sharing code within OrthancRestAnonymizeModify
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2842
diff changeset
294 {
abce036683cd sharing code within OrthancRestAnonymizeModify
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2842
diff changeset
295 output_->Format(value);
abce036683cd sharing code within OrthancRestAnonymizeModify
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2842
diff changeset
296 }
2642
ccc470091ea6 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
297 }
ccc470091ea6 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
298
2664
a21b244efb37 serialization of DicomModalityStoreJob, OrthancPeerStoreJob and ResourceModificationJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2663
diff changeset
299
a21b244efb37 serialization of DicomModalityStoreJob, OrthancPeerStoreJob and ResourceModificationJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2663
diff changeset
300 static const char* MODIFICATION = "Modification";
a21b244efb37 serialization of DicomModalityStoreJob, OrthancPeerStoreJob and ResourceModificationJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2663
diff changeset
301 static const char* ORIGIN = "Origin";
a21b244efb37 serialization of DicomModalityStoreJob, OrthancPeerStoreJob and ResourceModificationJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2663
diff changeset
302 static const char* IS_ANONYMIZATION = "IsAnonymization";
a21b244efb37 serialization of DicomModalityStoreJob, OrthancPeerStoreJob and ResourceModificationJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2663
diff changeset
303
a21b244efb37 serialization of DicomModalityStoreJob, OrthancPeerStoreJob and ResourceModificationJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2663
diff changeset
304
a21b244efb37 serialization of DicomModalityStoreJob, OrthancPeerStoreJob and ResourceModificationJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2663
diff changeset
305 ResourceModificationJob::ResourceModificationJob(ServerContext& context,
a21b244efb37 serialization of DicomModalityStoreJob, OrthancPeerStoreJob and ResourceModificationJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2663
diff changeset
306 const Json::Value& serialized) :
a21b244efb37 serialization of DicomModalityStoreJob, OrthancPeerStoreJob and ResourceModificationJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2663
diff changeset
307 SetOfInstancesJob(serialized),
a21b244efb37 serialization of DicomModalityStoreJob, OrthancPeerStoreJob and ResourceModificationJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2663
diff changeset
308 context_(context)
a21b244efb37 serialization of DicomModalityStoreJob, OrthancPeerStoreJob and ResourceModificationJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2663
diff changeset
309 {
a21b244efb37 serialization of DicomModalityStoreJob, OrthancPeerStoreJob and ResourceModificationJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2663
diff changeset
310 isAnonymization_ = SerializationToolbox::ReadBoolean(serialized, IS_ANONYMIZATION);
a21b244efb37 serialization of DicomModalityStoreJob, OrthancPeerStoreJob and ResourceModificationJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2663
diff changeset
311 origin_ = DicomInstanceOrigin(serialized[ORIGIN]);
a21b244efb37 serialization of DicomModalityStoreJob, OrthancPeerStoreJob and ResourceModificationJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2663
diff changeset
312 modification_.reset(new DicomModification(serialized[MODIFICATION]));
a21b244efb37 serialization of DicomModalityStoreJob, OrthancPeerStoreJob and ResourceModificationJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2663
diff changeset
313 }
2642
ccc470091ea6 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
314
2663
228e2783ce83 some jobs might not be serializable
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2648
diff changeset
315 bool ResourceModificationJob::Serialize(Json::Value& value)
2642
ccc470091ea6 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
316 {
2664
a21b244efb37 serialization of DicomModalityStoreJob, OrthancPeerStoreJob and ResourceModificationJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2663
diff changeset
317 if (!SetOfInstancesJob::Serialize(value))
a21b244efb37 serialization of DicomModalityStoreJob, OrthancPeerStoreJob and ResourceModificationJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2663
diff changeset
318 {
a21b244efb37 serialization of DicomModalityStoreJob, OrthancPeerStoreJob and ResourceModificationJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2663
diff changeset
319 return false;
a21b244efb37 serialization of DicomModalityStoreJob, OrthancPeerStoreJob and ResourceModificationJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2663
diff changeset
320 }
a21b244efb37 serialization of DicomModalityStoreJob, OrthancPeerStoreJob and ResourceModificationJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2663
diff changeset
321 else
a21b244efb37 serialization of DicomModalityStoreJob, OrthancPeerStoreJob and ResourceModificationJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2663
diff changeset
322 {
a21b244efb37 serialization of DicomModalityStoreJob, OrthancPeerStoreJob and ResourceModificationJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2663
diff changeset
323 value[IS_ANONYMIZATION] = isAnonymization_;
a21b244efb37 serialization of DicomModalityStoreJob, OrthancPeerStoreJob and ResourceModificationJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2663
diff changeset
324 origin_.Serialize(value[ORIGIN]);
a21b244efb37 serialization of DicomModalityStoreJob, OrthancPeerStoreJob and ResourceModificationJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2663
diff changeset
325
a21b244efb37 serialization of DicomModalityStoreJob, OrthancPeerStoreJob and ResourceModificationJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2663
diff changeset
326 Json::Value tmp;
a21b244efb37 serialization of DicomModalityStoreJob, OrthancPeerStoreJob and ResourceModificationJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2663
diff changeset
327 modification_->Serialize(tmp);
a21b244efb37 serialization of DicomModalityStoreJob, OrthancPeerStoreJob and ResourceModificationJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2663
diff changeset
328 value[MODIFICATION] = tmp;
2642
ccc470091ea6 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
329
2664
a21b244efb37 serialization of DicomModalityStoreJob, OrthancPeerStoreJob and ResourceModificationJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2663
diff changeset
330 return true;
a21b244efb37 serialization of DicomModalityStoreJob, OrthancPeerStoreJob and ResourceModificationJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2663
diff changeset
331 }
2642
ccc470091ea6 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
332 }
ccc470091ea6 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
333 }