Mercurial > hg > orthanc-object-storage
annotate Common/MoveStorageJob.cpp @ 138:a360eb28089d
third party downloads from uclouvain servers
author | Sebastien Jodogne <s.jodogne@gmail.com> |
---|---|
date | Wed, 20 Dec 2023 22:29:23 +0100 |
parents | 407bd022b0cf |
children | 3c7e0374f28e |
rev | line source |
---|---|
83
431ab61b5760
/move-storage when HybridMode is enabled
Alain Mazy <am@osimis.io>
parents:
diff
changeset
|
1 /** |
431ab61b5760
/move-storage when HybridMode is enabled
Alain Mazy <am@osimis.io>
parents:
diff
changeset
|
2 * Cloud storage plugins for Orthanc |
431ab61b5760
/move-storage when HybridMode is enabled
Alain Mazy <am@osimis.io>
parents:
diff
changeset
|
3 * Copyright (C) 2020-2021 Osimis S.A., Belgium |
431ab61b5760
/move-storage when HybridMode is enabled
Alain Mazy <am@osimis.io>
parents:
diff
changeset
|
4 * |
431ab61b5760
/move-storage when HybridMode is enabled
Alain Mazy <am@osimis.io>
parents:
diff
changeset
|
5 * This program is free software: you can redistribute it and/or |
431ab61b5760
/move-storage when HybridMode is enabled
Alain Mazy <am@osimis.io>
parents:
diff
changeset
|
6 * modify it under the terms of the GNU Affero General Public License |
431ab61b5760
/move-storage when HybridMode is enabled
Alain Mazy <am@osimis.io>
parents:
diff
changeset
|
7 * as published by the Free Software Foundation, either version 3 of |
431ab61b5760
/move-storage when HybridMode is enabled
Alain Mazy <am@osimis.io>
parents:
diff
changeset
|
8 * the License, or (at your option) any later version. |
431ab61b5760
/move-storage when HybridMode is enabled
Alain Mazy <am@osimis.io>
parents:
diff
changeset
|
9 * |
431ab61b5760
/move-storage when HybridMode is enabled
Alain Mazy <am@osimis.io>
parents:
diff
changeset
|
10 * This program is distributed in the hope that it will be useful, but |
431ab61b5760
/move-storage when HybridMode is enabled
Alain Mazy <am@osimis.io>
parents:
diff
changeset
|
11 * WITHOUT ANY WARRANTY; without even the implied warranty of |
431ab61b5760
/move-storage when HybridMode is enabled
Alain Mazy <am@osimis.io>
parents:
diff
changeset
|
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
431ab61b5760
/move-storage when HybridMode is enabled
Alain Mazy <am@osimis.io>
parents:
diff
changeset
|
13 * Affero General Public License for more details. |
431ab61b5760
/move-storage when HybridMode is enabled
Alain Mazy <am@osimis.io>
parents:
diff
changeset
|
14 * |
431ab61b5760
/move-storage when HybridMode is enabled
Alain Mazy <am@osimis.io>
parents:
diff
changeset
|
15 * You should have received a copy of the GNU Affero General Public License |
431ab61b5760
/move-storage when HybridMode is enabled
Alain Mazy <am@osimis.io>
parents:
diff
changeset
|
16 * along with this program. If not, see <http://www.gnu.org/licenses/>. |
431ab61b5760
/move-storage when HybridMode is enabled
Alain Mazy <am@osimis.io>
parents:
diff
changeset
|
17 **/ |
431ab61b5760
/move-storage when HybridMode is enabled
Alain Mazy <am@osimis.io>
parents:
diff
changeset
|
18 |
431ab61b5760
/move-storage when HybridMode is enabled
Alain Mazy <am@osimis.io>
parents:
diff
changeset
|
19 #include "MoveStorageJob.h" |
431ab61b5760
/move-storage when HybridMode is enabled
Alain Mazy <am@osimis.io>
parents:
diff
changeset
|
20 #include "Logging.h" |
84 | 21 #include "StoragePlugin.h" |
83
431ab61b5760
/move-storage when HybridMode is enabled
Alain Mazy <am@osimis.io>
parents:
diff
changeset
|
22 |
431ab61b5760
/move-storage when HybridMode is enabled
Alain Mazy <am@osimis.io>
parents:
diff
changeset
|
23 |
431ab61b5760
/move-storage when HybridMode is enabled
Alain Mazy <am@osimis.io>
parents:
diff
changeset
|
24 MoveStorageJob::MoveStorageJob(const std::string& targetStorage, |
431ab61b5760
/move-storage when HybridMode is enabled
Alain Mazy <am@osimis.io>
parents:
diff
changeset
|
25 const std::vector<std::string>& instances, |
431ab61b5760
/move-storage when HybridMode is enabled
Alain Mazy <am@osimis.io>
parents:
diff
changeset
|
26 const Json::Value& resourceForJobContent, |
431ab61b5760
/move-storage when HybridMode is enabled
Alain Mazy <am@osimis.io>
parents:
diff
changeset
|
27 bool cryptoEnabled) |
84 | 28 : OrthancPlugins::OrthancJob(JOB_TYPE_MOVE_STORAGE), |
83
431ab61b5760
/move-storage when HybridMode is enabled
Alain Mazy <am@osimis.io>
parents:
diff
changeset
|
29 targetStorage_(targetStorage), |
431ab61b5760
/move-storage when HybridMode is enabled
Alain Mazy <am@osimis.io>
parents:
diff
changeset
|
30 instances_(instances), |
431ab61b5760
/move-storage when HybridMode is enabled
Alain Mazy <am@osimis.io>
parents:
diff
changeset
|
31 processedInstancesCount_(0), |
431ab61b5760
/move-storage when HybridMode is enabled
Alain Mazy <am@osimis.io>
parents:
diff
changeset
|
32 resourceForJobContent_(resourceForJobContent), |
431ab61b5760
/move-storage when HybridMode is enabled
Alain Mazy <am@osimis.io>
parents:
diff
changeset
|
33 fileSystemStorage_(NULL), |
431ab61b5760
/move-storage when HybridMode is enabled
Alain Mazy <am@osimis.io>
parents:
diff
changeset
|
34 objectStorage_(NULL), |
431ab61b5760
/move-storage when HybridMode is enabled
Alain Mazy <am@osimis.io>
parents:
diff
changeset
|
35 cryptoEnabled_(cryptoEnabled) |
431ab61b5760
/move-storage when HybridMode is enabled
Alain Mazy <am@osimis.io>
parents:
diff
changeset
|
36 { |
84 | 37 UpdateContent(resourceForJobContent); |
38 | |
39 Json::Value serialized; | |
40 Serialize(serialized); | |
41 UpdateSerialized(serialized); | |
42 } | |
43 | |
44 void MoveStorageJob::Serialize(Json::Value& target) const | |
45 { | |
46 target[KEY_CONTENT] = resourceForJobContent_; | |
47 target[KEY_TARGET_STORAGE] = targetStorage_; | |
48 target[KEY_INSTANCES] = Json::arrayValue; | |
49 | |
50 for (size_t i = 0; i < instances_.size(); ++i) | |
51 { | |
52 target[KEY_INSTANCES].append(instances_[i]); | |
53 } | |
54 | |
83
431ab61b5760
/move-storage when HybridMode is enabled
Alain Mazy <am@osimis.io>
parents:
diff
changeset
|
55 } |
431ab61b5760
/move-storage when HybridMode is enabled
Alain Mazy <am@osimis.io>
parents:
diff
changeset
|
56 |
431ab61b5760
/move-storage when HybridMode is enabled
Alain Mazy <am@osimis.io>
parents:
diff
changeset
|
57 void MoveStorageJob::SetStorages(IStorage* fileSystemStorage, IStorage* objectStorage) |
431ab61b5760
/move-storage when HybridMode is enabled
Alain Mazy <am@osimis.io>
parents:
diff
changeset
|
58 { |
431ab61b5760
/move-storage when HybridMode is enabled
Alain Mazy <am@osimis.io>
parents:
diff
changeset
|
59 fileSystemStorage_ = fileSystemStorage; |
431ab61b5760
/move-storage when HybridMode is enabled
Alain Mazy <am@osimis.io>
parents:
diff
changeset
|
60 objectStorage_ = objectStorage; |
431ab61b5760
/move-storage when HybridMode is enabled
Alain Mazy <am@osimis.io>
parents:
diff
changeset
|
61 } |
431ab61b5760
/move-storage when HybridMode is enabled
Alain Mazy <am@osimis.io>
parents:
diff
changeset
|
62 |
431ab61b5760
/move-storage when HybridMode is enabled
Alain Mazy <am@osimis.io>
parents:
diff
changeset
|
63 static bool MoveAttachment(const std::string& uuid, int type, IStorage* sourceStorage, IStorage* targetStorage, bool cryptoEnabled) |
431ab61b5760
/move-storage when HybridMode is enabled
Alain Mazy <am@osimis.io>
parents:
diff
changeset
|
64 { |
431ab61b5760
/move-storage when HybridMode is enabled
Alain Mazy <am@osimis.io>
parents:
diff
changeset
|
65 std::vector<char> buffer; |
431ab61b5760
/move-storage when HybridMode is enabled
Alain Mazy <am@osimis.io>
parents:
diff
changeset
|
66 |
431ab61b5760
/move-storage when HybridMode is enabled
Alain Mazy <am@osimis.io>
parents:
diff
changeset
|
67 // read from source storage |
431ab61b5760
/move-storage when HybridMode is enabled
Alain Mazy <am@osimis.io>
parents:
diff
changeset
|
68 try |
431ab61b5760
/move-storage when HybridMode is enabled
Alain Mazy <am@osimis.io>
parents:
diff
changeset
|
69 { |
111
407bd022b0cf
in /move-storage: now detecting if file should be moved or not
Alain Mazy <am@osimis.io>
parents:
84
diff
changeset
|
70 if (sourceStorage->HasFileExists() && !sourceStorage->FileExists(uuid, static_cast<OrthancPluginContentType>(type), cryptoEnabled)) |
407bd022b0cf
in /move-storage: now detecting if file should be moved or not
Alain Mazy <am@osimis.io>
parents:
84
diff
changeset
|
71 { |
407bd022b0cf
in /move-storage: now detecting if file should be moved or not
Alain Mazy <am@osimis.io>
parents:
84
diff
changeset
|
72 OrthancPlugins::LogInfo("Move attachment: " + sourceStorage->GetNameForLogs() + " " + std::string(uuid) + " of type " + boost::lexical_cast<std::string>(type) + ", skipping, file is not on the source anymore"); |
407bd022b0cf
in /move-storage: now detecting if file should be moved or not
Alain Mazy <am@osimis.io>
parents:
84
diff
changeset
|
73 return true; |
407bd022b0cf
in /move-storage: now detecting if file should be moved or not
Alain Mazy <am@osimis.io>
parents:
84
diff
changeset
|
74 } |
407bd022b0cf
in /move-storage: now detecting if file should be moved or not
Alain Mazy <am@osimis.io>
parents:
84
diff
changeset
|
75 else if (targetStorage->HasFileExists() && targetStorage->FileExists(uuid, static_cast<OrthancPluginContentType>(type), cryptoEnabled)) |
407bd022b0cf
in /move-storage: now detecting if file should be moved or not
Alain Mazy <am@osimis.io>
parents:
84
diff
changeset
|
76 { |
407bd022b0cf
in /move-storage: now detecting if file should be moved or not
Alain Mazy <am@osimis.io>
parents:
84
diff
changeset
|
77 OrthancPlugins::LogInfo("Move attachment: " + targetStorage->GetNameForLogs() + " " + std::string(uuid) + " of type " + boost::lexical_cast<std::string>(type) + ", skipping, file already on the target"); |
407bd022b0cf
in /move-storage: now detecting if file should be moved or not
Alain Mazy <am@osimis.io>
parents:
84
diff
changeset
|
78 return true; |
407bd022b0cf
in /move-storage: now detecting if file should be moved or not
Alain Mazy <am@osimis.io>
parents:
84
diff
changeset
|
79 } |
407bd022b0cf
in /move-storage: now detecting if file should be moved or not
Alain Mazy <am@osimis.io>
parents:
84
diff
changeset
|
80 else |
407bd022b0cf
in /move-storage: now detecting if file should be moved or not
Alain Mazy <am@osimis.io>
parents:
84
diff
changeset
|
81 { |
407bd022b0cf
in /move-storage: now detecting if file should be moved or not
Alain Mazy <am@osimis.io>
parents:
84
diff
changeset
|
82 OrthancPlugins::LogInfo("Move attachment: " + sourceStorage->GetNameForLogs() + ": reading attachment " + std::string(uuid) + " of type " + boost::lexical_cast<std::string>(type)); |
407bd022b0cf
in /move-storage: now detecting if file should be moved or not
Alain Mazy <am@osimis.io>
parents:
84
diff
changeset
|
83 } |
407bd022b0cf
in /move-storage: now detecting if file should be moved or not
Alain Mazy <am@osimis.io>
parents:
84
diff
changeset
|
84 |
83
431ab61b5760
/move-storage when HybridMode is enabled
Alain Mazy <am@osimis.io>
parents:
diff
changeset
|
85 std::unique_ptr<IStorage::IReader> reader(sourceStorage->GetReaderForObject(uuid.c_str(), static_cast<OrthancPluginContentType>(type), cryptoEnabled)); |
431ab61b5760
/move-storage when HybridMode is enabled
Alain Mazy <am@osimis.io>
parents:
diff
changeset
|
86 |
431ab61b5760
/move-storage when HybridMode is enabled
Alain Mazy <am@osimis.io>
parents:
diff
changeset
|
87 size_t fileSize = reader->GetSize(); |
431ab61b5760
/move-storage when HybridMode is enabled
Alain Mazy <am@osimis.io>
parents:
diff
changeset
|
88 buffer.resize(fileSize); |
431ab61b5760
/move-storage when HybridMode is enabled
Alain Mazy <am@osimis.io>
parents:
diff
changeset
|
89 |
431ab61b5760
/move-storage when HybridMode is enabled
Alain Mazy <am@osimis.io>
parents:
diff
changeset
|
90 reader->ReadWhole(buffer.data(), fileSize); |
431ab61b5760
/move-storage when HybridMode is enabled
Alain Mazy <am@osimis.io>
parents:
diff
changeset
|
91 } |
431ab61b5760
/move-storage when HybridMode is enabled
Alain Mazy <am@osimis.io>
parents:
diff
changeset
|
92 catch (StoragePluginException& ex) |
431ab61b5760
/move-storage when HybridMode is enabled
Alain Mazy <am@osimis.io>
parents:
diff
changeset
|
93 { |
431ab61b5760
/move-storage when HybridMode is enabled
Alain Mazy <am@osimis.io>
parents:
diff
changeset
|
94 OrthancPlugins::LogInfo("Move attachment: " + sourceStorage->GetNameForLogs() + ": error while reading attachment " + std::string(uuid) + " of type " + boost::lexical_cast<std::string>(type) + ", this likely means that the file is already on the right storage"); |
431ab61b5760
/move-storage when HybridMode is enabled
Alain Mazy <am@osimis.io>
parents:
diff
changeset
|
95 return true; |
431ab61b5760
/move-storage when HybridMode is enabled
Alain Mazy <am@osimis.io>
parents:
diff
changeset
|
96 } |
431ab61b5760
/move-storage when HybridMode is enabled
Alain Mazy <am@osimis.io>
parents:
diff
changeset
|
97 |
431ab61b5760
/move-storage when HybridMode is enabled
Alain Mazy <am@osimis.io>
parents:
diff
changeset
|
98 // write to target storage |
431ab61b5760
/move-storage when HybridMode is enabled
Alain Mazy <am@osimis.io>
parents:
diff
changeset
|
99 if (buffer.size() > 0) |
431ab61b5760
/move-storage when HybridMode is enabled
Alain Mazy <am@osimis.io>
parents:
diff
changeset
|
100 { |
431ab61b5760
/move-storage when HybridMode is enabled
Alain Mazy <am@osimis.io>
parents:
diff
changeset
|
101 try |
431ab61b5760
/move-storage when HybridMode is enabled
Alain Mazy <am@osimis.io>
parents:
diff
changeset
|
102 { |
431ab61b5760
/move-storage when HybridMode is enabled
Alain Mazy <am@osimis.io>
parents:
diff
changeset
|
103 std::unique_ptr<IStorage::IWriter> writer(targetStorage->GetWriterForObject(uuid.c_str(), static_cast<OrthancPluginContentType>(type), cryptoEnabled)); |
431ab61b5760
/move-storage when HybridMode is enabled
Alain Mazy <am@osimis.io>
parents:
diff
changeset
|
104 |
431ab61b5760
/move-storage when HybridMode is enabled
Alain Mazy <am@osimis.io>
parents:
diff
changeset
|
105 writer->Write(buffer.data(), buffer.size()); |
431ab61b5760
/move-storage when HybridMode is enabled
Alain Mazy <am@osimis.io>
parents:
diff
changeset
|
106 } |
431ab61b5760
/move-storage when HybridMode is enabled
Alain Mazy <am@osimis.io>
parents:
diff
changeset
|
107 catch (StoragePluginException& ex) |
431ab61b5760
/move-storage when HybridMode is enabled
Alain Mazy <am@osimis.io>
parents:
diff
changeset
|
108 { |
431ab61b5760
/move-storage when HybridMode is enabled
Alain Mazy <am@osimis.io>
parents:
diff
changeset
|
109 OrthancPlugins::LogError("Move attachment: " + targetStorage->GetNameForLogs() + ": error while writing attachment " + std::string(uuid) + " of type " + boost::lexical_cast<std::string>(type) + ": " + ex.what()); |
431ab61b5760
/move-storage when HybridMode is enabled
Alain Mazy <am@osimis.io>
parents:
diff
changeset
|
110 return false; |
431ab61b5760
/move-storage when HybridMode is enabled
Alain Mazy <am@osimis.io>
parents:
diff
changeset
|
111 } |
431ab61b5760
/move-storage when HybridMode is enabled
Alain Mazy <am@osimis.io>
parents:
diff
changeset
|
112 } |
431ab61b5760
/move-storage when HybridMode is enabled
Alain Mazy <am@osimis.io>
parents:
diff
changeset
|
113 |
111
407bd022b0cf
in /move-storage: now detecting if file should be moved or not
Alain Mazy <am@osimis.io>
parents:
84
diff
changeset
|
114 // everything went well so far, we can delete from source storage |
83
431ab61b5760
/move-storage when HybridMode is enabled
Alain Mazy <am@osimis.io>
parents:
diff
changeset
|
115 if (buffer.size() > 0) |
431ab61b5760
/move-storage when HybridMode is enabled
Alain Mazy <am@osimis.io>
parents:
diff
changeset
|
116 { |
431ab61b5760
/move-storage when HybridMode is enabled
Alain Mazy <am@osimis.io>
parents:
diff
changeset
|
117 try |
431ab61b5760
/move-storage when HybridMode is enabled
Alain Mazy <am@osimis.io>
parents:
diff
changeset
|
118 { |
431ab61b5760
/move-storage when HybridMode is enabled
Alain Mazy <am@osimis.io>
parents:
diff
changeset
|
119 sourceStorage->DeleteObject(uuid.c_str(), static_cast<OrthancPluginContentType>(type), cryptoEnabled); |
431ab61b5760
/move-storage when HybridMode is enabled
Alain Mazy <am@osimis.io>
parents:
diff
changeset
|
120 } |
431ab61b5760
/move-storage when HybridMode is enabled
Alain Mazy <am@osimis.io>
parents:
diff
changeset
|
121 catch (StoragePluginException& ex) |
431ab61b5760
/move-storage when HybridMode is enabled
Alain Mazy <am@osimis.io>
parents:
diff
changeset
|
122 { |
431ab61b5760
/move-storage when HybridMode is enabled
Alain Mazy <am@osimis.io>
parents:
diff
changeset
|
123 OrthancPlugins::LogError("Move attachment: " + sourceStorage->GetNameForLogs() + ": error while deleting attachment " + std::string(uuid) + " of type " + boost::lexical_cast<std::string>(type) + ": " + ex.what()); |
431ab61b5760
/move-storage when HybridMode is enabled
Alain Mazy <am@osimis.io>
parents:
diff
changeset
|
124 return false; |
431ab61b5760
/move-storage when HybridMode is enabled
Alain Mazy <am@osimis.io>
parents:
diff
changeset
|
125 } |
431ab61b5760
/move-storage when HybridMode is enabled
Alain Mazy <am@osimis.io>
parents:
diff
changeset
|
126 } |
431ab61b5760
/move-storage when HybridMode is enabled
Alain Mazy <am@osimis.io>
parents:
diff
changeset
|
127 return true; |
431ab61b5760
/move-storage when HybridMode is enabled
Alain Mazy <am@osimis.io>
parents:
diff
changeset
|
128 } |
431ab61b5760
/move-storage when HybridMode is enabled
Alain Mazy <am@osimis.io>
parents:
diff
changeset
|
129 |
431ab61b5760
/move-storage when HybridMode is enabled
Alain Mazy <am@osimis.io>
parents:
diff
changeset
|
130 static bool MoveInstance(const std::string& instanceId, IStorage* sourceStorage, IStorage* targetStorage, bool cryptoEnabled) |
431ab61b5760
/move-storage when HybridMode is enabled
Alain Mazy <am@osimis.io>
parents:
diff
changeset
|
131 { |
431ab61b5760
/move-storage when HybridMode is enabled
Alain Mazy <am@osimis.io>
parents:
diff
changeset
|
132 LOG(INFO) << "Moving instance from " << sourceStorage->GetNameForLogs() << " to " << targetStorage->GetNameForLogs(); |
431ab61b5760
/move-storage when HybridMode is enabled
Alain Mazy <am@osimis.io>
parents:
diff
changeset
|
133 |
431ab61b5760
/move-storage when HybridMode is enabled
Alain Mazy <am@osimis.io>
parents:
diff
changeset
|
134 Json::Value attachmentsList; |
431ab61b5760
/move-storage when HybridMode is enabled
Alain Mazy <am@osimis.io>
parents:
diff
changeset
|
135 OrthancPlugins::RestApiGet(attachmentsList, std::string("/instances/") + instanceId + "/attachments?full", false); |
431ab61b5760
/move-storage when HybridMode is enabled
Alain Mazy <am@osimis.io>
parents:
diff
changeset
|
136 |
431ab61b5760
/move-storage when HybridMode is enabled
Alain Mazy <am@osimis.io>
parents:
diff
changeset
|
137 Json::Value::Members attachmentsMembers = attachmentsList.getMemberNames(); |
431ab61b5760
/move-storage when HybridMode is enabled
Alain Mazy <am@osimis.io>
parents:
diff
changeset
|
138 bool success = true; |
431ab61b5760
/move-storage when HybridMode is enabled
Alain Mazy <am@osimis.io>
parents:
diff
changeset
|
139 |
431ab61b5760
/move-storage when HybridMode is enabled
Alain Mazy <am@osimis.io>
parents:
diff
changeset
|
140 for (size_t i = 0; i < attachmentsMembers.size(); i++) |
431ab61b5760
/move-storage when HybridMode is enabled
Alain Mazy <am@osimis.io>
parents:
diff
changeset
|
141 { |
431ab61b5760
/move-storage when HybridMode is enabled
Alain Mazy <am@osimis.io>
parents:
diff
changeset
|
142 int attachmentId = attachmentsList[attachmentsMembers[i]].asInt(); |
431ab61b5760
/move-storage when HybridMode is enabled
Alain Mazy <am@osimis.io>
parents:
diff
changeset
|
143 |
431ab61b5760
/move-storage when HybridMode is enabled
Alain Mazy <am@osimis.io>
parents:
diff
changeset
|
144 Json::Value attachmentInfo; |
431ab61b5760
/move-storage when HybridMode is enabled
Alain Mazy <am@osimis.io>
parents:
diff
changeset
|
145 OrthancPlugins::RestApiGet(attachmentInfo, std::string("/instances/") + instanceId + "/attachments/" + boost::lexical_cast<std::string>(attachmentId) + "/info", false); |
431ab61b5760
/move-storage when HybridMode is enabled
Alain Mazy <am@osimis.io>
parents:
diff
changeset
|
146 |
431ab61b5760
/move-storage when HybridMode is enabled
Alain Mazy <am@osimis.io>
parents:
diff
changeset
|
147 std::string attachmentUuid = attachmentInfo["Uuid"].asString(); |
431ab61b5760
/move-storage when HybridMode is enabled
Alain Mazy <am@osimis.io>
parents:
diff
changeset
|
148 |
431ab61b5760
/move-storage when HybridMode is enabled
Alain Mazy <am@osimis.io>
parents:
diff
changeset
|
149 // now we have the uuid and type. We actually don't know where the file is but we'll try to move it anyway to the requested target |
431ab61b5760
/move-storage when HybridMode is enabled
Alain Mazy <am@osimis.io>
parents:
diff
changeset
|
150 success &= MoveAttachment(attachmentUuid, attachmentId, sourceStorage, targetStorage, cryptoEnabled); |
431ab61b5760
/move-storage when HybridMode is enabled
Alain Mazy <am@osimis.io>
parents:
diff
changeset
|
151 } |
431ab61b5760
/move-storage when HybridMode is enabled
Alain Mazy <am@osimis.io>
parents:
diff
changeset
|
152 |
431ab61b5760
/move-storage when HybridMode is enabled
Alain Mazy <am@osimis.io>
parents:
diff
changeset
|
153 return success; |
431ab61b5760
/move-storage when HybridMode is enabled
Alain Mazy <am@osimis.io>
parents:
diff
changeset
|
154 } |
431ab61b5760
/move-storage when HybridMode is enabled
Alain Mazy <am@osimis.io>
parents:
diff
changeset
|
155 |
431ab61b5760
/move-storage when HybridMode is enabled
Alain Mazy <am@osimis.io>
parents:
diff
changeset
|
156 OrthancPluginJobStepStatus MoveStorageJob::Step() |
431ab61b5760
/move-storage when HybridMode is enabled
Alain Mazy <am@osimis.io>
parents:
diff
changeset
|
157 { |
431ab61b5760
/move-storage when HybridMode is enabled
Alain Mazy <am@osimis.io>
parents:
diff
changeset
|
158 if (processedInstancesCount_ < instances_.size()) |
431ab61b5760
/move-storage when HybridMode is enabled
Alain Mazy <am@osimis.io>
parents:
diff
changeset
|
159 { |
84 | 160 IStorage* sourceStorage = (targetStorage_ == STORAGE_TYPE_FILE_SYSTEM ? objectStorage_ : fileSystemStorage_); |
161 IStorage* targetStorage = (targetStorage_ == STORAGE_TYPE_FILE_SYSTEM ? fileSystemStorage_ : objectStorage_); | |
83
431ab61b5760
/move-storage when HybridMode is enabled
Alain Mazy <am@osimis.io>
parents:
diff
changeset
|
162 |
431ab61b5760
/move-storage when HybridMode is enabled
Alain Mazy <am@osimis.io>
parents:
diff
changeset
|
163 if (MoveInstance(instances_[processedInstancesCount_], sourceStorage, targetStorage, cryptoEnabled_)) |
431ab61b5760
/move-storage when HybridMode is enabled
Alain Mazy <am@osimis.io>
parents:
diff
changeset
|
164 { |
431ab61b5760
/move-storage when HybridMode is enabled
Alain Mazy <am@osimis.io>
parents:
diff
changeset
|
165 processedInstancesCount_++; |
84 | 166 UpdateProgress((float)processedInstancesCount_/(float)instances_.size()); |
167 | |
83
431ab61b5760
/move-storage when HybridMode is enabled
Alain Mazy <am@osimis.io>
parents:
diff
changeset
|
168 return OrthancPluginJobStepStatus_Continue; |
431ab61b5760
/move-storage when HybridMode is enabled
Alain Mazy <am@osimis.io>
parents:
diff
changeset
|
169 } |
431ab61b5760
/move-storage when HybridMode is enabled
Alain Mazy <am@osimis.io>
parents:
diff
changeset
|
170 else |
431ab61b5760
/move-storage when HybridMode is enabled
Alain Mazy <am@osimis.io>
parents:
diff
changeset
|
171 { |
431ab61b5760
/move-storage when HybridMode is enabled
Alain Mazy <am@osimis.io>
parents:
diff
changeset
|
172 return OrthancPluginJobStepStatus_Failure; |
431ab61b5760
/move-storage when HybridMode is enabled
Alain Mazy <am@osimis.io>
parents:
diff
changeset
|
173 } |
431ab61b5760
/move-storage when HybridMode is enabled
Alain Mazy <am@osimis.io>
parents:
diff
changeset
|
174 } |
431ab61b5760
/move-storage when HybridMode is enabled
Alain Mazy <am@osimis.io>
parents:
diff
changeset
|
175 |
431ab61b5760
/move-storage when HybridMode is enabled
Alain Mazy <am@osimis.io>
parents:
diff
changeset
|
176 return OrthancPluginJobStepStatus_Success; |
431ab61b5760
/move-storage when HybridMode is enabled
Alain Mazy <am@osimis.io>
parents:
diff
changeset
|
177 } |
431ab61b5760
/move-storage when HybridMode is enabled
Alain Mazy <am@osimis.io>
parents:
diff
changeset
|
178 |
431ab61b5760
/move-storage when HybridMode is enabled
Alain Mazy <am@osimis.io>
parents:
diff
changeset
|
179 void MoveStorageJob::Stop(OrthancPluginJobStopReason reason) |
431ab61b5760
/move-storage when HybridMode is enabled
Alain Mazy <am@osimis.io>
parents:
diff
changeset
|
180 { |
431ab61b5760
/move-storage when HybridMode is enabled
Alain Mazy <am@osimis.io>
parents:
diff
changeset
|
181 } |
431ab61b5760
/move-storage when HybridMode is enabled
Alain Mazy <am@osimis.io>
parents:
diff
changeset
|
182 |
431ab61b5760
/move-storage when HybridMode is enabled
Alain Mazy <am@osimis.io>
parents:
diff
changeset
|
183 void MoveStorageJob::Reset() |
431ab61b5760
/move-storage when HybridMode is enabled
Alain Mazy <am@osimis.io>
parents:
diff
changeset
|
184 { |
431ab61b5760
/move-storage when HybridMode is enabled
Alain Mazy <am@osimis.io>
parents:
diff
changeset
|
185 processedInstancesCount_ = 0; |
431ab61b5760
/move-storage when HybridMode is enabled
Alain Mazy <am@osimis.io>
parents:
diff
changeset
|
186 } |