Mercurial > hg > orthanc
annotate OrthancFramework/Sources/JobsEngine/JobStepResult.cpp @ 5310:b5c502bcaf99
added a route to DELETE /jobs/../archive
author | Alain Mazy <am@osimis.io> |
---|---|
date | Mon, 12 Jun 2023 18:42:06 +0200 |
parents | 0ea402b4d901 |
children | 48b8dae6dc77 |
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 |
5185
0ea402b4d901
upgrade to year 2023
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4870
diff
changeset
|
5 * Copyright (C) 2017-2023 Osimis S.A., Belgium |
0ea402b4d901
upgrade to year 2023
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4870
diff
changeset
|
6 * Copyright (C) 2021-2023 Sebastien Jodogne, ICTEAM UCLouvain, Belgium |
2598
34dc57f4a7d2
simplification of JobStepResult
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
7 * |
34dc57f4a7d2
simplification of JobStepResult
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
8 * 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
|
9 * 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
|
10 * 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
|
11 * the License, or (at your option) any later version. |
2598
34dc57f4a7d2
simplification of JobStepResult
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
12 * |
34dc57f4a7d2
simplification of JobStepResult
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
13 * 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
|
14 * WITHOUT ANY WARRANTY; without even the implied warranty of |
34dc57f4a7d2
simplification of JobStepResult
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
15 * 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
|
16 * Lesser General Public License for more details. |
2598
34dc57f4a7d2
simplification of JobStepResult
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
17 * |
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
|
18 * 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
|
19 * 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
|
20 * <http://www.gnu.org/licenses/>. |
2598
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 |
34dc57f4a7d2
simplification of JobStepResult
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
24 #include "../PrecompiledHeaders.h" |
34dc57f4a7d2
simplification of JobStepResult
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
25 #include "JobStepResult.h" |
34dc57f4a7d2
simplification of JobStepResult
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
26 |
34dc57f4a7d2
simplification of JobStepResult
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
27 #include "../OrthancException.h" |
34dc57f4a7d2
simplification of JobStepResult
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
28 |
34dc57f4a7d2
simplification of JobStepResult
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
29 namespace Orthanc |
34dc57f4a7d2
simplification of JobStepResult
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
30 { |
4300 | 31 JobStepResult::JobStepResult() : |
32 code_(JobStepCode_Failure), | |
33 timeout_(0), | |
34 error_(ErrorCode_InternalError) | |
35 { | |
36 } | |
37 | |
38 JobStepResult JobStepResult::Success() | |
39 { | |
40 return JobStepResult(JobStepCode_Success); | |
41 } | |
42 | |
43 JobStepResult JobStepResult::Continue() | |
44 { | |
45 return JobStepResult(JobStepCode_Continue); | |
46 } | |
47 | |
2598
34dc57f4a7d2
simplification of JobStepResult
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
48 JobStepResult JobStepResult::Retry(unsigned int timeout) |
34dc57f4a7d2
simplification of JobStepResult
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
49 { |
34dc57f4a7d2
simplification of JobStepResult
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
50 JobStepResult result(JobStepCode_Retry); |
34dc57f4a7d2
simplification of JobStepResult
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
51 result.timeout_ = timeout; |
34dc57f4a7d2
simplification of JobStepResult
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
52 return result; |
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 |
34dc57f4a7d2
simplification of JobStepResult
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
55 |
3240
e44e0127e553
Fix issue #134 (/patient/modify gives 500, should really be 400)
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3060
diff
changeset
|
56 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
|
57 const char* details) |
2598
34dc57f4a7d2
simplification of JobStepResult
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
58 { |
34dc57f4a7d2
simplification of JobStepResult
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
59 JobStepResult result(JobStepCode_Failure); |
34dc57f4a7d2
simplification of JobStepResult
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
60 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
|
61 |
e44e0127e553
Fix issue #134 (/patient/modify gives 500, should really be 400)
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3060
diff
changeset
|
62 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
|
63 { |
e44e0127e553
Fix issue #134 (/patient/modify gives 500, should really be 400)
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3060
diff
changeset
|
64 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
|
65 } |
e44e0127e553
Fix issue #134 (/patient/modify gives 500, should really be 400)
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3060
diff
changeset
|
66 |
2598
34dc57f4a7d2
simplification of JobStepResult
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
67 return result; |
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 |
34dc57f4a7d2
simplification of JobStepResult
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
70 |
3240
e44e0127e553
Fix issue #134 (/patient/modify gives 500, should really be 400)
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3060
diff
changeset
|
71 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
|
72 { |
e44e0127e553
Fix issue #134 (/patient/modify gives 500, should really be 400)
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3060
diff
changeset
|
73 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
|
74 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
|
75 } |
4300 | 76 |
77 JobStepCode JobStepResult::GetCode() const | |
78 { | |
79 return code_; | |
80 } | |
3240
e44e0127e553
Fix issue #134 (/patient/modify gives 500, should really be 400)
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3060
diff
changeset
|
81 |
e44e0127e553
Fix issue #134 (/patient/modify gives 500, should really be 400)
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3060
diff
changeset
|
82 |
2598
34dc57f4a7d2
simplification of JobStepResult
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
83 unsigned int JobStepResult::GetRetryTimeout() const |
34dc57f4a7d2
simplification of JobStepResult
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
84 { |
34dc57f4a7d2
simplification of JobStepResult
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
85 if (code_ == JobStepCode_Retry) |
34dc57f4a7d2
simplification of JobStepResult
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
86 { |
34dc57f4a7d2
simplification of JobStepResult
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
87 return timeout_; |
34dc57f4a7d2
simplification of JobStepResult
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
88 } |
34dc57f4a7d2
simplification of JobStepResult
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
89 else |
34dc57f4a7d2
simplification of JobStepResult
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
90 { |
34dc57f4a7d2
simplification of JobStepResult
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
91 throw OrthancException(ErrorCode_BadSequenceOfCalls); |
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 |
34dc57f4a7d2
simplification of JobStepResult
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
96 ErrorCode JobStepResult::GetFailureCode() const |
34dc57f4a7d2
simplification of JobStepResult
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
97 { |
34dc57f4a7d2
simplification of JobStepResult
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
98 if (code_ == JobStepCode_Failure) |
34dc57f4a7d2
simplification of JobStepResult
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
99 { |
34dc57f4a7d2
simplification of JobStepResult
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
100 return error_; |
34dc57f4a7d2
simplification of JobStepResult
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
101 } |
34dc57f4a7d2
simplification of JobStepResult
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
102 else |
34dc57f4a7d2
simplification of JobStepResult
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
103 { |
34dc57f4a7d2
simplification of JobStepResult
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
104 throw OrthancException(ErrorCode_BadSequenceOfCalls); |
34dc57f4a7d2
simplification of JobStepResult
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
105 } |
34dc57f4a7d2
simplification of JobStepResult
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
106 } |
3240
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 |
e44e0127e553
Fix issue #134 (/patient/modify gives 500, should really be 400)
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3060
diff
changeset
|
109 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
|
110 { |
e44e0127e553
Fix issue #134 (/patient/modify gives 500, should really be 400)
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3060
diff
changeset
|
111 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
|
112 { |
e44e0127e553
Fix issue #134 (/patient/modify gives 500, should really be 400)
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3060
diff
changeset
|
113 return failureDetails_; |
e44e0127e553
Fix issue #134 (/patient/modify gives 500, should really be 400)
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3060
diff
changeset
|
114 } |
e44e0127e553
Fix issue #134 (/patient/modify gives 500, should really be 400)
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3060
diff
changeset
|
115 else |
e44e0127e553
Fix issue #134 (/patient/modify gives 500, should really be 400)
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3060
diff
changeset
|
116 { |
e44e0127e553
Fix issue #134 (/patient/modify gives 500, should really be 400)
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3060
diff
changeset
|
117 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
|
118 } |
e44e0127e553
Fix issue #134 (/patient/modify gives 500, should really be 400)
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3060
diff
changeset
|
119 } |
2598
34dc57f4a7d2
simplification of JobStepResult
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
120 } |