annotate OrthancServer/StorageCommitmentReports.h @ 3822:0d5f3a438e14 transcoding

cont
author Sebastien Jodogne <s.jodogne@gmail.com>
date Fri, 10 Apr 2020 11:39:40 +0200
parents bff4da769f6f
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
3736
0540b54324f1 StorageCommitmentReports
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1 /**
0540b54324f1 StorageCommitmentReports
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
2 * Orthanc - A Lightweight, RESTful DICOM Store
0540b54324f1 StorageCommitmentReports
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
3 * Copyright (C) 2012-2016 Sebastien Jodogne, Medical Physics
0540b54324f1 StorageCommitmentReports
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
4 * Department, University Hospital of Liege, Belgium
0540b54324f1 StorageCommitmentReports
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
5 * Copyright (C) 2017-2020 Osimis S.A., Belgium
0540b54324f1 StorageCommitmentReports
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
6 *
0540b54324f1 StorageCommitmentReports
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
7 * This program is free software: you can redistribute it and/or
0540b54324f1 StorageCommitmentReports
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
8 * modify it under the terms of the GNU General Public License as
0540b54324f1 StorageCommitmentReports
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
9 * published by the Free Software Foundation, either version 3 of the
0540b54324f1 StorageCommitmentReports
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
10 * License, or (at your option) any later version.
0540b54324f1 StorageCommitmentReports
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
11 *
0540b54324f1 StorageCommitmentReports
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
12 * In addition, as a special exception, the copyright holders of this
0540b54324f1 StorageCommitmentReports
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
13 * program give permission to link the code of its release with the
0540b54324f1 StorageCommitmentReports
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
14 * OpenSSL project's "OpenSSL" library (or with modified versions of it
0540b54324f1 StorageCommitmentReports
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
15 * that use the same license as the "OpenSSL" library), and distribute
0540b54324f1 StorageCommitmentReports
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
16 * the linked executables. You must obey the GNU General Public License
0540b54324f1 StorageCommitmentReports
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
17 * in all respects for all of the code used other than "OpenSSL". If you
0540b54324f1 StorageCommitmentReports
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
18 * modify file(s) with this exception, you may extend this exception to
0540b54324f1 StorageCommitmentReports
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
0540b54324f1 StorageCommitmentReports
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
20 * you do not wish to do so, delete this exception statement from your
0540b54324f1 StorageCommitmentReports
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
21 * version. If you delete this exception statement from all source files
0540b54324f1 StorageCommitmentReports
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
22 * in the program, then also delete it here.
0540b54324f1 StorageCommitmentReports
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
23 *
0540b54324f1 StorageCommitmentReports
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
24 * This program is distributed in the hope that it will be useful, but
0540b54324f1 StorageCommitmentReports
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
25 * WITHOUT ANY WARRANTY; without even the implied warranty of
0540b54324f1 StorageCommitmentReports
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
26 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
0540b54324f1 StorageCommitmentReports
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
27 * General Public License for more details.
0540b54324f1 StorageCommitmentReports
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
28 *
0540b54324f1 StorageCommitmentReports
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
29 * You should have received a copy of the GNU General Public License
0540b54324f1 StorageCommitmentReports
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
30 * along with this program. If not, see <http://www.gnu.org/licenses/>.
0540b54324f1 StorageCommitmentReports
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
31 **/
0540b54324f1 StorageCommitmentReports
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
32
0540b54324f1 StorageCommitmentReports
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
33
0540b54324f1 StorageCommitmentReports
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
34 #pragma once
0540b54324f1 StorageCommitmentReports
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
35
0540b54324f1 StorageCommitmentReports
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
36 #include "../Core/Cache/LeastRecentlyUsedIndex.h"
0540b54324f1 StorageCommitmentReports
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
37
0540b54324f1 StorageCommitmentReports
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
38 namespace Orthanc
0540b54324f1 StorageCommitmentReports
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
39 {
0540b54324f1 StorageCommitmentReports
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
40 class StorageCommitmentReports
0540b54324f1 StorageCommitmentReports
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
41 {
0540b54324f1 StorageCommitmentReports
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
42 public:
0540b54324f1 StorageCommitmentReports
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
43 class Report : public boost::noncopyable
0540b54324f1 StorageCommitmentReports
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
44 {
0540b54324f1 StorageCommitmentReports
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
45 public:
0540b54324f1 StorageCommitmentReports
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
46 enum Status
0540b54324f1 StorageCommitmentReports
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
47 {
0540b54324f1 StorageCommitmentReports
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
48 Status_Success,
0540b54324f1 StorageCommitmentReports
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
49 Status_Failure,
0540b54324f1 StorageCommitmentReports
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
50 Status_Pending
0540b54324f1 StorageCommitmentReports
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
51 };
0540b54324f1 StorageCommitmentReports
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
52
0540b54324f1 StorageCommitmentReports
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
53 private:
0540b54324f1 StorageCommitmentReports
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
54 struct Success
0540b54324f1 StorageCommitmentReports
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
55 {
0540b54324f1 StorageCommitmentReports
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
56 std::string sopClassUid_;
0540b54324f1 StorageCommitmentReports
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
57 std::string sopInstanceUid_;
0540b54324f1 StorageCommitmentReports
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
58 };
0540b54324f1 StorageCommitmentReports
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
59
0540b54324f1 StorageCommitmentReports
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
60 struct Failure
0540b54324f1 StorageCommitmentReports
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
61 {
0540b54324f1 StorageCommitmentReports
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
62 std::string sopClassUid_;
0540b54324f1 StorageCommitmentReports
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
63 std::string sopInstanceUid_;
0540b54324f1 StorageCommitmentReports
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
64 StorageCommitmentFailureReason reason_;
0540b54324f1 StorageCommitmentReports
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
65 };
0540b54324f1 StorageCommitmentReports
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
66
0540b54324f1 StorageCommitmentReports
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
67 bool isComplete_;
3737
f29843323daf accessing storage commitment reports from REST API
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3736
diff changeset
68 std::list<Success> success_;
3736
0540b54324f1 StorageCommitmentReports
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
69 std::list<Failure> failures_;
0540b54324f1 StorageCommitmentReports
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
70 std::string remoteAet_;
0540b54324f1 StorageCommitmentReports
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
71
0540b54324f1 StorageCommitmentReports
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
72 public:
0540b54324f1 StorageCommitmentReports
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
73 Report(const std::string& remoteAet) :
0540b54324f1 StorageCommitmentReports
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
74 isComplete_(false),
0540b54324f1 StorageCommitmentReports
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
75 remoteAet_(remoteAet)
0540b54324f1 StorageCommitmentReports
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
76 {
0540b54324f1 StorageCommitmentReports
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
77 }
0540b54324f1 StorageCommitmentReports
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
78
0540b54324f1 StorageCommitmentReports
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
79 const std::string& GetRemoteAet() const
0540b54324f1 StorageCommitmentReports
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
80 {
0540b54324f1 StorageCommitmentReports
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
81 return remoteAet_;
0540b54324f1 StorageCommitmentReports
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
82 }
0540b54324f1 StorageCommitmentReports
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
83
0540b54324f1 StorageCommitmentReports
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
84 void MarkAsComplete();
0540b54324f1 StorageCommitmentReports
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
85
0540b54324f1 StorageCommitmentReports
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
86 void AddSuccess(const std::string& sopClassUid,
0540b54324f1 StorageCommitmentReports
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
87 const std::string& sopInstanceUid);
0540b54324f1 StorageCommitmentReports
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
88
0540b54324f1 StorageCommitmentReports
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
89 void AddFailure(const std::string& sopClassUid,
0540b54324f1 StorageCommitmentReports
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
90 const std::string& sopInstanceUid,
0540b54324f1 StorageCommitmentReports
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
91 StorageCommitmentFailureReason reason);
0540b54324f1 StorageCommitmentReports
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
92
0540b54324f1 StorageCommitmentReports
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
93 Status GetStatus() const;
3737
f29843323daf accessing storage commitment reports from REST API
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3736
diff changeset
94
f29843323daf accessing storage commitment reports from REST API
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3736
diff changeset
95 void Format(Json::Value& json) const;
3738
bff4da769f6f new route: "/storage-commitment/{...}/remove"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3737
diff changeset
96
bff4da769f6f new route: "/storage-commitment/{...}/remove"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3737
diff changeset
97 void GetSuccessSopInstanceUids(std::vector<std::string>& target) const;
3736
0540b54324f1 StorageCommitmentReports
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
98 };
0540b54324f1 StorageCommitmentReports
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
99
0540b54324f1 StorageCommitmentReports
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
100 private:
0540b54324f1 StorageCommitmentReports
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
101 typedef LeastRecentlyUsedIndex<std::string, Report*> Content;
0540b54324f1 StorageCommitmentReports
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
102
0540b54324f1 StorageCommitmentReports
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
103 boost::mutex mutex_;
0540b54324f1 StorageCommitmentReports
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
104 Content content_;
0540b54324f1 StorageCommitmentReports
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
105 size_t maxSize_;
0540b54324f1 StorageCommitmentReports
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
106
0540b54324f1 StorageCommitmentReports
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
107 public:
0540b54324f1 StorageCommitmentReports
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
108 StorageCommitmentReports(size_t maxSize) :
0540b54324f1 StorageCommitmentReports
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
109 maxSize_(maxSize)
0540b54324f1 StorageCommitmentReports
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
110 {
0540b54324f1 StorageCommitmentReports
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
111 }
0540b54324f1 StorageCommitmentReports
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
112
0540b54324f1 StorageCommitmentReports
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
113 ~StorageCommitmentReports();
0540b54324f1 StorageCommitmentReports
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
114
0540b54324f1 StorageCommitmentReports
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
115 size_t GetMaxSize() const
0540b54324f1 StorageCommitmentReports
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
116 {
0540b54324f1 StorageCommitmentReports
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
117 return maxSize_;
0540b54324f1 StorageCommitmentReports
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
118 }
0540b54324f1 StorageCommitmentReports
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
119
0540b54324f1 StorageCommitmentReports
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
120 void Store(const std::string& transactionUid,
0540b54324f1 StorageCommitmentReports
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
121 Report* report); // Takes ownership
0540b54324f1 StorageCommitmentReports
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
122
0540b54324f1 StorageCommitmentReports
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
123 class Accessor : public boost::noncopyable
0540b54324f1 StorageCommitmentReports
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
124 {
0540b54324f1 StorageCommitmentReports
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
125 private:
0540b54324f1 StorageCommitmentReports
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
126 boost::mutex::scoped_lock lock_;
0540b54324f1 StorageCommitmentReports
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
127 std::string transactionUid_;
0540b54324f1 StorageCommitmentReports
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
128 Report *report_;
0540b54324f1 StorageCommitmentReports
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
129
0540b54324f1 StorageCommitmentReports
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
130 public:
0540b54324f1 StorageCommitmentReports
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
131 Accessor(StorageCommitmentReports& that,
0540b54324f1 StorageCommitmentReports
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
132 const std::string& transactionUid);
0540b54324f1 StorageCommitmentReports
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
133
0540b54324f1 StorageCommitmentReports
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
134 const std::string& GetTransactionUid() const
0540b54324f1 StorageCommitmentReports
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
135 {
0540b54324f1 StorageCommitmentReports
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
136 return transactionUid_;
0540b54324f1 StorageCommitmentReports
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
137 }
0540b54324f1 StorageCommitmentReports
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
138
0540b54324f1 StorageCommitmentReports
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
139 bool IsValid() const
0540b54324f1 StorageCommitmentReports
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
140 {
0540b54324f1 StorageCommitmentReports
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
141 return report_ != NULL;
0540b54324f1 StorageCommitmentReports
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
142 }
0540b54324f1 StorageCommitmentReports
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
143
0540b54324f1 StorageCommitmentReports
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
144 const Report& GetReport() const;
0540b54324f1 StorageCommitmentReports
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
145 };
0540b54324f1 StorageCommitmentReports
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
146 };
0540b54324f1 StorageCommitmentReports
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
147 }