annotate OrthancServer/ServerJobs/StorageCommitmentScpJob.cpp @ 3658:2d90dd30858c storage-commitment

providing job ID to the IJob::Step() methods
author Sebastien Jodogne <s.jodogne@gmail.com>
date Mon, 10 Feb 2020 16:44:26 +0100
parents 115f82775c46
children 08eb0f93c491
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
3642
fddf3fc82362 upgrade to year 2020
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3639
diff changeset
5 * Copyright (C) 2017-2020 Osimis S.A., Belgium
3636
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"
3638
ae866fc06df5 serialization of StorageCommitmentScpJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3636
diff changeset
40 #include "../../Core/SerializationToolbox.h"
3636
bce6ee64f2a4 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
41 #include "../OrthancConfiguration.h"
bce6ee64f2a4 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
42 #include "../ServerContext.h"
bce6ee64f2a4 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
43
bce6ee64f2a4 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
44
3638
ae866fc06df5 serialization of StorageCommitmentScpJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3636
diff changeset
45 static const char* ANSWER = "Answer";
ae866fc06df5 serialization of StorageCommitmentScpJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3636
diff changeset
46 static const char* CALLED_AET = "CalledAet";
ae866fc06df5 serialization of StorageCommitmentScpJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3636
diff changeset
47 static const char* LOOKUP = "Lookup";
ae866fc06df5 serialization of StorageCommitmentScpJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3636
diff changeset
48 static const char* REMOTE_MODALITY = "RemoteModality";
ae866fc06df5 serialization of StorageCommitmentScpJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3636
diff changeset
49 static const char* SOP_CLASS_UID = "SopClassUid";
ae866fc06df5 serialization of StorageCommitmentScpJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3636
diff changeset
50 static const char* SOP_INSTANCE_UID = "SopInstanceUid";
ae866fc06df5 serialization of StorageCommitmentScpJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3636
diff changeset
51 static const char* TRANSACTION_UID = "TransactionUid";
ae866fc06df5 serialization of StorageCommitmentScpJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3636
diff changeset
52 static const char* TYPE = "Type";
ae866fc06df5 serialization of StorageCommitmentScpJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3636
diff changeset
53
ae866fc06df5 serialization of StorageCommitmentScpJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3636
diff changeset
54
ae866fc06df5 serialization of StorageCommitmentScpJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3636
diff changeset
55
3636
bce6ee64f2a4 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
56 namespace Orthanc
bce6ee64f2a4 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
57 {
3657
115f82775c46 handling of storage commitment failure reasons
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3642
diff changeset
58 class StorageCommitmentScpJob::StorageCommitmentCommand : public SetOfCommandsJob::ICommand
115f82775c46 handling of storage commitment failure reasons
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3642
diff changeset
59 {
115f82775c46 handling of storage commitment failure reasons
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3642
diff changeset
60 public:
115f82775c46 handling of storage commitment failure reasons
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3642
diff changeset
61 virtual bool IsAnswer() const = 0;
115f82775c46 handling of storage commitment failure reasons
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3642
diff changeset
62 };
115f82775c46 handling of storage commitment failure reasons
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3642
diff changeset
63
115f82775c46 handling of storage commitment failure reasons
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3642
diff changeset
64
115f82775c46 handling of storage commitment failure reasons
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3642
diff changeset
65 class StorageCommitmentScpJob::LookupCommand : public StorageCommitmentCommand
3636
bce6ee64f2a4 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
66 {
bce6ee64f2a4 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
67 private:
3657
115f82775c46 handling of storage commitment failure reasons
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3642
diff changeset
68 ServerContext& context_;
115f82775c46 handling of storage commitment failure reasons
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3642
diff changeset
69 bool hasFailureReason_;
115f82775c46 handling of storage commitment failure reasons
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3642
diff changeset
70 std::string sopClassUid_;
115f82775c46 handling of storage commitment failure reasons
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3642
diff changeset
71 std::string sopInstanceUid_;
115f82775c46 handling of storage commitment failure reasons
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3642
diff changeset
72 StorageCommitmentFailureReason failureReason_;
3636
bce6ee64f2a4 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
73
bce6ee64f2a4 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
74 public:
3657
115f82775c46 handling of storage commitment failure reasons
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3642
diff changeset
75 LookupCommand(ServerContext& context,
3636
bce6ee64f2a4 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
76 const std::string& sopClassUid,
bce6ee64f2a4 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
77 const std::string& sopInstanceUid) :
3657
115f82775c46 handling of storage commitment failure reasons
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3642
diff changeset
78 context_(context),
115f82775c46 handling of storage commitment failure reasons
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3642
diff changeset
79 hasFailureReason_(false),
3636
bce6ee64f2a4 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
80 sopClassUid_(sopClassUid),
bce6ee64f2a4 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
81 sopInstanceUid_(sopInstanceUid)
bce6ee64f2a4 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
82 {
bce6ee64f2a4 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
83 }
bce6ee64f2a4 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
84
3657
115f82775c46 handling of storage commitment failure reasons
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3642
diff changeset
85 virtual bool IsAnswer() const
115f82775c46 handling of storage commitment failure reasons
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3642
diff changeset
86 {
115f82775c46 handling of storage commitment failure reasons
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3642
diff changeset
87 return false;
115f82775c46 handling of storage commitment failure reasons
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3642
diff changeset
88 }
115f82775c46 handling of storage commitment failure reasons
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3642
diff changeset
89
3658
2d90dd30858c providing job ID to the IJob::Step() methods
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3657
diff changeset
90 virtual bool Execute(const std::string& jobId) ORTHANC_OVERRIDE
3636
bce6ee64f2a4 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
91 {
3657
115f82775c46 handling of storage commitment failure reasons
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3642
diff changeset
92 if (hasFailureReason_)
115f82775c46 handling of storage commitment failure reasons
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3642
diff changeset
93 {
115f82775c46 handling of storage commitment failure reasons
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3642
diff changeset
94 throw OrthancException(ErrorCode_BadSequenceOfCalls);
115f82775c46 handling of storage commitment failure reasons
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3642
diff changeset
95 }
115f82775c46 handling of storage commitment failure reasons
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3642
diff changeset
96
115f82775c46 handling of storage commitment failure reasons
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3642
diff changeset
97 bool success = false;
115f82775c46 handling of storage commitment failure reasons
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3642
diff changeset
98
115f82775c46 handling of storage commitment failure reasons
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3642
diff changeset
99 try
115f82775c46 handling of storage commitment failure reasons
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3642
diff changeset
100 {
115f82775c46 handling of storage commitment failure reasons
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3642
diff changeset
101 std::vector<std::string> orthancId;
115f82775c46 handling of storage commitment failure reasons
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3642
diff changeset
102 context_.GetIndex().LookupIdentifierExact(orthancId, ResourceType_Instance, DICOM_TAG_SOP_INSTANCE_UID, sopInstanceUid_);
115f82775c46 handling of storage commitment failure reasons
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3642
diff changeset
103
115f82775c46 handling of storage commitment failure reasons
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3642
diff changeset
104 if (orthancId.size() == 1)
115f82775c46 handling of storage commitment failure reasons
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3642
diff changeset
105 {
115f82775c46 handling of storage commitment failure reasons
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3642
diff changeset
106 std::string a, b;
115f82775c46 handling of storage commitment failure reasons
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3642
diff changeset
107
115f82775c46 handling of storage commitment failure reasons
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3642
diff changeset
108 // Make sure that the DICOM file can be re-read by DCMTK
115f82775c46 handling of storage commitment failure reasons
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3642
diff changeset
109 // from the file storage, and that the actual SOP
115f82775c46 handling of storage commitment failure reasons
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3642
diff changeset
110 // class/instance UIDs do match
115f82775c46 handling of storage commitment failure reasons
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3642
diff changeset
111 ServerContext::DicomCacheLocker locker(context_, orthancId[0]);
115f82775c46 handling of storage commitment failure reasons
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3642
diff changeset
112 if (locker.GetDicom().GetTagValue(a, DICOM_TAG_SOP_CLASS_UID) &&
115f82775c46 handling of storage commitment failure reasons
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3642
diff changeset
113 locker.GetDicom().GetTagValue(b, DICOM_TAG_SOP_INSTANCE_UID) &&
115f82775c46 handling of storage commitment failure reasons
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3642
diff changeset
114 a == sopClassUid_ &&
115f82775c46 handling of storage commitment failure reasons
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3642
diff changeset
115 b == sopInstanceUid_)
115f82775c46 handling of storage commitment failure reasons
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3642
diff changeset
116 {
115f82775c46 handling of storage commitment failure reasons
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3642
diff changeset
117 success = true;
115f82775c46 handling of storage commitment failure reasons
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3642
diff changeset
118 }
115f82775c46 handling of storage commitment failure reasons
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3642
diff changeset
119 }
115f82775c46 handling of storage commitment failure reasons
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3642
diff changeset
120 }
115f82775c46 handling of storage commitment failure reasons
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3642
diff changeset
121 catch (OrthancException&)
115f82775c46 handling of storage commitment failure reasons
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3642
diff changeset
122 {
115f82775c46 handling of storage commitment failure reasons
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3642
diff changeset
123 }
115f82775c46 handling of storage commitment failure reasons
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3642
diff changeset
124
115f82775c46 handling of storage commitment failure reasons
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3642
diff changeset
125 LOG(INFO) << " Storage commitment SCP job: " << (success ? "Success" : "Failure")
115f82775c46 handling of storage commitment failure reasons
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3642
diff changeset
126 << " while looking for " << sopClassUid_ << " / " << sopInstanceUid_;
115f82775c46 handling of storage commitment failure reasons
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3642
diff changeset
127
115f82775c46 handling of storage commitment failure reasons
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3642
diff changeset
128 failureReason_ = (success ?
115f82775c46 handling of storage commitment failure reasons
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3642
diff changeset
129 StorageCommitmentFailureReason_Success :
115f82775c46 handling of storage commitment failure reasons
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3642
diff changeset
130 StorageCommitmentFailureReason_NoSuchObjectInstance /* 0x0112 == 274 */);
115f82775c46 handling of storage commitment failure reasons
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3642
diff changeset
131 hasFailureReason_ = true;
115f82775c46 handling of storage commitment failure reasons
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3642
diff changeset
132
3636
bce6ee64f2a4 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
133 return true;
bce6ee64f2a4 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
134 }
bce6ee64f2a4 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
135
3657
115f82775c46 handling of storage commitment failure reasons
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3642
diff changeset
136 const std::string& GetSopClassUid() const
115f82775c46 handling of storage commitment failure reasons
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3642
diff changeset
137 {
115f82775c46 handling of storage commitment failure reasons
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3642
diff changeset
138 return sopClassUid_;
115f82775c46 handling of storage commitment failure reasons
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3642
diff changeset
139 }
115f82775c46 handling of storage commitment failure reasons
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3642
diff changeset
140
115f82775c46 handling of storage commitment failure reasons
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3642
diff changeset
141 const std::string& GetSopInstanceUid() const
115f82775c46 handling of storage commitment failure reasons
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3642
diff changeset
142 {
115f82775c46 handling of storage commitment failure reasons
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3642
diff changeset
143 return sopInstanceUid_;
115f82775c46 handling of storage commitment failure reasons
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3642
diff changeset
144 }
115f82775c46 handling of storage commitment failure reasons
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3642
diff changeset
145
115f82775c46 handling of storage commitment failure reasons
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3642
diff changeset
146 StorageCommitmentFailureReason GetFailureReason() const
115f82775c46 handling of storage commitment failure reasons
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3642
diff changeset
147 {
115f82775c46 handling of storage commitment failure reasons
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3642
diff changeset
148 if (hasFailureReason_)
115f82775c46 handling of storage commitment failure reasons
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3642
diff changeset
149 {
115f82775c46 handling of storage commitment failure reasons
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3642
diff changeset
150 return failureReason_;
115f82775c46 handling of storage commitment failure reasons
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3642
diff changeset
151 }
115f82775c46 handling of storage commitment failure reasons
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3642
diff changeset
152 else
115f82775c46 handling of storage commitment failure reasons
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3642
diff changeset
153 {
115f82775c46 handling of storage commitment failure reasons
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3642
diff changeset
154 throw OrthancException(ErrorCode_BadSequenceOfCalls);
115f82775c46 handling of storage commitment failure reasons
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3642
diff changeset
155 }
115f82775c46 handling of storage commitment failure reasons
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3642
diff changeset
156 }
115f82775c46 handling of storage commitment failure reasons
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3642
diff changeset
157
3636
bce6ee64f2a4 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
158 virtual void Serialize(Json::Value& target) const
bce6ee64f2a4 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
159 {
bce6ee64f2a4 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
160 target = Json::objectValue;
3638
ae866fc06df5 serialization of StorageCommitmentScpJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3636
diff changeset
161 target[TYPE] = LOOKUP;
ae866fc06df5 serialization of StorageCommitmentScpJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3636
diff changeset
162 target[SOP_CLASS_UID] = sopClassUid_;
ae866fc06df5 serialization of StorageCommitmentScpJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3636
diff changeset
163 target[SOP_INSTANCE_UID] = sopInstanceUid_;
3636
bce6ee64f2a4 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
164 }
bce6ee64f2a4 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
165 };
bce6ee64f2a4 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
166
bce6ee64f2a4 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
167
3657
115f82775c46 handling of storage commitment failure reasons
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3642
diff changeset
168 class StorageCommitmentScpJob::AnswerCommand : public StorageCommitmentCommand
3636
bce6ee64f2a4 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
169 {
bce6ee64f2a4 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
170 private:
bce6ee64f2a4 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
171 StorageCommitmentScpJob& that_;
bce6ee64f2a4 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
172
bce6ee64f2a4 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
173 public:
bce6ee64f2a4 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
174 AnswerCommand(StorageCommitmentScpJob& that) :
bce6ee64f2a4 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
175 that_(that)
bce6ee64f2a4 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
176 {
3639
0c9a8f6d2349 better unserialization
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3638
diff changeset
177 if (that_.ready_)
0c9a8f6d2349 better unserialization
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3638
diff changeset
178 {
0c9a8f6d2349 better unserialization
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3638
diff changeset
179 throw OrthancException(ErrorCode_BadSequenceOfCalls);
0c9a8f6d2349 better unserialization
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3638
diff changeset
180 }
0c9a8f6d2349 better unserialization
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3638
diff changeset
181 else
0c9a8f6d2349 better unserialization
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3638
diff changeset
182 {
0c9a8f6d2349 better unserialization
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3638
diff changeset
183 that_.ready_ = true;
0c9a8f6d2349 better unserialization
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3638
diff changeset
184 }
3636
bce6ee64f2a4 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
185 }
bce6ee64f2a4 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
186
3657
115f82775c46 handling of storage commitment failure reasons
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3642
diff changeset
187 virtual bool IsAnswer() const
115f82775c46 handling of storage commitment failure reasons
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3642
diff changeset
188 {
115f82775c46 handling of storage commitment failure reasons
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3642
diff changeset
189 return true;
115f82775c46 handling of storage commitment failure reasons
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3642
diff changeset
190 }
115f82775c46 handling of storage commitment failure reasons
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3642
diff changeset
191
3658
2d90dd30858c providing job ID to the IJob::Step() methods
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3657
diff changeset
192 virtual bool Execute(const std::string& jobId) ORTHANC_OVERRIDE
3636
bce6ee64f2a4 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
193 {
bce6ee64f2a4 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
194 that_.Answer();
bce6ee64f2a4 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
195 return true;
bce6ee64f2a4 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
196 }
bce6ee64f2a4 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
197
bce6ee64f2a4 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
198 virtual void Serialize(Json::Value& target) const
bce6ee64f2a4 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
199 {
bce6ee64f2a4 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
200 target = Json::objectValue;
3638
ae866fc06df5 serialization of StorageCommitmentScpJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3636
diff changeset
201 target[TYPE] = ANSWER;
3636
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 class StorageCommitmentScpJob::Unserializer : public SetOfCommandsJob::ICommandUnserializer
bce6ee64f2a4 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
207 {
bce6ee64f2a4 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
208 private:
3657
115f82775c46 handling of storage commitment failure reasons
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3642
diff changeset
209 StorageCommitmentScpJob& that_;
115f82775c46 handling of storage commitment failure reasons
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3642
diff changeset
210 ServerContext& context_;
3636
bce6ee64f2a4 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
211
bce6ee64f2a4 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
212 public:
3657
115f82775c46 handling of storage commitment failure reasons
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3642
diff changeset
213 Unserializer(StorageCommitmentScpJob& that,
115f82775c46 handling of storage commitment failure reasons
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3642
diff changeset
214 ServerContext& context) :
115f82775c46 handling of storage commitment failure reasons
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3642
diff changeset
215 that_(that),
115f82775c46 handling of storage commitment failure reasons
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3642
diff changeset
216 context_(context)
3636
bce6ee64f2a4 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
217 {
3639
0c9a8f6d2349 better unserialization
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3638
diff changeset
218 that_.ready_ = false;
3636
bce6ee64f2a4 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
219 }
bce6ee64f2a4 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
220
bce6ee64f2a4 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
221 virtual ICommand* Unserialize(const Json::Value& source) const
bce6ee64f2a4 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
222 {
3638
ae866fc06df5 serialization of StorageCommitmentScpJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3636
diff changeset
223 const std::string type = SerializationToolbox::ReadString(source, TYPE);
3636
bce6ee64f2a4 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
224
3638
ae866fc06df5 serialization of StorageCommitmentScpJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3636
diff changeset
225 if (type == LOOKUP)
ae866fc06df5 serialization of StorageCommitmentScpJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3636
diff changeset
226 {
3657
115f82775c46 handling of storage commitment failure reasons
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3642
diff changeset
227 return new LookupCommand(context_,
3638
ae866fc06df5 serialization of StorageCommitmentScpJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3636
diff changeset
228 SerializationToolbox::ReadString(source, SOP_CLASS_UID),
ae866fc06df5 serialization of StorageCommitmentScpJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3636
diff changeset
229 SerializationToolbox::ReadString(source, SOP_INSTANCE_UID));
ae866fc06df5 serialization of StorageCommitmentScpJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3636
diff changeset
230 }
ae866fc06df5 serialization of StorageCommitmentScpJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3636
diff changeset
231 else if (type == ANSWER)
ae866fc06df5 serialization of StorageCommitmentScpJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3636
diff changeset
232 {
ae866fc06df5 serialization of StorageCommitmentScpJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3636
diff changeset
233 return new AnswerCommand(that_);
ae866fc06df5 serialization of StorageCommitmentScpJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3636
diff changeset
234 }
ae866fc06df5 serialization of StorageCommitmentScpJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3636
diff changeset
235 else
ae866fc06df5 serialization of StorageCommitmentScpJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3636
diff changeset
236 {
ae866fc06df5 serialization of StorageCommitmentScpJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3636
diff changeset
237 throw OrthancException(ErrorCode_BadFileFormat);
ae866fc06df5 serialization of StorageCommitmentScpJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3636
diff changeset
238 }
3636
bce6ee64f2a4 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
239 }
bce6ee64f2a4 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
240 };
bce6ee64f2a4 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
241
bce6ee64f2a4 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
242
3657
115f82775c46 handling of storage commitment failure reasons
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3642
diff changeset
243 void StorageCommitmentScpJob::Answer()
115f82775c46 handling of storage commitment failure reasons
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3642
diff changeset
244 {
115f82775c46 handling of storage commitment failure reasons
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3642
diff changeset
245 LOG(INFO) << " Storage commitment SCP job: Sending answer";
115f82775c46 handling of storage commitment failure reasons
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3642
diff changeset
246
115f82775c46 handling of storage commitment failure reasons
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3642
diff changeset
247 const size_t n = GetCommandsCount();
115f82775c46 handling of storage commitment failure reasons
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3642
diff changeset
248
115f82775c46 handling of storage commitment failure reasons
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3642
diff changeset
249 if (n == 0)
3636
bce6ee64f2a4 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
250 {
3657
115f82775c46 handling of storage commitment failure reasons
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3642
diff changeset
251 throw OrthancException(ErrorCode_InternalError);
115f82775c46 handling of storage commitment failure reasons
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3642
diff changeset
252 }
115f82775c46 handling of storage commitment failure reasons
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3642
diff changeset
253
115f82775c46 handling of storage commitment failure reasons
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3642
diff changeset
254 std::vector<std::string> sopClassUids, sopInstanceUids;
115f82775c46 handling of storage commitment failure reasons
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3642
diff changeset
255 std::vector<StorageCommitmentFailureReason> failureReasons;
3636
bce6ee64f2a4 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
256
3657
115f82775c46 handling of storage commitment failure reasons
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3642
diff changeset
257 sopClassUids.reserve(n);
115f82775c46 handling of storage commitment failure reasons
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3642
diff changeset
258 sopInstanceUids.reserve(n);
115f82775c46 handling of storage commitment failure reasons
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3642
diff changeset
259 failureReasons.reserve(n);
115f82775c46 handling of storage commitment failure reasons
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3642
diff changeset
260
115f82775c46 handling of storage commitment failure reasons
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3642
diff changeset
261 for (size_t i = 0; i < n; i++)
115f82775c46 handling of storage commitment failure reasons
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3642
diff changeset
262 {
115f82775c46 handling of storage commitment failure reasons
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3642
diff changeset
263 const StorageCommitmentCommand& command = dynamic_cast<const StorageCommitmentCommand&>(GetCommand(i));
115f82775c46 handling of storage commitment failure reasons
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3642
diff changeset
264
115f82775c46 handling of storage commitment failure reasons
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3642
diff changeset
265 if (i == n - 1)
3636
bce6ee64f2a4 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
266 {
3657
115f82775c46 handling of storage commitment failure reasons
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3642
diff changeset
267 if (!command.IsAnswer())
115f82775c46 handling of storage commitment failure reasons
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3642
diff changeset
268 {
115f82775c46 handling of storage commitment failure reasons
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3642
diff changeset
269 throw OrthancException(ErrorCode_InternalError);
115f82775c46 handling of storage commitment failure reasons
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3642
diff changeset
270 }
115f82775c46 handling of storage commitment failure reasons
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3642
diff changeset
271 }
115f82775c46 handling of storage commitment failure reasons
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3642
diff changeset
272 else
115f82775c46 handling of storage commitment failure reasons
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3642
diff changeset
273 {
115f82775c46 handling of storage commitment failure reasons
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3642
diff changeset
274 if (command.IsAnswer())
115f82775c46 handling of storage commitment failure reasons
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3642
diff changeset
275 {
115f82775c46 handling of storage commitment failure reasons
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3642
diff changeset
276 throw OrthancException(ErrorCode_InternalError);
115f82775c46 handling of storage commitment failure reasons
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3642
diff changeset
277 }
3636
bce6ee64f2a4 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
278
3657
115f82775c46 handling of storage commitment failure reasons
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3642
diff changeset
279 const LookupCommand& lookup = dynamic_cast<const LookupCommand&>(command);
115f82775c46 handling of storage commitment failure reasons
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3642
diff changeset
280
115f82775c46 handling of storage commitment failure reasons
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3642
diff changeset
281 sopClassUids.push_back(lookup.GetSopClassUid());
115f82775c46 handling of storage commitment failure reasons
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3642
diff changeset
282 sopInstanceUids.push_back(lookup.GetSopInstanceUid());
115f82775c46 handling of storage commitment failure reasons
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3642
diff changeset
283 failureReasons.push_back(lookup.GetFailureReason());
3636
bce6ee64f2a4 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
284 }
bce6ee64f2a4 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
285 }
bce6ee64f2a4 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
286
bce6ee64f2a4 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
287 DicomUserConnection scu(calledAet_, remoteModality_);
3657
115f82775c46 handling of storage commitment failure reasons
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3642
diff changeset
288 scu.ReportStorageCommitment(transactionUid_, sopClassUids, sopInstanceUids, failureReasons);
3636
bce6ee64f2a4 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
289 }
bce6ee64f2a4 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
290
bce6ee64f2a4 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
291
bce6ee64f2a4 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
292 StorageCommitmentScpJob::StorageCommitmentScpJob(ServerContext& context,
bce6ee64f2a4 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
293 const std::string& transactionUid,
bce6ee64f2a4 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
294 const std::string& remoteAet,
bce6ee64f2a4 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
295 const std::string& calledAet) :
bce6ee64f2a4 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
296 context_(context),
bce6ee64f2a4 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
297 ready_(false),
bce6ee64f2a4 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
298 transactionUid_(transactionUid),
bce6ee64f2a4 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
299 calledAet_(calledAet)
bce6ee64f2a4 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
300 {
bce6ee64f2a4 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
301 {
bce6ee64f2a4 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
302 OrthancConfiguration::ReaderLock lock;
bce6ee64f2a4 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
303 if (!lock.GetConfiguration().LookupDicomModalityUsingAETitle(remoteModality_, remoteAet))
bce6ee64f2a4 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
304 {
bce6ee64f2a4 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
305 throw OrthancException(ErrorCode_InexistentItem,
bce6ee64f2a4 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
306 "Unknown remote modality for storage commitment SCP: " + remoteAet);
bce6ee64f2a4 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
307 }
bce6ee64f2a4 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
308 }
bce6ee64f2a4 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
309 }
bce6ee64f2a4 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
310
bce6ee64f2a4 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
311
bce6ee64f2a4 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
312 void StorageCommitmentScpJob::AddInstance(const std::string& sopClassUid,
bce6ee64f2a4 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
313 const std::string& sopInstanceUid)
bce6ee64f2a4 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
314 {
bce6ee64f2a4 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
315 if (ready_)
bce6ee64f2a4 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
316 {
bce6ee64f2a4 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
317 throw OrthancException(ErrorCode_BadSequenceOfCalls);
bce6ee64f2a4 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
318 }
bce6ee64f2a4 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
319 else
bce6ee64f2a4 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
320 {
3657
115f82775c46 handling of storage commitment failure reasons
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3642
diff changeset
321 AddCommand(new LookupCommand(context_, sopClassUid, sopInstanceUid));
3636
bce6ee64f2a4 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
322 }
bce6ee64f2a4 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
323 }
bce6ee64f2a4 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
324
bce6ee64f2a4 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
325
bce6ee64f2a4 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
326 void StorageCommitmentScpJob::MarkAsReady()
bce6ee64f2a4 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
327 {
3639
0c9a8f6d2349 better unserialization
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3638
diff changeset
328 AddCommand(new AnswerCommand(*this));
3636
bce6ee64f2a4 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
329 }
bce6ee64f2a4 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
330
bce6ee64f2a4 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
331
bce6ee64f2a4 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
332 void StorageCommitmentScpJob::GetPublicContent(Json::Value& value)
bce6ee64f2a4 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
333 {
bce6ee64f2a4 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
334 SetOfCommandsJob::GetPublicContent(value);
bce6ee64f2a4 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
335
3638
ae866fc06df5 serialization of StorageCommitmentScpJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3636
diff changeset
336 value["CalledAet"] = calledAet_;
3636
bce6ee64f2a4 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
337 value["RemoteAet"] = remoteModality_.GetApplicationEntityTitle();
bce6ee64f2a4 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
338 value["TransactionUid"] = transactionUid_;
bce6ee64f2a4 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
339 }
3638
ae866fc06df5 serialization of StorageCommitmentScpJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3636
diff changeset
340
ae866fc06df5 serialization of StorageCommitmentScpJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3636
diff changeset
341
ae866fc06df5 serialization of StorageCommitmentScpJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3636
diff changeset
342 StorageCommitmentScpJob::StorageCommitmentScpJob(ServerContext& context,
ae866fc06df5 serialization of StorageCommitmentScpJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3636
diff changeset
343 const Json::Value& serialized) :
3657
115f82775c46 handling of storage commitment failure reasons
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3642
diff changeset
344 SetOfCommandsJob(new Unserializer(*this, context), serialized),
3639
0c9a8f6d2349 better unserialization
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3638
diff changeset
345 context_(context)
3638
ae866fc06df5 serialization of StorageCommitmentScpJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3636
diff changeset
346 {
ae866fc06df5 serialization of StorageCommitmentScpJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3636
diff changeset
347 transactionUid_ = SerializationToolbox::ReadString(serialized, TRANSACTION_UID);
ae866fc06df5 serialization of StorageCommitmentScpJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3636
diff changeset
348 remoteModality_ = RemoteModalityParameters(serialized[REMOTE_MODALITY]);
ae866fc06df5 serialization of StorageCommitmentScpJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3636
diff changeset
349 calledAet_ = SerializationToolbox::ReadString(serialized, CALLED_AET);
ae866fc06df5 serialization of StorageCommitmentScpJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3636
diff changeset
350 }
ae866fc06df5 serialization of StorageCommitmentScpJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3636
diff changeset
351
ae866fc06df5 serialization of StorageCommitmentScpJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3636
diff changeset
352
ae866fc06df5 serialization of StorageCommitmentScpJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3636
diff changeset
353 bool StorageCommitmentScpJob::Serialize(Json::Value& target)
ae866fc06df5 serialization of StorageCommitmentScpJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3636
diff changeset
354 {
ae866fc06df5 serialization of StorageCommitmentScpJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3636
diff changeset
355 if (!SetOfCommandsJob::Serialize(target))
ae866fc06df5 serialization of StorageCommitmentScpJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3636
diff changeset
356 {
ae866fc06df5 serialization of StorageCommitmentScpJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3636
diff changeset
357 return false;
ae866fc06df5 serialization of StorageCommitmentScpJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3636
diff changeset
358 }
ae866fc06df5 serialization of StorageCommitmentScpJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3636
diff changeset
359 else
ae866fc06df5 serialization of StorageCommitmentScpJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3636
diff changeset
360 {
ae866fc06df5 serialization of StorageCommitmentScpJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3636
diff changeset
361 target[TRANSACTION_UID] = transactionUid_;
ae866fc06df5 serialization of StorageCommitmentScpJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3636
diff changeset
362 remoteModality_.Serialize(target[REMOTE_MODALITY], true /* force advanced format */);
ae866fc06df5 serialization of StorageCommitmentScpJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3636
diff changeset
363 target[CALLED_AET] = calledAet_;
ae866fc06df5 serialization of StorageCommitmentScpJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3636
diff changeset
364 return true;
ae866fc06df5 serialization of StorageCommitmentScpJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3636
diff changeset
365 }
ae866fc06df5 serialization of StorageCommitmentScpJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3636
diff changeset
366 }
3636
bce6ee64f2a4 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
367 }