Mercurial > hg > orthanc
annotate OrthancFramework/Sources/JobsEngine/JobStepResult.cpp @ 4300:b30a8de92ad9
abi continued
author | Sebastien Jodogne <s.jodogne@gmail.com> |
---|---|
date | Thu, 05 Nov 2020 19:33:18 +0100 |
parents | bf7b9edf6b81 |
children | d9473bd5ed43 |
rev | line source |
---|---|
2598
34dc57f4a7d2
simplification of JobStepResult
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1 /** |
34dc57f4a7d2
simplification of JobStepResult
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
2 * Orthanc - A Lightweight, RESTful DICOM Store |
34dc57f4a7d2
simplification of JobStepResult
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
3 * Copyright (C) 2012-2016 Sebastien Jodogne, Medical Physics |
34dc57f4a7d2
simplification of JobStepResult
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
4 * Department, University Hospital of Liege, Belgium |
3640
94f4a18a79cc
upgrade to year 2020
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3240
diff
changeset
|
5 * Copyright (C) 2017-2020 Osimis S.A., Belgium |
2598
34dc57f4a7d2
simplification of JobStepResult
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
6 * |
34dc57f4a7d2
simplification of JobStepResult
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
7 * This program is free software: you can redistribute it and/or |
4119
bf7b9edf6b81
re-licensing the OrthancFramework to LGPL, in order to license Stone of Orthanc under LGPL
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4044
diff
changeset
|
8 * modify it under the terms of the GNU Lesser General Public License |
bf7b9edf6b81
re-licensing the OrthancFramework to LGPL, in order to license Stone of Orthanc under LGPL
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4044
diff
changeset
|
9 * as published by the Free Software Foundation, either version 3 of |
bf7b9edf6b81
re-licensing the OrthancFramework to LGPL, in order to license Stone of Orthanc under LGPL
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4044
diff
changeset
|
10 * the License, or (at your option) any later version. |
2598
34dc57f4a7d2
simplification of JobStepResult
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
11 * |
34dc57f4a7d2
simplification of JobStepResult
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
12 * This program is distributed in the hope that it will be useful, but |
34dc57f4a7d2
simplification of JobStepResult
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
13 * WITHOUT ANY WARRANTY; without even the implied warranty of |
34dc57f4a7d2
simplification of JobStepResult
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
4119
bf7b9edf6b81
re-licensing the OrthancFramework to LGPL, in order to license Stone of Orthanc under LGPL
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4044
diff
changeset
|
15 * Lesser General Public License for more details. |
2598
34dc57f4a7d2
simplification of JobStepResult
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
16 * |
4119
bf7b9edf6b81
re-licensing the OrthancFramework to LGPL, in order to license Stone of Orthanc under LGPL
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4044
diff
changeset
|
17 * You should have received a copy of the GNU Lesser General Public |
bf7b9edf6b81
re-licensing the OrthancFramework to LGPL, in order to license Stone of Orthanc under LGPL
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4044
diff
changeset
|
18 * License along with this program. If not, see |
bf7b9edf6b81
re-licensing the OrthancFramework to LGPL, in order to license Stone of Orthanc under LGPL
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4044
diff
changeset
|
19 * <http://www.gnu.org/licenses/>. |
2598
34dc57f4a7d2
simplification of JobStepResult
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
20 **/ |
34dc57f4a7d2
simplification of JobStepResult
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
21 |
34dc57f4a7d2
simplification of JobStepResult
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
22 |
34dc57f4a7d2
simplification of JobStepResult
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
23 #include "../PrecompiledHeaders.h" |
34dc57f4a7d2
simplification of JobStepResult
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
24 #include "JobStepResult.h" |
34dc57f4a7d2
simplification of JobStepResult
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
25 |
34dc57f4a7d2
simplification of JobStepResult
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
26 #include "../OrthancException.h" |
34dc57f4a7d2
simplification of JobStepResult
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
27 |
34dc57f4a7d2
simplification of JobStepResult
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
28 namespace Orthanc |
34dc57f4a7d2
simplification of JobStepResult
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
29 { |
4300 | 30 JobStepResult::JobStepResult() : |
31 code_(JobStepCode_Failure), | |
32 timeout_(0), | |
33 error_(ErrorCode_InternalError) | |
34 { | |
35 } | |
36 | |
37 JobStepResult JobStepResult::Success() | |
38 { | |
39 return JobStepResult(JobStepCode_Success); | |
40 } | |
41 | |
42 JobStepResult JobStepResult::Continue() | |
43 { | |
44 return JobStepResult(JobStepCode_Continue); | |
45 } | |
46 | |
2598
34dc57f4a7d2
simplification of JobStepResult
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
47 JobStepResult JobStepResult::Retry(unsigned int timeout) |
34dc57f4a7d2
simplification of JobStepResult
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
48 { |
34dc57f4a7d2
simplification of JobStepResult
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
49 JobStepResult result(JobStepCode_Retry); |
34dc57f4a7d2
simplification of JobStepResult
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
50 result.timeout_ = timeout; |
34dc57f4a7d2
simplification of JobStepResult
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
51 return result; |
34dc57f4a7d2
simplification of JobStepResult
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
52 } |
34dc57f4a7d2
simplification of JobStepResult
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
53 |
34dc57f4a7d2
simplification of JobStepResult
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
54 |
3240
e44e0127e553
Fix issue #134 (/patient/modify gives 500, should really be 400)
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3060
diff
changeset
|
55 JobStepResult JobStepResult::Failure(const ErrorCode& error, |
e44e0127e553
Fix issue #134 (/patient/modify gives 500, should really be 400)
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3060
diff
changeset
|
56 const char* details) |
2598
34dc57f4a7d2
simplification of JobStepResult
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
57 { |
34dc57f4a7d2
simplification of JobStepResult
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
58 JobStepResult result(JobStepCode_Failure); |
34dc57f4a7d2
simplification of JobStepResult
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
59 result.error_ = error; |
3240
e44e0127e553
Fix issue #134 (/patient/modify gives 500, should really be 400)
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3060
diff
changeset
|
60 |
e44e0127e553
Fix issue #134 (/patient/modify gives 500, should really be 400)
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3060
diff
changeset
|
61 if (details != NULL) |
e44e0127e553
Fix issue #134 (/patient/modify gives 500, should really be 400)
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3060
diff
changeset
|
62 { |
e44e0127e553
Fix issue #134 (/patient/modify gives 500, should really be 400)
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3060
diff
changeset
|
63 result.failureDetails_ = details; |
e44e0127e553
Fix issue #134 (/patient/modify gives 500, should really be 400)
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3060
diff
changeset
|
64 } |
e44e0127e553
Fix issue #134 (/patient/modify gives 500, should really be 400)
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3060
diff
changeset
|
65 |
2598
34dc57f4a7d2
simplification of JobStepResult
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
66 return result; |
34dc57f4a7d2
simplification of JobStepResult
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
67 } |
34dc57f4a7d2
simplification of JobStepResult
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
68 |
34dc57f4a7d2
simplification of JobStepResult
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
69 |
3240
e44e0127e553
Fix issue #134 (/patient/modify gives 500, should really be 400)
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3060
diff
changeset
|
70 JobStepResult JobStepResult::Failure(const OrthancException& exception) |
e44e0127e553
Fix issue #134 (/patient/modify gives 500, should really be 400)
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3060
diff
changeset
|
71 { |
e44e0127e553
Fix issue #134 (/patient/modify gives 500, should really be 400)
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3060
diff
changeset
|
72 return Failure(exception.GetErrorCode(), |
e44e0127e553
Fix issue #134 (/patient/modify gives 500, should really be 400)
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3060
diff
changeset
|
73 exception.HasDetails() ? exception.GetDetails() : NULL); |
e44e0127e553
Fix issue #134 (/patient/modify gives 500, should really be 400)
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3060
diff
changeset
|
74 } |
4300 | 75 |
76 JobStepCode JobStepResult::GetCode() const | |
77 { | |
78 return code_; | |
79 } | |
3240
e44e0127e553
Fix issue #134 (/patient/modify gives 500, should really be 400)
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3060
diff
changeset
|
80 |
e44e0127e553
Fix issue #134 (/patient/modify gives 500, should really be 400)
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3060
diff
changeset
|
81 |
2598
34dc57f4a7d2
simplification of JobStepResult
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
82 unsigned int JobStepResult::GetRetryTimeout() const |
34dc57f4a7d2
simplification of JobStepResult
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
83 { |
34dc57f4a7d2
simplification of JobStepResult
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
84 if (code_ == JobStepCode_Retry) |
34dc57f4a7d2
simplification of JobStepResult
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
85 { |
34dc57f4a7d2
simplification of JobStepResult
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
86 return timeout_; |
34dc57f4a7d2
simplification of JobStepResult
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
87 } |
34dc57f4a7d2
simplification of JobStepResult
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
88 else |
34dc57f4a7d2
simplification of JobStepResult
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
89 { |
34dc57f4a7d2
simplification of JobStepResult
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
90 throw OrthancException(ErrorCode_BadSequenceOfCalls); |
34dc57f4a7d2
simplification of JobStepResult
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
91 } |
34dc57f4a7d2
simplification of JobStepResult
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
92 } |
34dc57f4a7d2
simplification of JobStepResult
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
93 |
34dc57f4a7d2
simplification of JobStepResult
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
94 |
34dc57f4a7d2
simplification of JobStepResult
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
95 ErrorCode JobStepResult::GetFailureCode() const |
34dc57f4a7d2
simplification of JobStepResult
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
96 { |
34dc57f4a7d2
simplification of JobStepResult
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
97 if (code_ == JobStepCode_Failure) |
34dc57f4a7d2
simplification of JobStepResult
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
98 { |
34dc57f4a7d2
simplification of JobStepResult
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
99 return error_; |
34dc57f4a7d2
simplification of JobStepResult
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
100 } |
34dc57f4a7d2
simplification of JobStepResult
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
101 else |
34dc57f4a7d2
simplification of JobStepResult
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
102 { |
34dc57f4a7d2
simplification of JobStepResult
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
103 throw OrthancException(ErrorCode_BadSequenceOfCalls); |
34dc57f4a7d2
simplification of JobStepResult
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
104 } |
34dc57f4a7d2
simplification of JobStepResult
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
105 } |
3240
e44e0127e553
Fix issue #134 (/patient/modify gives 500, should really be 400)
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3060
diff
changeset
|
106 |
e44e0127e553
Fix issue #134 (/patient/modify gives 500, should really be 400)
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3060
diff
changeset
|
107 |
e44e0127e553
Fix issue #134 (/patient/modify gives 500, should really be 400)
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3060
diff
changeset
|
108 const std::string& JobStepResult::GetFailureDetails() const |
e44e0127e553
Fix issue #134 (/patient/modify gives 500, should really be 400)
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3060
diff
changeset
|
109 { |
e44e0127e553
Fix issue #134 (/patient/modify gives 500, should really be 400)
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3060
diff
changeset
|
110 if (code_ == JobStepCode_Failure) |
e44e0127e553
Fix issue #134 (/patient/modify gives 500, should really be 400)
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3060
diff
changeset
|
111 { |
e44e0127e553
Fix issue #134 (/patient/modify gives 500, should really be 400)
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3060
diff
changeset
|
112 return failureDetails_; |
e44e0127e553
Fix issue #134 (/patient/modify gives 500, should really be 400)
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3060
diff
changeset
|
113 } |
e44e0127e553
Fix issue #134 (/patient/modify gives 500, should really be 400)
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3060
diff
changeset
|
114 else |
e44e0127e553
Fix issue #134 (/patient/modify gives 500, should really be 400)
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3060
diff
changeset
|
115 { |
e44e0127e553
Fix issue #134 (/patient/modify gives 500, should really be 400)
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3060
diff
changeset
|
116 throw OrthancException(ErrorCode_BadSequenceOfCalls); |
e44e0127e553
Fix issue #134 (/patient/modify gives 500, should really be 400)
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3060
diff
changeset
|
117 } |
e44e0127e553
Fix issue #134 (/patient/modify gives 500, should really be 400)
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3060
diff
changeset
|
118 } |
2598
34dc57f4a7d2
simplification of JobStepResult
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
119 } |