annotate OrthancServer/ServerJobs/StorageCommitmentScpJob.cpp @ 3636:bce6ee64f2a4 storage-commitment

reorganization
author Sebastien Jodogne <s.jodogne@gmail.com>
date Fri, 31 Jan 2020 14:29:35 +0100
parents
children ae866fc06df5
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
3636
bce6ee64f2a4 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1 /**
bce6ee64f2a4 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
2 * Orthanc - A Lightweight, RESTful DICOM Store
bce6ee64f2a4 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
3 * Copyright (C) 2012-2016 Sebastien Jodogne, Medical Physics
bce6ee64f2a4 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
4 * Department, University Hospital of Liege, Belgium
bce6ee64f2a4 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
5 * Copyright (C) 2017-2019 Osimis S.A., Belgium
bce6ee64f2a4 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
6 *
bce6ee64f2a4 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
7 * This program is free software: you can redistribute it and/or
bce6ee64f2a4 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
8 * modify it under the terms of the GNU General Public License as
bce6ee64f2a4 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
9 * published by the Free Software Foundation, either version 3 of the
bce6ee64f2a4 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
10 * License, or (at your option) any later version.
bce6ee64f2a4 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
11 *
bce6ee64f2a4 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
12 * In addition, as a special exception, the copyright holders of this
bce6ee64f2a4 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
13 * program give permission to link the code of its release with the
bce6ee64f2a4 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
14 * OpenSSL project's "OpenSSL" library (or with modified versions of it
bce6ee64f2a4 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
15 * that use the same license as the "OpenSSL" library), and distribute
bce6ee64f2a4 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
16 * the linked executables. You must obey the GNU General Public License
bce6ee64f2a4 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
bce6ee64f2a4 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
18 * modify file(s) with this exception, you may extend this exception to
bce6ee64f2a4 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
bce6ee64f2a4 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
20 * you do not wish to do so, delete this exception statement from your
bce6ee64f2a4 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
21 * version. If you delete this exception statement from all source files
bce6ee64f2a4 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
22 * in the program, then also delete it here.
bce6ee64f2a4 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
23 *
bce6ee64f2a4 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
24 * This program is distributed in the hope that it will be useful, but
bce6ee64f2a4 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
25 * WITHOUT ANY WARRANTY; without even the implied warranty of
bce6ee64f2a4 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
26 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
bce6ee64f2a4 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
27 * General Public License for more details.
bce6ee64f2a4 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
28 *
bce6ee64f2a4 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
29 * You should have received a copy of the GNU General Public License
bce6ee64f2a4 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
30 * along with this program. If not, see <http://www.gnu.org/licenses/>.
bce6ee64f2a4 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
31 **/
bce6ee64f2a4 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
32
bce6ee64f2a4 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
33
bce6ee64f2a4 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
34 #include "../PrecompiledHeadersServer.h"
bce6ee64f2a4 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
35 #include "StorageCommitmentScpJob.h"
bce6ee64f2a4 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
36
bce6ee64f2a4 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
37 #include "../../Core/DicomNetworking/DicomUserConnection.h"
bce6ee64f2a4 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
38 #include "../../Core/Logging.h"
bce6ee64f2a4 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
39 #include "../../Core/OrthancException.h"
bce6ee64f2a4 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
40 #include "../OrthancConfiguration.h"
bce6ee64f2a4 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
41 #include "../ServerContext.h"
bce6ee64f2a4 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
42
bce6ee64f2a4 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
43
bce6ee64f2a4 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
44 namespace Orthanc
bce6ee64f2a4 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
45 {
bce6ee64f2a4 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
46 class StorageCommitmentScpJob::LookupCommand : public SetOfCommandsJob::ICommand
bce6ee64f2a4 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
47 {
bce6ee64f2a4 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
48 private:
bce6ee64f2a4 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
49 StorageCommitmentScpJob& that_;
bce6ee64f2a4 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
50 std::string sopClassUid_;
bce6ee64f2a4 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
51 std::string sopInstanceUid_;
bce6ee64f2a4 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
52
bce6ee64f2a4 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
53 public:
bce6ee64f2a4 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
54 LookupCommand(StorageCommitmentScpJob& that,
bce6ee64f2a4 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
55 const std::string& sopClassUid,
bce6ee64f2a4 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
56 const std::string& sopInstanceUid) :
bce6ee64f2a4 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
57 that_(that),
bce6ee64f2a4 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
58 sopClassUid_(sopClassUid),
bce6ee64f2a4 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
59 sopInstanceUid_(sopInstanceUid)
bce6ee64f2a4 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
60 {
bce6ee64f2a4 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
61 }
bce6ee64f2a4 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
62
bce6ee64f2a4 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
63 virtual bool Execute()
bce6ee64f2a4 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
64 {
bce6ee64f2a4 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
65 that_.LookupInstance(sopClassUid_, sopInstanceUid_);
bce6ee64f2a4 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
66 return true;
bce6ee64f2a4 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
67 }
bce6ee64f2a4 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
68
bce6ee64f2a4 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
69 virtual void Serialize(Json::Value& target) const
bce6ee64f2a4 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
70 {
bce6ee64f2a4 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
71 target = Json::objectValue;
bce6ee64f2a4 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
72 target["Type"] = "Lookup";
bce6ee64f2a4 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
73 target["SopClassUid"] = sopClassUid_;
bce6ee64f2a4 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
74 target["SopInstanceUid"] = sopInstanceUid_;
bce6ee64f2a4 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
75 }
bce6ee64f2a4 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
76 };
bce6ee64f2a4 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
77
bce6ee64f2a4 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
78
bce6ee64f2a4 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
79 class StorageCommitmentScpJob::AnswerCommand : public SetOfCommandsJob::ICommand
bce6ee64f2a4 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
80 {
bce6ee64f2a4 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
81 private:
bce6ee64f2a4 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
82 StorageCommitmentScpJob& that_;
bce6ee64f2a4 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
83
bce6ee64f2a4 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
84 public:
bce6ee64f2a4 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
85 AnswerCommand(StorageCommitmentScpJob& that) :
bce6ee64f2a4 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
86 that_(that)
bce6ee64f2a4 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
87 {
bce6ee64f2a4 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
88 }
bce6ee64f2a4 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
89
bce6ee64f2a4 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
90 virtual bool Execute()
bce6ee64f2a4 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
91 {
bce6ee64f2a4 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
92 that_.Answer();
bce6ee64f2a4 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
93 return true;
bce6ee64f2a4 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
94 }
bce6ee64f2a4 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
95
bce6ee64f2a4 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
96 virtual void Serialize(Json::Value& target) const
bce6ee64f2a4 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
97 {
bce6ee64f2a4 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
98 target = Json::objectValue;
bce6ee64f2a4 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
99 target["Type"] = "Answer";
bce6ee64f2a4 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
100 }
bce6ee64f2a4 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
101 };
bce6ee64f2a4 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
102
bce6ee64f2a4 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
103
bce6ee64f2a4 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
104 class StorageCommitmentScpJob::Unserializer : public SetOfCommandsJob::ICommandUnserializer
bce6ee64f2a4 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
105 {
bce6ee64f2a4 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
106 private:
bce6ee64f2a4 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
107 StorageCommitmentScpJob& that_;
bce6ee64f2a4 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
108
bce6ee64f2a4 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
109 public:
bce6ee64f2a4 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
110 Unserializer(StorageCommitmentScpJob& that) :
bce6ee64f2a4 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
111 that_(that)
bce6ee64f2a4 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
112 {
bce6ee64f2a4 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
113 }
bce6ee64f2a4 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
114
bce6ee64f2a4 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
115 virtual ICommand* Unserialize(const Json::Value& source) const
bce6ee64f2a4 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
116 {
bce6ee64f2a4 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
117 std::cout << "===================================\n";
bce6ee64f2a4 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
118 std::cout << source.toStyledString();
bce6ee64f2a4 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
119
bce6ee64f2a4 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
120 /*DicomMap findAnswer;
bce6ee64f2a4 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
121 findAnswer.Unserialize(source);
bce6ee64f2a4 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
122 return new Command(that_, findAnswer);*/
bce6ee64f2a4 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
123
bce6ee64f2a4 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
124 throw OrthancException(ErrorCode_NotImplemented);
bce6ee64f2a4 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
125 }
bce6ee64f2a4 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
126 };
bce6ee64f2a4 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
127
bce6ee64f2a4 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
128
bce6ee64f2a4 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
129 void StorageCommitmentScpJob::LookupInstance(const std::string& sopClassUid,
bce6ee64f2a4 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
130 const std::string& sopInstanceUid)
bce6ee64f2a4 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
131 {
bce6ee64f2a4 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
132 bool success = false;
bce6ee64f2a4 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
133
bce6ee64f2a4 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
134 try
bce6ee64f2a4 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
135 {
bce6ee64f2a4 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
136 std::vector<std::string> orthancId;
bce6ee64f2a4 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
137 context_.GetIndex().LookupIdentifierExact(orthancId, ResourceType_Instance, DICOM_TAG_SOP_INSTANCE_UID, sopInstanceUid);
bce6ee64f2a4 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
138
bce6ee64f2a4 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
139 if (orthancId.size() == 1)
bce6ee64f2a4 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
140 {
bce6ee64f2a4 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
141 std::string a, b;
bce6ee64f2a4 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
142
bce6ee64f2a4 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
143 // Make sure that the DICOM file can be re-read by DCMTK
bce6ee64f2a4 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
144 // from the file storage, and that the actual SOP
bce6ee64f2a4 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
145 // class/instance UIDs do match
bce6ee64f2a4 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
146 ServerContext::DicomCacheLocker locker(context_, orthancId[0]);
bce6ee64f2a4 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
147 if (locker.GetDicom().GetTagValue(a, DICOM_TAG_SOP_CLASS_UID) &&
bce6ee64f2a4 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
148 locker.GetDicom().GetTagValue(b, DICOM_TAG_SOP_INSTANCE_UID) &&
bce6ee64f2a4 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
149 a == sopClassUid &&
bce6ee64f2a4 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
150 b == sopInstanceUid)
bce6ee64f2a4 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
151 {
bce6ee64f2a4 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
152 success = true;
bce6ee64f2a4 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
153 }
bce6ee64f2a4 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
154 }
bce6ee64f2a4 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
155 }
bce6ee64f2a4 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
156 catch (OrthancException&)
bce6ee64f2a4 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
157 {
bce6ee64f2a4 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
158 }
bce6ee64f2a4 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
159
bce6ee64f2a4 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
160 LOG(INFO) << " Storage commitment SCP job: " << (success ? "Success" : "Failure")
bce6ee64f2a4 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
161 << " while looking for " << sopClassUid << " / " << sopInstanceUid;
bce6ee64f2a4 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
162
bce6ee64f2a4 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
163 if (success)
bce6ee64f2a4 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
164 {
bce6ee64f2a4 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
165 successSopClassUids_.push_back(sopClassUid);
bce6ee64f2a4 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
166 successSopInstanceUids_.push_back(sopInstanceUid);
bce6ee64f2a4 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
167 }
bce6ee64f2a4 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
168 else
bce6ee64f2a4 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
169 {
bce6ee64f2a4 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
170 failedSopClassUids_.push_back(sopClassUid);
bce6ee64f2a4 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
171 failedSopInstanceUids_.push_back(sopInstanceUid);
bce6ee64f2a4 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
172 }
bce6ee64f2a4 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
173 }
bce6ee64f2a4 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
174
bce6ee64f2a4 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
175
bce6ee64f2a4 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
176 void StorageCommitmentScpJob::Answer()
bce6ee64f2a4 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
177 {
bce6ee64f2a4 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
178 LOG(INFO) << " Storage commitment SCP job: Sending answer";
bce6ee64f2a4 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
179
bce6ee64f2a4 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
180 DicomUserConnection scu(calledAet_, remoteModality_);
bce6ee64f2a4 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
181 scu.ReportStorageCommitment(transactionUid_, successSopClassUids_, successSopInstanceUids_,
bce6ee64f2a4 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
182 failedSopClassUids_, failedSopInstanceUids_);
bce6ee64f2a4 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
183 }
bce6ee64f2a4 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
184
bce6ee64f2a4 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
185
bce6ee64f2a4 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
186 StorageCommitmentScpJob::StorageCommitmentScpJob(ServerContext& context,
bce6ee64f2a4 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
187 const std::string& transactionUid,
bce6ee64f2a4 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
188 const std::string& remoteAet,
bce6ee64f2a4 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
189 const std::string& calledAet) :
bce6ee64f2a4 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
190 context_(context),
bce6ee64f2a4 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
191 ready_(false),
bce6ee64f2a4 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
192 transactionUid_(transactionUid),
bce6ee64f2a4 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
193 calledAet_(calledAet)
bce6ee64f2a4 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
194 {
bce6ee64f2a4 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
195 {
bce6ee64f2a4 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
196 OrthancConfiguration::ReaderLock lock;
bce6ee64f2a4 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
197 if (!lock.GetConfiguration().LookupDicomModalityUsingAETitle(remoteModality_, remoteAet))
bce6ee64f2a4 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
198 {
bce6ee64f2a4 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
199 throw OrthancException(ErrorCode_InexistentItem,
bce6ee64f2a4 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
200 "Unknown remote modality for storage commitment SCP: " + remoteAet);
bce6ee64f2a4 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
201 }
bce6ee64f2a4 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
202 }
bce6ee64f2a4 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
203 }
bce6ee64f2a4 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
204
bce6ee64f2a4 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
205
bce6ee64f2a4 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
206 void StorageCommitmentScpJob::AddInstance(const std::string& sopClassUid,
bce6ee64f2a4 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
207 const std::string& sopInstanceUid)
bce6ee64f2a4 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
208 {
bce6ee64f2a4 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
209 if (ready_)
bce6ee64f2a4 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
210 {
bce6ee64f2a4 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
211 throw OrthancException(ErrorCode_BadSequenceOfCalls);
bce6ee64f2a4 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
212 }
bce6ee64f2a4 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
213 else
bce6ee64f2a4 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
214 {
bce6ee64f2a4 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
215 AddCommand(new LookupCommand(*this, sopClassUid, sopInstanceUid));
bce6ee64f2a4 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
216 }
bce6ee64f2a4 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
217 }
bce6ee64f2a4 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
218
bce6ee64f2a4 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
219
bce6ee64f2a4 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
220 void StorageCommitmentScpJob::MarkAsReady()
bce6ee64f2a4 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
221 {
bce6ee64f2a4 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
222 if (ready_)
bce6ee64f2a4 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
223 {
bce6ee64f2a4 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
224 throw OrthancException(ErrorCode_BadSequenceOfCalls);
bce6ee64f2a4 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
225 }
bce6ee64f2a4 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
226 else
bce6ee64f2a4 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
227 {
bce6ee64f2a4 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
228 AddCommand(new AnswerCommand(*this));
bce6ee64f2a4 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
229 ready_ = true;
bce6ee64f2a4 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
230 }
bce6ee64f2a4 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
231 }
bce6ee64f2a4 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
232
bce6ee64f2a4 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
233
bce6ee64f2a4 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
234 void StorageCommitmentScpJob::GetPublicContent(Json::Value& value)
bce6ee64f2a4 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
235 {
bce6ee64f2a4 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
236 SetOfCommandsJob::GetPublicContent(value);
bce6ee64f2a4 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
237
bce6ee64f2a4 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
238 value["LocalAet"] = calledAet_;
bce6ee64f2a4 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
239 value["RemoteAet"] = remoteModality_.GetApplicationEntityTitle();
bce6ee64f2a4 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
240 value["TransactionUid"] = transactionUid_;
bce6ee64f2a4 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
241 }
bce6ee64f2a4 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
242 }