annotate OrthancServer/Plugins/Samples/AdvancedStorage/Plugin.cpp @ 5834:79a497908b04 attach-custom-data tip

merged find-refactoring -> attach-custom-data
author Alain Mazy <am@orthanc.team>
date Wed, 09 Oct 2024 11:06:20 +0200
parents 79ac3924eff8
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
5080
d7274e43ea7c allow plugins to store a customData in the Attachments table to e.g. store custom paths without requiring an external DB
Alain Mazy <am@osimis.io>
parents:
diff changeset
1 /**
d7274e43ea7c allow plugins to store a customData in the Attachments table to e.g. store custom paths without requiring an external DB
Alain Mazy <am@osimis.io>
parents:
diff changeset
2 * Orthanc - A Lightweight, RESTful DICOM Store
d7274e43ea7c allow plugins to store a customData in the Attachments table to e.g. store custom paths without requiring an external DB
Alain Mazy <am@osimis.io>
parents:
diff changeset
3 * Copyright (C) 2012-2016 Sebastien Jodogne, Medical Physics
d7274e43ea7c allow plugins to store a customData in the Attachments table to e.g. store custom paths without requiring an external DB
Alain Mazy <am@osimis.io>
parents:
diff changeset
4 * Department, University Hospital of Liege, Belgium
d7274e43ea7c allow plugins to store a customData in the Attachments table to e.g. store custom paths without requiring an external DB
Alain Mazy <am@osimis.io>
parents:
diff changeset
5 * Copyright (C) 2017-2022 Osimis S.A., Belgium
d7274e43ea7c allow plugins to store a customData in the Attachments table to e.g. store custom paths without requiring an external DB
Alain Mazy <am@osimis.io>
parents:
diff changeset
6 * Copyright (C) 2021-2022 Sebastien Jodogne, ICTEAM UCLouvain, Belgium
d7274e43ea7c allow plugins to store a customData in the Attachments table to e.g. store custom paths without requiring an external DB
Alain Mazy <am@osimis.io>
parents:
diff changeset
7 *
d7274e43ea7c allow plugins to store a customData in the Attachments table to e.g. store custom paths without requiring an external DB
Alain Mazy <am@osimis.io>
parents:
diff changeset
8 * This program is free software: you can redistribute it and/or
d7274e43ea7c allow plugins to store a customData in the Attachments table to e.g. store custom paths without requiring an external DB
Alain Mazy <am@osimis.io>
parents:
diff changeset
9 * modify it under the terms of the GNU General Public License as
d7274e43ea7c allow plugins to store a customData in the Attachments table to e.g. store custom paths without requiring an external DB
Alain Mazy <am@osimis.io>
parents:
diff changeset
10 * published by the Free Software Foundation, either version 3 of the
d7274e43ea7c allow plugins to store a customData in the Attachments table to e.g. store custom paths without requiring an external DB
Alain Mazy <am@osimis.io>
parents:
diff changeset
11 * License, or (at your option) any later version.
d7274e43ea7c allow plugins to store a customData in the Attachments table to e.g. store custom paths without requiring an external DB
Alain Mazy <am@osimis.io>
parents:
diff changeset
12 *
d7274e43ea7c allow plugins to store a customData in the Attachments table to e.g. store custom paths without requiring an external DB
Alain Mazy <am@osimis.io>
parents:
diff changeset
13 * This program is distributed in the hope that it will be useful, but
d7274e43ea7c allow plugins to store a customData in the Attachments table to e.g. store custom paths without requiring an external DB
Alain Mazy <am@osimis.io>
parents:
diff changeset
14 * WITHOUT ANY WARRANTY; without even the implied warranty of
d7274e43ea7c allow plugins to store a customData in the Attachments table to e.g. store custom paths without requiring an external DB
Alain Mazy <am@osimis.io>
parents:
diff changeset
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
d7274e43ea7c allow plugins to store a customData in the Attachments table to e.g. store custom paths without requiring an external DB
Alain Mazy <am@osimis.io>
parents:
diff changeset
16 * General Public License for more details.
d7274e43ea7c allow plugins to store a customData in the Attachments table to e.g. store custom paths without requiring an external DB
Alain Mazy <am@osimis.io>
parents:
diff changeset
17 *
d7274e43ea7c allow plugins to store a customData in the Attachments table to e.g. store custom paths without requiring an external DB
Alain Mazy <am@osimis.io>
parents:
diff changeset
18 * You should have received a copy of the GNU General Public License
d7274e43ea7c allow plugins to store a customData in the Attachments table to e.g. store custom paths without requiring an external DB
Alain Mazy <am@osimis.io>
parents:
diff changeset
19 * along with this program. If not, see <http://www.gnu.org/licenses/>.
d7274e43ea7c allow plugins to store a customData in the Attachments table to e.g. store custom paths without requiring an external DB
Alain Mazy <am@osimis.io>
parents:
diff changeset
20 **/
d7274e43ea7c allow plugins to store a customData in the Attachments table to e.g. store custom paths without requiring an external DB
Alain Mazy <am@osimis.io>
parents:
diff changeset
21
5807
8279eaab0d1d merged default -> attach-custom-data
Alain Mazy <am@orthanc.team>
parents: 5085
diff changeset
22 #define ORTHANC_PLUGIN_NAME "advanced-storage"
5080
d7274e43ea7c allow plugins to store a customData in the Attachments table to e.g. store custom paths without requiring an external DB
Alain Mazy <am@osimis.io>
parents:
diff changeset
23
d7274e43ea7c allow plugins to store a customData in the Attachments table to e.g. store custom paths without requiring an external DB
Alain Mazy <am@osimis.io>
parents:
diff changeset
24 #include "../../../../OrthancFramework/Sources/Compatibility.h"
d7274e43ea7c allow plugins to store a customData in the Attachments table to e.g. store custom paths without requiring an external DB
Alain Mazy <am@osimis.io>
parents:
diff changeset
25 #include "../../../../OrthancFramework/Sources/OrthancException.h"
d7274e43ea7c allow plugins to store a customData in the Attachments table to e.g. store custom paths without requiring an external DB
Alain Mazy <am@osimis.io>
parents:
diff changeset
26 #include "../../../../OrthancFramework/Sources/SystemToolbox.h"
d7274e43ea7c allow plugins to store a customData in the Attachments table to e.g. store custom paths without requiring an external DB
Alain Mazy <am@osimis.io>
parents:
diff changeset
27 #include "../../../../OrthancFramework/Sources/Toolbox.h"
d7274e43ea7c allow plugins to store a customData in the Attachments table to e.g. store custom paths without requiring an external DB
Alain Mazy <am@osimis.io>
parents:
diff changeset
28 #include "../../../../OrthancFramework/Sources/Logging.h"
5811
a451777236fb advanced storage: fix + customizable path
Alain Mazy <am@orthanc.team>
parents: 5808
diff changeset
29 #include "../../../../OrthancFramework/Sources/DicomFormat/DicomInstanceHasher.h"
5080
d7274e43ea7c allow plugins to store a customData in the Attachments table to e.g. store custom paths without requiring an external DB
Alain Mazy <am@osimis.io>
parents:
diff changeset
30 #include "../Common/OrthancPluginCppWrapper.h"
d7274e43ea7c allow plugins to store a customData in the Attachments table to e.g. store custom paths without requiring an external DB
Alain Mazy <am@osimis.io>
parents:
diff changeset
31
d7274e43ea7c allow plugins to store a customData in the Attachments table to e.g. store custom paths without requiring an external DB
Alain Mazy <am@osimis.io>
parents:
diff changeset
32 #include <boost/filesystem.hpp>
d7274e43ea7c allow plugins to store a customData in the Attachments table to e.g. store custom paths without requiring an external DB
Alain Mazy <am@osimis.io>
parents:
diff changeset
33 #include <boost/filesystem/fstream.hpp>
d7274e43ea7c allow plugins to store a customData in the Attachments table to e.g. store custom paths without requiring an external DB
Alain Mazy <am@osimis.io>
parents:
diff changeset
34 #include <boost/iostreams/device/file_descriptor.hpp>
d7274e43ea7c allow plugins to store a customData in the Attachments table to e.g. store custom paths without requiring an external DB
Alain Mazy <am@osimis.io>
parents:
diff changeset
35 #include <boost/iostreams/stream.hpp>
d7274e43ea7c allow plugins to store a customData in the Attachments table to e.g. store custom paths without requiring an external DB
Alain Mazy <am@osimis.io>
parents:
diff changeset
36
d7274e43ea7c allow plugins to store a customData in the Attachments table to e.g. store custom paths without requiring an external DB
Alain Mazy <am@osimis.io>
parents:
diff changeset
37
d7274e43ea7c allow plugins to store a customData in the Attachments table to e.g. store custom paths without requiring an external DB
Alain Mazy <am@osimis.io>
parents:
diff changeset
38 #include <json/value.h>
d7274e43ea7c allow plugins to store a customData in the Attachments table to e.g. store custom paths without requiring an external DB
Alain Mazy <am@osimis.io>
parents:
diff changeset
39 #include <json/writer.h>
d7274e43ea7c allow plugins to store a customData in the Attachments table to e.g. store custom paths without requiring an external DB
Alain Mazy <am@osimis.io>
parents:
diff changeset
40 #include <string.h>
d7274e43ea7c allow plugins to store a customData in the Attachments table to e.g. store custom paths without requiring an external DB
Alain Mazy <am@osimis.io>
parents:
diff changeset
41 #include <iostream>
d7274e43ea7c allow plugins to store a customData in the Attachments table to e.g. store custom paths without requiring an external DB
Alain Mazy <am@osimis.io>
parents:
diff changeset
42 #include <algorithm>
d7274e43ea7c allow plugins to store a customData in the Attachments table to e.g. store custom paths without requiring an external DB
Alain Mazy <am@osimis.io>
parents:
diff changeset
43 #include <map>
d7274e43ea7c allow plugins to store a customData in the Attachments table to e.g. store custom paths without requiring an external DB
Alain Mazy <am@osimis.io>
parents:
diff changeset
44 #include <list>
d7274e43ea7c allow plugins to store a customData in the Attachments table to e.g. store custom paths without requiring an external DB
Alain Mazy <am@osimis.io>
parents:
diff changeset
45 #include <time.h>
d7274e43ea7c allow plugins to store a customData in the Attachments table to e.g. store custom paths without requiring an external DB
Alain Mazy <am@osimis.io>
parents:
diff changeset
46
d7274e43ea7c allow plugins to store a customData in the Attachments table to e.g. store custom paths without requiring an external DB
Alain Mazy <am@osimis.io>
parents:
diff changeset
47 namespace fs = boost::filesystem;
d7274e43ea7c allow plugins to store a customData in the Attachments table to e.g. store custom paths without requiring an external DB
Alain Mazy <am@osimis.io>
parents:
diff changeset
48
5081
c673997507ea advanced storage cont
Alain Mazy <am@osimis.io>
parents: 5080
diff changeset
49 fs::path rootPath_;
c673997507ea advanced storage cont
Alain Mazy <am@osimis.io>
parents: 5080
diff changeset
50 bool multipleStoragesEnabled_ = false;
c673997507ea advanced storage cont
Alain Mazy <am@osimis.io>
parents: 5080
diff changeset
51 std::map<std::string, fs::path> rootPaths_;
c673997507ea advanced storage cont
Alain Mazy <am@osimis.io>
parents: 5080
diff changeset
52 std::string currentStorageId_;
c673997507ea advanced storage cont
Alain Mazy <am@osimis.io>
parents: 5080
diff changeset
53 std::string namingScheme_;
5812
3f7985dc2df4 fixes in advanced-storage plugin
Alain Mazy <am@orthanc.team>
parents: 5811
diff changeset
54 std::string otherAttachmentsPrefix_;
5080
d7274e43ea7c allow plugins to store a customData in the Attachments table to e.g. store custom paths without requiring an external DB
Alain Mazy <am@osimis.io>
parents:
diff changeset
55 bool fsyncOnWrite_ = true;
5081
c673997507ea advanced storage cont
Alain Mazy <am@osimis.io>
parents: 5080
diff changeset
56 size_t maxPathLength_ = 256;
c673997507ea advanced storage cont
Alain Mazy <am@osimis.io>
parents: 5080
diff changeset
57 size_t legacyPathLength = 39; // ex "/00/f7/00f7fd8b-47bd8c3a-ff917804-d180cdbc-40cf9527"
c673997507ea advanced storage cont
Alain Mazy <am@osimis.io>
parents: 5080
diff changeset
58
c673997507ea advanced storage cont
Alain Mazy <am@osimis.io>
parents: 5080
diff changeset
59 fs::path GetRootPath()
c673997507ea advanced storage cont
Alain Mazy <am@osimis.io>
parents: 5080
diff changeset
60 {
c673997507ea advanced storage cont
Alain Mazy <am@osimis.io>
parents: 5080
diff changeset
61 if (multipleStoragesEnabled_)
c673997507ea advanced storage cont
Alain Mazy <am@osimis.io>
parents: 5080
diff changeset
62 {
c673997507ea advanced storage cont
Alain Mazy <am@osimis.io>
parents: 5080
diff changeset
63 return rootPaths_[currentStorageId_];
c673997507ea advanced storage cont
Alain Mazy <am@osimis.io>
parents: 5080
diff changeset
64 }
c673997507ea advanced storage cont
Alain Mazy <am@osimis.io>
parents: 5080
diff changeset
65
c673997507ea advanced storage cont
Alain Mazy <am@osimis.io>
parents: 5080
diff changeset
66 return rootPath_;
c673997507ea advanced storage cont
Alain Mazy <am@osimis.io>
parents: 5080
diff changeset
67 }
c673997507ea advanced storage cont
Alain Mazy <am@osimis.io>
parents: 5080
diff changeset
68
c673997507ea advanced storage cont
Alain Mazy <am@osimis.io>
parents: 5080
diff changeset
69 fs::path GetRootPath(const std::string& storageId)
c673997507ea advanced storage cont
Alain Mazy <am@osimis.io>
parents: 5080
diff changeset
70 {
c673997507ea advanced storage cont
Alain Mazy <am@osimis.io>
parents: 5080
diff changeset
71 if (multipleStoragesEnabled_)
c673997507ea advanced storage cont
Alain Mazy <am@osimis.io>
parents: 5080
diff changeset
72 {
c673997507ea advanced storage cont
Alain Mazy <am@osimis.io>
parents: 5080
diff changeset
73 if (rootPaths_.find(storageId) == rootPaths_.end())
c673997507ea advanced storage cont
Alain Mazy <am@osimis.io>
parents: 5080
diff changeset
74 {
c673997507ea advanced storage cont
Alain Mazy <am@osimis.io>
parents: 5080
diff changeset
75 throw Orthanc::OrthancException(Orthanc::ErrorCode_ParameterOutOfRange, std::string("Advanced Storage - storage '" + storageId + "' is not defined in configuration"));
c673997507ea advanced storage cont
Alain Mazy <am@osimis.io>
parents: 5080
diff changeset
76 }
c673997507ea advanced storage cont
Alain Mazy <am@osimis.io>
parents: 5080
diff changeset
77 return rootPaths_[storageId];
c673997507ea advanced storage cont
Alain Mazy <am@osimis.io>
parents: 5080
diff changeset
78 }
c673997507ea advanced storage cont
Alain Mazy <am@osimis.io>
parents: 5080
diff changeset
79
c673997507ea advanced storage cont
Alain Mazy <am@osimis.io>
parents: 5080
diff changeset
80 return rootPath_;
c673997507ea advanced storage cont
Alain Mazy <am@osimis.io>
parents: 5080
diff changeset
81 }
5080
d7274e43ea7c allow plugins to store a customData in the Attachments table to e.g. store custom paths without requiring an external DB
Alain Mazy <am@osimis.io>
parents:
diff changeset
82
d7274e43ea7c allow plugins to store a customData in the Attachments table to e.g. store custom paths without requiring an external DB
Alain Mazy <am@osimis.io>
parents:
diff changeset
83
d7274e43ea7c allow plugins to store a customData in the Attachments table to e.g. store custom paths without requiring an external DB
Alain Mazy <am@osimis.io>
parents:
diff changeset
84 fs::path GetLegacyRelativePath(const std::string& uuid)
d7274e43ea7c allow plugins to store a customData in the Attachments table to e.g. store custom paths without requiring an external DB
Alain Mazy <am@osimis.io>
parents:
diff changeset
85 {
d7274e43ea7c allow plugins to store a customData in the Attachments table to e.g. store custom paths without requiring an external DB
Alain Mazy <am@osimis.io>
parents:
diff changeset
86 if (!Orthanc::Toolbox::IsUuid(uuid))
d7274e43ea7c allow plugins to store a customData in the Attachments table to e.g. store custom paths without requiring an external DB
Alain Mazy <am@osimis.io>
parents:
diff changeset
87 {
d7274e43ea7c allow plugins to store a customData in the Attachments table to e.g. store custom paths without requiring an external DB
Alain Mazy <am@osimis.io>
parents:
diff changeset
88 throw Orthanc::OrthancException(Orthanc::ErrorCode_ParameterOutOfRange);
d7274e43ea7c allow plugins to store a customData in the Attachments table to e.g. store custom paths without requiring an external DB
Alain Mazy <am@osimis.io>
parents:
diff changeset
89 }
d7274e43ea7c allow plugins to store a customData in the Attachments table to e.g. store custom paths without requiring an external DB
Alain Mazy <am@osimis.io>
parents:
diff changeset
90
5081
c673997507ea advanced storage cont
Alain Mazy <am@osimis.io>
parents: 5080
diff changeset
91 fs::path path;
5080
d7274e43ea7c allow plugins to store a customData in the Attachments table to e.g. store custom paths without requiring an external DB
Alain Mazy <am@osimis.io>
parents:
diff changeset
92
5812
3f7985dc2df4 fixes in advanced-storage plugin
Alain Mazy <am@orthanc.team>
parents: 5811
diff changeset
93 if (!otherAttachmentsPrefix_.empty())
3f7985dc2df4 fixes in advanced-storage plugin
Alain Mazy <am@orthanc.team>
parents: 5811
diff changeset
94 {
3f7985dc2df4 fixes in advanced-storage plugin
Alain Mazy <am@orthanc.team>
parents: 5811
diff changeset
95 path /= otherAttachmentsPrefix_;
3f7985dc2df4 fixes in advanced-storage plugin
Alain Mazy <am@orthanc.team>
parents: 5811
diff changeset
96 }
3f7985dc2df4 fixes in advanced-storage plugin
Alain Mazy <am@orthanc.team>
parents: 5811
diff changeset
97
5080
d7274e43ea7c allow plugins to store a customData in the Attachments table to e.g. store custom paths without requiring an external DB
Alain Mazy <am@osimis.io>
parents:
diff changeset
98 path /= std::string(&uuid[0], &uuid[2]);
d7274e43ea7c allow plugins to store a customData in the Attachments table to e.g. store custom paths without requiring an external DB
Alain Mazy <am@osimis.io>
parents:
diff changeset
99 path /= std::string(&uuid[2], &uuid[4]);
d7274e43ea7c allow plugins to store a customData in the Attachments table to e.g. store custom paths without requiring an external DB
Alain Mazy <am@osimis.io>
parents:
diff changeset
100 path /= uuid;
d7274e43ea7c allow plugins to store a customData in the Attachments table to e.g. store custom paths without requiring an external DB
Alain Mazy <am@osimis.io>
parents:
diff changeset
101
d7274e43ea7c allow plugins to store a customData in the Attachments table to e.g. store custom paths without requiring an external DB
Alain Mazy <am@osimis.io>
parents:
diff changeset
102 #if BOOST_HAS_FILESYSTEM_V3 == 1
d7274e43ea7c allow plugins to store a customData in the Attachments table to e.g. store custom paths without requiring an external DB
Alain Mazy <am@osimis.io>
parents:
diff changeset
103 path.make_preferred();
d7274e43ea7c allow plugins to store a customData in the Attachments table to e.g. store custom paths without requiring an external DB
Alain Mazy <am@osimis.io>
parents:
diff changeset
104 #endif
d7274e43ea7c allow plugins to store a customData in the Attachments table to e.g. store custom paths without requiring an external DB
Alain Mazy <am@osimis.io>
parents:
diff changeset
105
d7274e43ea7c allow plugins to store a customData in the Attachments table to e.g. store custom paths without requiring an external DB
Alain Mazy <am@osimis.io>
parents:
diff changeset
106 return path;
d7274e43ea7c allow plugins to store a customData in the Attachments table to e.g. store custom paths without requiring an external DB
Alain Mazy <am@osimis.io>
parents:
diff changeset
107 }
d7274e43ea7c allow plugins to store a customData in the Attachments table to e.g. store custom paths without requiring an external DB
Alain Mazy <am@osimis.io>
parents:
diff changeset
108
5081
c673997507ea advanced storage cont
Alain Mazy <am@osimis.io>
parents: 5080
diff changeset
109 fs::path GetPath(const std::string& uuid, const std::string& customDataString)
5080
d7274e43ea7c allow plugins to store a customData in the Attachments table to e.g. store custom paths without requiring an external DB
Alain Mazy <am@osimis.io>
parents:
diff changeset
110 {
5081
c673997507ea advanced storage cont
Alain Mazy <am@osimis.io>
parents: 5080
diff changeset
111 fs::path path;
c673997507ea advanced storage cont
Alain Mazy <am@osimis.io>
parents: 5080
diff changeset
112
c673997507ea advanced storage cont
Alain Mazy <am@osimis.io>
parents: 5080
diff changeset
113 if (!customDataString.empty())
c673997507ea advanced storage cont
Alain Mazy <am@osimis.io>
parents: 5080
diff changeset
114 {
c673997507ea advanced storage cont
Alain Mazy <am@osimis.io>
parents: 5080
diff changeset
115 Json::Value customData;
c673997507ea advanced storage cont
Alain Mazy <am@osimis.io>
parents: 5080
diff changeset
116 Orthanc::Toolbox::ReadJson(customData, customDataString);
5080
d7274e43ea7c allow plugins to store a customData in the Attachments table to e.g. store custom paths without requiring an external DB
Alain Mazy <am@osimis.io>
parents:
diff changeset
117
5812
3f7985dc2df4 fixes in advanced-storage plugin
Alain Mazy <am@orthanc.team>
parents: 5811
diff changeset
118 if (customData["v"].asInt() == 1) // Version
5080
d7274e43ea7c allow plugins to store a customData in the Attachments table to e.g. store custom paths without requiring an external DB
Alain Mazy <am@osimis.io>
parents:
diff changeset
119 {
5812
3f7985dc2df4 fixes in advanced-storage plugin
Alain Mazy <am@orthanc.team>
parents: 5811
diff changeset
120 if (customData.isMember("s")) // Storage ID
5081
c673997507ea advanced storage cont
Alain Mazy <am@osimis.io>
parents: 5080
diff changeset
121 {
5812
3f7985dc2df4 fixes in advanced-storage plugin
Alain Mazy <am@orthanc.team>
parents: 5811
diff changeset
122 path = GetRootPath(customData["s"].asString());
5081
c673997507ea advanced storage cont
Alain Mazy <am@osimis.io>
parents: 5080
diff changeset
123 }
c673997507ea advanced storage cont
Alain Mazy <am@osimis.io>
parents: 5080
diff changeset
124 else
c673997507ea advanced storage cont
Alain Mazy <am@osimis.io>
parents: 5080
diff changeset
125 {
c673997507ea advanced storage cont
Alain Mazy <am@osimis.io>
parents: 5080
diff changeset
126 path = GetRootPath();
c673997507ea advanced storage cont
Alain Mazy <am@osimis.io>
parents: 5080
diff changeset
127 }
c673997507ea advanced storage cont
Alain Mazy <am@osimis.io>
parents: 5080
diff changeset
128
5812
3f7985dc2df4 fixes in advanced-storage plugin
Alain Mazy <am@orthanc.team>
parents: 5811
diff changeset
129 if (customData.isMember("p")) // Path
5081
c673997507ea advanced storage cont
Alain Mazy <am@osimis.io>
parents: 5080
diff changeset
130 {
5812
3f7985dc2df4 fixes in advanced-storage plugin
Alain Mazy <am@orthanc.team>
parents: 5811
diff changeset
131 path /= customData["p"].asString();
5081
c673997507ea advanced storage cont
Alain Mazy <am@osimis.io>
parents: 5080
diff changeset
132 }
c673997507ea advanced storage cont
Alain Mazy <am@osimis.io>
parents: 5080
diff changeset
133 else
c673997507ea advanced storage cont
Alain Mazy <am@osimis.io>
parents: 5080
diff changeset
134 { // we are in "legacy mode" for the path part
c673997507ea advanced storage cont
Alain Mazy <am@osimis.io>
parents: 5080
diff changeset
135 path /= GetLegacyRelativePath(uuid);
c673997507ea advanced storage cont
Alain Mazy <am@osimis.io>
parents: 5080
diff changeset
136 }
5080
d7274e43ea7c allow plugins to store a customData in the Attachments table to e.g. store custom paths without requiring an external DB
Alain Mazy <am@osimis.io>
parents:
diff changeset
137 }
d7274e43ea7c allow plugins to store a customData in the Attachments table to e.g. store custom paths without requiring an external DB
Alain Mazy <am@osimis.io>
parents:
diff changeset
138 else
d7274e43ea7c allow plugins to store a customData in the Attachments table to e.g. store custom paths without requiring an external DB
Alain Mazy <am@osimis.io>
parents:
diff changeset
139 {
5081
c673997507ea advanced storage cont
Alain Mazy <am@osimis.io>
parents: 5080
diff changeset
140 throw Orthanc::OrthancException(Orthanc::ErrorCode_ParameterOutOfRange, std::string("Advanced Storage - unknown version for custom data '" + boost::lexical_cast<std::string>(customData["Version"].asInt()) + "'"));
5080
d7274e43ea7c allow plugins to store a customData in the Attachments table to e.g. store custom paths without requiring an external DB
Alain Mazy <am@osimis.io>
parents:
diff changeset
141 }
d7274e43ea7c allow plugins to store a customData in the Attachments table to e.g. store custom paths without requiring an external DB
Alain Mazy <am@osimis.io>
parents:
diff changeset
142 }
5081
c673997507ea advanced storage cont
Alain Mazy <am@osimis.io>
parents: 5080
diff changeset
143 else // we are in "legacy mode"
5080
d7274e43ea7c allow plugins to store a customData in the Attachments table to e.g. store custom paths without requiring an external DB
Alain Mazy <am@osimis.io>
parents:
diff changeset
144 {
5812
3f7985dc2df4 fixes in advanced-storage plugin
Alain Mazy <am@orthanc.team>
parents: 5811
diff changeset
145 path = rootPath_;
5080
d7274e43ea7c allow plugins to store a customData in the Attachments table to e.g. store custom paths without requiring an external DB
Alain Mazy <am@osimis.io>
parents:
diff changeset
146 path /= GetLegacyRelativePath(uuid);
d7274e43ea7c allow plugins to store a customData in the Attachments table to e.g. store custom paths without requiring an external DB
Alain Mazy <am@osimis.io>
parents:
diff changeset
147 }
d7274e43ea7c allow plugins to store a customData in the Attachments table to e.g. store custom paths without requiring an external DB
Alain Mazy <am@osimis.io>
parents:
diff changeset
148
d7274e43ea7c allow plugins to store a customData in the Attachments table to e.g. store custom paths without requiring an external DB
Alain Mazy <am@osimis.io>
parents:
diff changeset
149 path.make_preferred();
d7274e43ea7c allow plugins to store a customData in the Attachments table to e.g. store custom paths without requiring an external DB
Alain Mazy <am@osimis.io>
parents:
diff changeset
150 return path;
d7274e43ea7c allow plugins to store a customData in the Attachments table to e.g. store custom paths without requiring an external DB
Alain Mazy <am@osimis.io>
parents:
diff changeset
151 }
d7274e43ea7c allow plugins to store a customData in the Attachments table to e.g. store custom paths without requiring an external DB
Alain Mazy <am@osimis.io>
parents:
diff changeset
152
5081
c673997507ea advanced storage cont
Alain Mazy <am@osimis.io>
parents: 5080
diff changeset
153 void GetCustomData(std::string& output, const fs::path& path)
5080
d7274e43ea7c allow plugins to store a customData in the Attachments table to e.g. store custom paths without requiring an external DB
Alain Mazy <am@osimis.io>
parents:
diff changeset
154 {
5081
c673997507ea advanced storage cont
Alain Mazy <am@osimis.io>
parents: 5080
diff changeset
155 // if we use defaults, non need to store anything in the metadata, the plugin has the same behavior as the core of Orthanc
c673997507ea advanced storage cont
Alain Mazy <am@osimis.io>
parents: 5080
diff changeset
156 if (namingScheme_ == "OrthancDefault" && !multipleStoragesEnabled_)
c673997507ea advanced storage cont
Alain Mazy <am@osimis.io>
parents: 5080
diff changeset
157 {
c673997507ea advanced storage cont
Alain Mazy <am@osimis.io>
parents: 5080
diff changeset
158 return;
c673997507ea advanced storage cont
Alain Mazy <am@osimis.io>
parents: 5080
diff changeset
159 }
c673997507ea advanced storage cont
Alain Mazy <am@osimis.io>
parents: 5080
diff changeset
160
c673997507ea advanced storage cont
Alain Mazy <am@osimis.io>
parents: 5080
diff changeset
161 Json::Value customDataJson;
5812
3f7985dc2df4 fixes in advanced-storage plugin
Alain Mazy <am@orthanc.team>
parents: 5811
diff changeset
162 // Keep short field names to reduce SQL data usage
3f7985dc2df4 fixes in advanced-storage plugin
Alain Mazy <am@orthanc.team>
parents: 5811
diff changeset
163 customDataJson["v"] = 1; // Version
5081
c673997507ea advanced storage cont
Alain Mazy <am@osimis.io>
parents: 5080
diff changeset
164
5808
63c025cf6958 cleanup
Alain Mazy <am@orthanc.team>
parents: 5807
diff changeset
165 // no need to store the path since if we are in the default mode
5081
c673997507ea advanced storage cont
Alain Mazy <am@osimis.io>
parents: 5080
diff changeset
166 if (namingScheme_ != "OrthancDefault")
5808
63c025cf6958 cleanup
Alain Mazy <am@orthanc.team>
parents: 5807
diff changeset
167 {
5812
3f7985dc2df4 fixes in advanced-storage plugin
Alain Mazy <am@orthanc.team>
parents: 5811
diff changeset
168 customDataJson["p"] = path.string(); // Path
5081
c673997507ea advanced storage cont
Alain Mazy <am@osimis.io>
parents: 5080
diff changeset
169 }
c673997507ea advanced storage cont
Alain Mazy <am@osimis.io>
parents: 5080
diff changeset
170
c673997507ea advanced storage cont
Alain Mazy <am@osimis.io>
parents: 5080
diff changeset
171 if (multipleStoragesEnabled_)
c673997507ea advanced storage cont
Alain Mazy <am@osimis.io>
parents: 5080
diff changeset
172 {
5812
3f7985dc2df4 fixes in advanced-storage plugin
Alain Mazy <am@orthanc.team>
parents: 5811
diff changeset
173 customDataJson["s"] = currentStorageId_; // Storage id
5081
c673997507ea advanced storage cont
Alain Mazy <am@osimis.io>
parents: 5080
diff changeset
174 }
c673997507ea advanced storage cont
Alain Mazy <am@osimis.io>
parents: 5080
diff changeset
175
5808
63c025cf6958 cleanup
Alain Mazy <am@orthanc.team>
parents: 5807
diff changeset
176 return Orthanc::Toolbox::WriteFastJson(output, customDataJson);
5080
d7274e43ea7c allow plugins to store a customData in the Attachments table to e.g. store custom paths without requiring an external DB
Alain Mazy <am@osimis.io>
parents:
diff changeset
177 }
d7274e43ea7c allow plugins to store a customData in the Attachments table to e.g. store custom paths without requiring an external DB
Alain Mazy <am@osimis.io>
parents:
diff changeset
178
5811
a451777236fb advanced storage: fix + customizable path
Alain Mazy <am@orthanc.team>
parents: 5808
diff changeset
179 std::string GetSplitDateDicomTagToPath(const Json::Value& tags, const char* tagName, const char* defaultValue = NULL)
5080
d7274e43ea7c allow plugins to store a customData in the Attachments table to e.g. store custom paths without requiring an external DB
Alain Mazy <am@osimis.io>
parents:
diff changeset
180 {
d7274e43ea7c allow plugins to store a customData in the Attachments table to e.g. store custom paths without requiring an external DB
Alain Mazy <am@osimis.io>
parents:
diff changeset
181 if (tags.isMember(tagName) && tags[tagName].asString().size() == 8)
d7274e43ea7c allow plugins to store a customData in the Attachments table to e.g. store custom paths without requiring an external DB
Alain Mazy <am@osimis.io>
parents:
diff changeset
182 {
d7274e43ea7c allow plugins to store a customData in the Attachments table to e.g. store custom paths without requiring an external DB
Alain Mazy <am@osimis.io>
parents:
diff changeset
183 std::string date = tags[tagName].asString();
5811
a451777236fb advanced storage: fix + customizable path
Alain Mazy <am@orthanc.team>
parents: 5808
diff changeset
184 return date.substr(0, 4) + "/" + date.substr(4, 2) + "/" + date.substr(6, 2);
5080
d7274e43ea7c allow plugins to store a customData in the Attachments table to e.g. store custom paths without requiring an external DB
Alain Mazy <am@osimis.io>
parents:
diff changeset
185 }
d7274e43ea7c allow plugins to store a customData in the Attachments table to e.g. store custom paths without requiring an external DB
Alain Mazy <am@osimis.io>
parents:
diff changeset
186 else if (defaultValue != NULL)
d7274e43ea7c allow plugins to store a customData in the Attachments table to e.g. store custom paths without requiring an external DB
Alain Mazy <am@osimis.io>
parents:
diff changeset
187 {
5811
a451777236fb advanced storage: fix + customizable path
Alain Mazy <am@orthanc.team>
parents: 5808
diff changeset
188 return defaultValue;
5080
d7274e43ea7c allow plugins to store a customData in the Attachments table to e.g. store custom paths without requiring an external DB
Alain Mazy <am@osimis.io>
parents:
diff changeset
189 }
5811
a451777236fb advanced storage: fix + customizable path
Alain Mazy <am@orthanc.team>
parents: 5808
diff changeset
190
a451777236fb advanced storage: fix + customizable path
Alain Mazy <am@orthanc.team>
parents: 5808
diff changeset
191 return "";
5080
d7274e43ea7c allow plugins to store a customData in the Attachments table to e.g. store custom paths without requiring an external DB
Alain Mazy <am@osimis.io>
parents:
diff changeset
192 }
d7274e43ea7c allow plugins to store a customData in the Attachments table to e.g. store custom paths without requiring an external DB
Alain Mazy <am@osimis.io>
parents:
diff changeset
193
5812
3f7985dc2df4 fixes in advanced-storage plugin
Alain Mazy <am@orthanc.team>
parents: 5811
diff changeset
194 std::string GetStringDicomTagForPath(const Json::Value& tags, const std::string& tagName, const char* defaultValue = NULL)
5080
d7274e43ea7c allow plugins to store a customData in the Attachments table to e.g. store custom paths without requiring an external DB
Alain Mazy <am@osimis.io>
parents:
diff changeset
195 {
d7274e43ea7c allow plugins to store a customData in the Attachments table to e.g. store custom paths without requiring an external DB
Alain Mazy <am@osimis.io>
parents:
diff changeset
196 if (tags.isMember(tagName) && tags[tagName].isString() && tags[tagName].asString().size() > 0)
d7274e43ea7c allow plugins to store a customData in the Attachments table to e.g. store custom paths without requiring an external DB
Alain Mazy <am@osimis.io>
parents:
diff changeset
197 {
5811
a451777236fb advanced storage: fix + customizable path
Alain Mazy <am@orthanc.team>
parents: 5808
diff changeset
198 return tags[tagName].asString();
5080
d7274e43ea7c allow plugins to store a customData in the Attachments table to e.g. store custom paths without requiring an external DB
Alain Mazy <am@osimis.io>
parents:
diff changeset
199 }
d7274e43ea7c allow plugins to store a customData in the Attachments table to e.g. store custom paths without requiring an external DB
Alain Mazy <am@osimis.io>
parents:
diff changeset
200 else if (defaultValue != NULL)
d7274e43ea7c allow plugins to store a customData in the Attachments table to e.g. store custom paths without requiring an external DB
Alain Mazy <am@osimis.io>
parents:
diff changeset
201 {
5811
a451777236fb advanced storage: fix + customizable path
Alain Mazy <am@orthanc.team>
parents: 5808
diff changeset
202 return defaultValue;
5080
d7274e43ea7c allow plugins to store a customData in the Attachments table to e.g. store custom paths without requiring an external DB
Alain Mazy <am@osimis.io>
parents:
diff changeset
203 }
5811
a451777236fb advanced storage: fix + customizable path
Alain Mazy <am@orthanc.team>
parents: 5808
diff changeset
204
a451777236fb advanced storage: fix + customizable path
Alain Mazy <am@orthanc.team>
parents: 5808
diff changeset
205 return "";
5080
d7274e43ea7c allow plugins to store a customData in the Attachments table to e.g. store custom paths without requiring an external DB
Alain Mazy <am@osimis.io>
parents:
diff changeset
206 }
d7274e43ea7c allow plugins to store a customData in the Attachments table to e.g. store custom paths without requiring an external DB
Alain Mazy <am@osimis.io>
parents:
diff changeset
207
5812
3f7985dc2df4 fixes in advanced-storage plugin
Alain Mazy <am@orthanc.team>
parents: 5811
diff changeset
208 std::string GetIntDicomTagForPath(const Json::Value& tags, const std::string& tagName, const char* defaultValue = NULL, size_t padding = 0)
3f7985dc2df4 fixes in advanced-storage plugin
Alain Mazy <am@orthanc.team>
parents: 5811
diff changeset
209 {
3f7985dc2df4 fixes in advanced-storage plugin
Alain Mazy <am@orthanc.team>
parents: 5811
diff changeset
210 if (tags.isMember(tagName))
3f7985dc2df4 fixes in advanced-storage plugin
Alain Mazy <am@orthanc.team>
parents: 5811
diff changeset
211 {
3f7985dc2df4 fixes in advanced-storage plugin
Alain Mazy <am@orthanc.team>
parents: 5811
diff changeset
212 std::string value;
3f7985dc2df4 fixes in advanced-storage plugin
Alain Mazy <am@orthanc.team>
parents: 5811
diff changeset
213 if (tags[tagName].isInt())
3f7985dc2df4 fixes in advanced-storage plugin
Alain Mazy <am@orthanc.team>
parents: 5811
diff changeset
214 {
3f7985dc2df4 fixes in advanced-storage plugin
Alain Mazy <am@orthanc.team>
parents: 5811
diff changeset
215 value = boost::lexical_cast<std::string>(tags[tagName].asInt());
3f7985dc2df4 fixes in advanced-storage plugin
Alain Mazy <am@orthanc.team>
parents: 5811
diff changeset
216 }
3f7985dc2df4 fixes in advanced-storage plugin
Alain Mazy <am@orthanc.team>
parents: 5811
diff changeset
217 else if (tags[tagName].isString())
3f7985dc2df4 fixes in advanced-storage plugin
Alain Mazy <am@orthanc.team>
parents: 5811
diff changeset
218 {
3f7985dc2df4 fixes in advanced-storage plugin
Alain Mazy <am@orthanc.team>
parents: 5811
diff changeset
219 value = tags[tagName].asString();
3f7985dc2df4 fixes in advanced-storage plugin
Alain Mazy <am@orthanc.team>
parents: 5811
diff changeset
220 }
3f7985dc2df4 fixes in advanced-storage plugin
Alain Mazy <am@orthanc.team>
parents: 5811
diff changeset
221
3f7985dc2df4 fixes in advanced-storage plugin
Alain Mazy <am@orthanc.team>
parents: 5811
diff changeset
222 if (padding > 0 && padding > value.size())
3f7985dc2df4 fixes in advanced-storage plugin
Alain Mazy <am@orthanc.team>
parents: 5811
diff changeset
223 {
3f7985dc2df4 fixes in advanced-storage plugin
Alain Mazy <am@orthanc.team>
parents: 5811
diff changeset
224 value = std::string(padding - value.size(), '0') + value;
3f7985dc2df4 fixes in advanced-storage plugin
Alain Mazy <am@orthanc.team>
parents: 5811
diff changeset
225 }
3f7985dc2df4 fixes in advanced-storage plugin
Alain Mazy <am@orthanc.team>
parents: 5811
diff changeset
226 return value;
3f7985dc2df4 fixes in advanced-storage plugin
Alain Mazy <am@orthanc.team>
parents: 5811
diff changeset
227 }
3f7985dc2df4 fixes in advanced-storage plugin
Alain Mazy <am@orthanc.team>
parents: 5811
diff changeset
228 else if (defaultValue != NULL)
3f7985dc2df4 fixes in advanced-storage plugin
Alain Mazy <am@orthanc.team>
parents: 5811
diff changeset
229 {
3f7985dc2df4 fixes in advanced-storage plugin
Alain Mazy <am@orthanc.team>
parents: 5811
diff changeset
230 return defaultValue;
3f7985dc2df4 fixes in advanced-storage plugin
Alain Mazy <am@orthanc.team>
parents: 5811
diff changeset
231 }
3f7985dc2df4 fixes in advanced-storage plugin
Alain Mazy <am@orthanc.team>
parents: 5811
diff changeset
232
3f7985dc2df4 fixes in advanced-storage plugin
Alain Mazy <am@orthanc.team>
parents: 5811
diff changeset
233 return "";
3f7985dc2df4 fixes in advanced-storage plugin
Alain Mazy <am@orthanc.team>
parents: 5811
diff changeset
234 }
3f7985dc2df4 fixes in advanced-storage plugin
Alain Mazy <am@orthanc.team>
parents: 5811
diff changeset
235
3f7985dc2df4 fixes in advanced-storage plugin
Alain Mazy <am@orthanc.team>
parents: 5811
diff changeset
236 void ReplaceTagKeyword(std::string& folderName, const std::string& keyword, const Json::Value& tags, const char* defaultValue, const char* tagKey = NULL)
3f7985dc2df4 fixes in advanced-storage plugin
Alain Mazy <am@orthanc.team>
parents: 5811
diff changeset
237 {
3f7985dc2df4 fixes in advanced-storage plugin
Alain Mazy <am@orthanc.team>
parents: 5811
diff changeset
238 if (folderName.find(keyword) != std::string::npos)
3f7985dc2df4 fixes in advanced-storage plugin
Alain Mazy <am@orthanc.team>
parents: 5811
diff changeset
239 {
3f7985dc2df4 fixes in advanced-storage plugin
Alain Mazy <am@orthanc.team>
parents: 5811
diff changeset
240 std::string key = keyword.substr(1, keyword.size() -2);
3f7985dc2df4 fixes in advanced-storage plugin
Alain Mazy <am@orthanc.team>
parents: 5811
diff changeset
241 if (tagKey != NULL)
3f7985dc2df4 fixes in advanced-storage plugin
Alain Mazy <am@orthanc.team>
parents: 5811
diff changeset
242 {
3f7985dc2df4 fixes in advanced-storage plugin
Alain Mazy <am@orthanc.team>
parents: 5811
diff changeset
243 key = tagKey;
3f7985dc2df4 fixes in advanced-storage plugin
Alain Mazy <am@orthanc.team>
parents: 5811
diff changeset
244 }
3f7985dc2df4 fixes in advanced-storage plugin
Alain Mazy <am@orthanc.team>
parents: 5811
diff changeset
245 boost::replace_all(folderName, keyword, GetStringDicomTagForPath(tags, key, defaultValue));
3f7985dc2df4 fixes in advanced-storage plugin
Alain Mazy <am@orthanc.team>
parents: 5811
diff changeset
246 }
3f7985dc2df4 fixes in advanced-storage plugin
Alain Mazy <am@orthanc.team>
parents: 5811
diff changeset
247 }
3f7985dc2df4 fixes in advanced-storage plugin
Alain Mazy <am@orthanc.team>
parents: 5811
diff changeset
248
3f7985dc2df4 fixes in advanced-storage plugin
Alain Mazy <am@orthanc.team>
parents: 5811
diff changeset
249 void ReplaceIntTagKeyword(std::string& folderName, const std::string& keyword, const Json::Value& tags, const char* defaultValue, size_t padding, const char* tagKey = NULL)
3f7985dc2df4 fixes in advanced-storage plugin
Alain Mazy <am@orthanc.team>
parents: 5811
diff changeset
250 {
3f7985dc2df4 fixes in advanced-storage plugin
Alain Mazy <am@orthanc.team>
parents: 5811
diff changeset
251 if (folderName.find(keyword) != std::string::npos)
3f7985dc2df4 fixes in advanced-storage plugin
Alain Mazy <am@orthanc.team>
parents: 5811
diff changeset
252 {
3f7985dc2df4 fixes in advanced-storage plugin
Alain Mazy <am@orthanc.team>
parents: 5811
diff changeset
253 std::string key = keyword.substr(1, keyword.size() -2);
3f7985dc2df4 fixes in advanced-storage plugin
Alain Mazy <am@orthanc.team>
parents: 5811
diff changeset
254 if (tagKey != NULL)
3f7985dc2df4 fixes in advanced-storage plugin
Alain Mazy <am@orthanc.team>
parents: 5811
diff changeset
255 {
3f7985dc2df4 fixes in advanced-storage plugin
Alain Mazy <am@orthanc.team>
parents: 5811
diff changeset
256 key = tagKey;
3f7985dc2df4 fixes in advanced-storage plugin
Alain Mazy <am@orthanc.team>
parents: 5811
diff changeset
257 }
3f7985dc2df4 fixes in advanced-storage plugin
Alain Mazy <am@orthanc.team>
parents: 5811
diff changeset
258 boost::replace_all(folderName, keyword, GetIntDicomTagForPath(tags, key, defaultValue, padding));
3f7985dc2df4 fixes in advanced-storage plugin
Alain Mazy <am@orthanc.team>
parents: 5811
diff changeset
259 }
3f7985dc2df4 fixes in advanced-storage plugin
Alain Mazy <am@orthanc.team>
parents: 5811
diff changeset
260 }
3f7985dc2df4 fixes in advanced-storage plugin
Alain Mazy <am@orthanc.team>
parents: 5811
diff changeset
261
3f7985dc2df4 fixes in advanced-storage plugin
Alain Mazy <am@orthanc.team>
parents: 5811
diff changeset
262
3f7985dc2df4 fixes in advanced-storage plugin
Alain Mazy <am@orthanc.team>
parents: 5811
diff changeset
263 void ReplaceOrthancID(std::string& folderName, const std::string& keyword, const std::string& id, size_t from, size_t length)
3f7985dc2df4 fixes in advanced-storage plugin
Alain Mazy <am@orthanc.team>
parents: 5811
diff changeset
264 {
3f7985dc2df4 fixes in advanced-storage plugin
Alain Mazy <am@orthanc.team>
parents: 5811
diff changeset
265 if (length == 0)
3f7985dc2df4 fixes in advanced-storage plugin
Alain Mazy <am@orthanc.team>
parents: 5811
diff changeset
266 {
3f7985dc2df4 fixes in advanced-storage plugin
Alain Mazy <am@orthanc.team>
parents: 5811
diff changeset
267 boost::replace_all(folderName, keyword, id);
3f7985dc2df4 fixes in advanced-storage plugin
Alain Mazy <am@orthanc.team>
parents: 5811
diff changeset
268 }
3f7985dc2df4 fixes in advanced-storage plugin
Alain Mazy <am@orthanc.team>
parents: 5811
diff changeset
269 else
3f7985dc2df4 fixes in advanced-storage plugin
Alain Mazy <am@orthanc.team>
parents: 5811
diff changeset
270 {
3f7985dc2df4 fixes in advanced-storage plugin
Alain Mazy <am@orthanc.team>
parents: 5811
diff changeset
271 boost::replace_all(folderName, keyword, id.substr(from, length));
3f7985dc2df4 fixes in advanced-storage plugin
Alain Mazy <am@orthanc.team>
parents: 5811
diff changeset
272 }
3f7985dc2df4 fixes in advanced-storage plugin
Alain Mazy <am@orthanc.team>
parents: 5811
diff changeset
273 }
3f7985dc2df4 fixes in advanced-storage plugin
Alain Mazy <am@orthanc.team>
parents: 5811
diff changeset
274
3f7985dc2df4 fixes in advanced-storage plugin
Alain Mazy <am@orthanc.team>
parents: 5811
diff changeset
275
3f7985dc2df4 fixes in advanced-storage plugin
Alain Mazy <am@orthanc.team>
parents: 5811
diff changeset
276
5080
d7274e43ea7c allow plugins to store a customData in the Attachments table to e.g. store custom paths without requiring an external DB
Alain Mazy <am@osimis.io>
parents:
diff changeset
277 void AddIntDicomTagToPath(fs::path& path, const Json::Value& tags, const char* tagName, size_t zeroPaddingWidth = 0, const char* defaultValue = NULL)
d7274e43ea7c allow plugins to store a customData in the Attachments table to e.g. store custom paths without requiring an external DB
Alain Mazy <am@osimis.io>
parents:
diff changeset
278 {
d7274e43ea7c allow plugins to store a customData in the Attachments table to e.g. store custom paths without requiring an external DB
Alain Mazy <am@osimis.io>
parents:
diff changeset
279 if (tags.isMember(tagName) && tags[tagName].isString() && tags[tagName].asString().size() > 0)
d7274e43ea7c allow plugins to store a customData in the Attachments table to e.g. store custom paths without requiring an external DB
Alain Mazy <am@osimis.io>
parents:
diff changeset
280 {
d7274e43ea7c allow plugins to store a customData in the Attachments table to e.g. store custom paths without requiring an external DB
Alain Mazy <am@osimis.io>
parents:
diff changeset
281 std::string tagValue = tags[tagName].asString();
d7274e43ea7c allow plugins to store a customData in the Attachments table to e.g. store custom paths without requiring an external DB
Alain Mazy <am@osimis.io>
parents:
diff changeset
282 if (zeroPaddingWidth > 0 && tagValue.size() < zeroPaddingWidth)
d7274e43ea7c allow plugins to store a customData in the Attachments table to e.g. store custom paths without requiring an external DB
Alain Mazy <am@osimis.io>
parents:
diff changeset
283 {
d7274e43ea7c allow plugins to store a customData in the Attachments table to e.g. store custom paths without requiring an external DB
Alain Mazy <am@osimis.io>
parents:
diff changeset
284 std::string padding(zeroPaddingWidth - tagValue.size(), '0');
d7274e43ea7c allow plugins to store a customData in the Attachments table to e.g. store custom paths without requiring an external DB
Alain Mazy <am@osimis.io>
parents:
diff changeset
285 path /= padding + tagValue;
d7274e43ea7c allow plugins to store a customData in the Attachments table to e.g. store custom paths without requiring an external DB
Alain Mazy <am@osimis.io>
parents:
diff changeset
286 }
d7274e43ea7c allow plugins to store a customData in the Attachments table to e.g. store custom paths without requiring an external DB
Alain Mazy <am@osimis.io>
parents:
diff changeset
287 else
d7274e43ea7c allow plugins to store a customData in the Attachments table to e.g. store custom paths without requiring an external DB
Alain Mazy <am@osimis.io>
parents:
diff changeset
288 {
d7274e43ea7c allow plugins to store a customData in the Attachments table to e.g. store custom paths without requiring an external DB
Alain Mazy <am@osimis.io>
parents:
diff changeset
289 path /= tagValue;
d7274e43ea7c allow plugins to store a customData in the Attachments table to e.g. store custom paths without requiring an external DB
Alain Mazy <am@osimis.io>
parents:
diff changeset
290 }
d7274e43ea7c allow plugins to store a customData in the Attachments table to e.g. store custom paths without requiring an external DB
Alain Mazy <am@osimis.io>
parents:
diff changeset
291 }
d7274e43ea7c allow plugins to store a customData in the Attachments table to e.g. store custom paths without requiring an external DB
Alain Mazy <am@osimis.io>
parents:
diff changeset
292 else if (defaultValue != NULL)
d7274e43ea7c allow plugins to store a customData in the Attachments table to e.g. store custom paths without requiring an external DB
Alain Mazy <am@osimis.io>
parents:
diff changeset
293 {
d7274e43ea7c allow plugins to store a customData in the Attachments table to e.g. store custom paths without requiring an external DB
Alain Mazy <am@osimis.io>
parents:
diff changeset
294 path /= defaultValue;
d7274e43ea7c allow plugins to store a customData in the Attachments table to e.g. store custom paths without requiring an external DB
Alain Mazy <am@osimis.io>
parents:
diff changeset
295 }
d7274e43ea7c allow plugins to store a customData in the Attachments table to e.g. store custom paths without requiring an external DB
Alain Mazy <am@osimis.io>
parents:
diff changeset
296 }
d7274e43ea7c allow plugins to store a customData in the Attachments table to e.g. store custom paths without requiring an external DB
Alain Mazy <am@osimis.io>
parents:
diff changeset
297
5081
c673997507ea advanced storage cont
Alain Mazy <am@osimis.io>
parents: 5080
diff changeset
298 std::string GetExtension(OrthancPluginContentType type, bool isCompressed)
5080
d7274e43ea7c allow plugins to store a customData in the Attachments table to e.g. store custom paths without requiring an external DB
Alain Mazy <am@osimis.io>
parents:
diff changeset
299 {
d7274e43ea7c allow plugins to store a customData in the Attachments table to e.g. store custom paths without requiring an external DB
Alain Mazy <am@osimis.io>
parents:
diff changeset
300 std::string extension;
d7274e43ea7c allow plugins to store a customData in the Attachments table to e.g. store custom paths without requiring an external DB
Alain Mazy <am@osimis.io>
parents:
diff changeset
301
d7274e43ea7c allow plugins to store a customData in the Attachments table to e.g. store custom paths without requiring an external DB
Alain Mazy <am@osimis.io>
parents:
diff changeset
302 switch (type)
d7274e43ea7c allow plugins to store a customData in the Attachments table to e.g. store custom paths without requiring an external DB
Alain Mazy <am@osimis.io>
parents:
diff changeset
303 {
d7274e43ea7c allow plugins to store a customData in the Attachments table to e.g. store custom paths without requiring an external DB
Alain Mazy <am@osimis.io>
parents:
diff changeset
304 case OrthancPluginContentType_Dicom:
d7274e43ea7c allow plugins to store a customData in the Attachments table to e.g. store custom paths without requiring an external DB
Alain Mazy <am@osimis.io>
parents:
diff changeset
305 extension = ".dcm";
d7274e43ea7c allow plugins to store a customData in the Attachments table to e.g. store custom paths without requiring an external DB
Alain Mazy <am@osimis.io>
parents:
diff changeset
306 break;
d7274e43ea7c allow plugins to store a customData in the Attachments table to e.g. store custom paths without requiring an external DB
Alain Mazy <am@osimis.io>
parents:
diff changeset
307 case OrthancPluginContentType_DicomUntilPixelData:
d7274e43ea7c allow plugins to store a customData in the Attachments table to e.g. store custom paths without requiring an external DB
Alain Mazy <am@osimis.io>
parents:
diff changeset
308 extension = ".dcm.head";
d7274e43ea7c allow plugins to store a customData in the Attachments table to e.g. store custom paths without requiring an external DB
Alain Mazy <am@osimis.io>
parents:
diff changeset
309 break;
d7274e43ea7c allow plugins to store a customData in the Attachments table to e.g. store custom paths without requiring an external DB
Alain Mazy <am@osimis.io>
parents:
diff changeset
310 default:
d7274e43ea7c allow plugins to store a customData in the Attachments table to e.g. store custom paths without requiring an external DB
Alain Mazy <am@osimis.io>
parents:
diff changeset
311 extension = ".unk";
d7274e43ea7c allow plugins to store a customData in the Attachments table to e.g. store custom paths without requiring an external DB
Alain Mazy <am@osimis.io>
parents:
diff changeset
312 }
d7274e43ea7c allow plugins to store a customData in the Attachments table to e.g. store custom paths without requiring an external DB
Alain Mazy <am@osimis.io>
parents:
diff changeset
313 if (isCompressed)
d7274e43ea7c allow plugins to store a customData in the Attachments table to e.g. store custom paths without requiring an external DB
Alain Mazy <am@osimis.io>
parents:
diff changeset
314 {
d7274e43ea7c allow plugins to store a customData in the Attachments table to e.g. store custom paths without requiring an external DB
Alain Mazy <am@osimis.io>
parents:
diff changeset
315 extension = extension + ".cmp"; // compression is zlib + size -> we can not use the .zip extension
d7274e43ea7c allow plugins to store a customData in the Attachments table to e.g. store custom paths without requiring an external DB
Alain Mazy <am@osimis.io>
parents:
diff changeset
316 }
d7274e43ea7c allow plugins to store a customData in the Attachments table to e.g. store custom paths without requiring an external DB
Alain Mazy <am@osimis.io>
parents:
diff changeset
317
5081
c673997507ea advanced storage cont
Alain Mazy <am@osimis.io>
parents: 5080
diff changeset
318 return extension;
c673997507ea advanced storage cont
Alain Mazy <am@osimis.io>
parents: 5080
diff changeset
319 }
c673997507ea advanced storage cont
Alain Mazy <am@osimis.io>
parents: 5080
diff changeset
320
c673997507ea advanced storage cont
Alain Mazy <am@osimis.io>
parents: 5080
diff changeset
321 fs::path GetRelativePathFromTags(const Json::Value& tags, const char* uuid, OrthancPluginContentType type, bool isCompressed)
c673997507ea advanced storage cont
Alain Mazy <am@osimis.io>
parents: 5080
diff changeset
322 {
c673997507ea advanced storage cont
Alain Mazy <am@osimis.io>
parents: 5080
diff changeset
323 fs::path path;
c673997507ea advanced storage cont
Alain Mazy <am@osimis.io>
parents: 5080
diff changeset
324
c673997507ea advanced storage cont
Alain Mazy <am@osimis.io>
parents: 5080
diff changeset
325 if (!tags.isNull())
c673997507ea advanced storage cont
Alain Mazy <am@osimis.io>
parents: 5080
diff changeset
326 {
5811
a451777236fb advanced storage: fix + customizable path
Alain Mazy <am@orthanc.team>
parents: 5808
diff changeset
327 std::vector<std::string> folderNames;
a451777236fb advanced storage: fix + customizable path
Alain Mazy <am@orthanc.team>
parents: 5808
diff changeset
328 Orthanc::Toolbox::SplitString(folderNames, namingScheme_, '/');
a451777236fb advanced storage: fix + customizable path
Alain Mazy <am@orthanc.team>
parents: 5808
diff changeset
329
a451777236fb advanced storage: fix + customizable path
Alain Mazy <am@orthanc.team>
parents: 5808
diff changeset
330 for (std::vector<std::string>::const_iterator it = folderNames.begin(); it != folderNames.end(); ++it)
5081
c673997507ea advanced storage cont
Alain Mazy <am@osimis.io>
parents: 5080
diff changeset
331 {
5811
a451777236fb advanced storage: fix + customizable path
Alain Mazy <am@orthanc.team>
parents: 5808
diff changeset
332 std::string folderName = *it;
5812
3f7985dc2df4 fixes in advanced-storage plugin
Alain Mazy <am@orthanc.team>
parents: 5811
diff changeset
333
3f7985dc2df4 fixes in advanced-storage plugin
Alain Mazy <am@orthanc.team>
parents: 5811
diff changeset
334 if (folderName.find("{split(StudyDate)}") != std::string::npos)
5811
a451777236fb advanced storage: fix + customizable path
Alain Mazy <am@orthanc.team>
parents: 5808
diff changeset
335 {
5812
3f7985dc2df4 fixes in advanced-storage plugin
Alain Mazy <am@orthanc.team>
parents: 5811
diff changeset
336 boost::replace_all(folderName, "{split(StudyDate)}", GetSplitDateDicomTagToPath(tags, "StudyDate", "NO_STUDY_DATE"));
5811
a451777236fb advanced storage: fix + customizable path
Alain Mazy <am@orthanc.team>
parents: 5808
diff changeset
337 }
a451777236fb advanced storage: fix + customizable path
Alain Mazy <am@orthanc.team>
parents: 5808
diff changeset
338
5812
3f7985dc2df4 fixes in advanced-storage plugin
Alain Mazy <am@orthanc.team>
parents: 5811
diff changeset
339 if (folderName.find("{split(PatientBirthDate)}") != std::string::npos)
5811
a451777236fb advanced storage: fix + customizable path
Alain Mazy <am@orthanc.team>
parents: 5808
diff changeset
340 {
5812
3f7985dc2df4 fixes in advanced-storage plugin
Alain Mazy <am@orthanc.team>
parents: 5811
diff changeset
341 boost::replace_all(folderName, "{split(PatientBirthDate)}", GetSplitDateDicomTagToPath(tags, "PatientBirthDate", "NO_PATIENT_BIRTH_DATE"));
5081
c673997507ea advanced storage cont
Alain Mazy <am@osimis.io>
parents: 5080
diff changeset
342 }
5080
d7274e43ea7c allow plugins to store a customData in the Attachments table to e.g. store custom paths without requiring an external DB
Alain Mazy <am@osimis.io>
parents:
diff changeset
343
5812
3f7985dc2df4 fixes in advanced-storage plugin
Alain Mazy <am@orthanc.team>
parents: 5811
diff changeset
344 ReplaceTagKeyword(folderName, "{PatientID}", tags, "NO_PATIENT_ID");
3f7985dc2df4 fixes in advanced-storage plugin
Alain Mazy <am@orthanc.team>
parents: 5811
diff changeset
345 ReplaceTagKeyword(folderName, "{PatientBirthDate}", tags, "NO_PATIENT_BIRTH_DATE");
3f7985dc2df4 fixes in advanced-storage plugin
Alain Mazy <am@orthanc.team>
parents: 5811
diff changeset
346 ReplaceTagKeyword(folderName, "{PatientName}", tags, "NO_PATIENT_NAME");
3f7985dc2df4 fixes in advanced-storage plugin
Alain Mazy <am@orthanc.team>
parents: 5811
diff changeset
347 ReplaceTagKeyword(folderName, "{PatientSex}", tags, "NO_PATIENT_SEX");
3f7985dc2df4 fixes in advanced-storage plugin
Alain Mazy <am@orthanc.team>
parents: 5811
diff changeset
348 ReplaceTagKeyword(folderName, "{StudyInstanceUID}", tags, "NO_STUDY_INSTANCE_UID");
3f7985dc2df4 fixes in advanced-storage plugin
Alain Mazy <am@orthanc.team>
parents: 5811
diff changeset
349 ReplaceTagKeyword(folderName, "{StudyDate}", tags, "NO_STUDY_DATE");
3f7985dc2df4 fixes in advanced-storage plugin
Alain Mazy <am@orthanc.team>
parents: 5811
diff changeset
350 ReplaceTagKeyword(folderName, "{StudyID}", tags, "NO_STUDY_ID");
3f7985dc2df4 fixes in advanced-storage plugin
Alain Mazy <am@orthanc.team>
parents: 5811
diff changeset
351 ReplaceTagKeyword(folderName, "{StudyDescription}", tags, "NO_STUDY_DESCRIPTION");
3f7985dc2df4 fixes in advanced-storage plugin
Alain Mazy <am@orthanc.team>
parents: 5811
diff changeset
352 ReplaceTagKeyword(folderName, "{AccessionNumber}", tags, "NO_ACCESSION_NUMBER");
3f7985dc2df4 fixes in advanced-storage plugin
Alain Mazy <am@orthanc.team>
parents: 5811
diff changeset
353 ReplaceTagKeyword(folderName, "{SeriesInstanceUID}", tags, "NO_SERIES_INSTANCE_UID");
3f7985dc2df4 fixes in advanced-storage plugin
Alain Mazy <am@orthanc.team>
parents: 5811
diff changeset
354 ReplaceTagKeyword(folderName, "{SeriesDate}", tags, "NO_SERIES_DATE");
3f7985dc2df4 fixes in advanced-storage plugin
Alain Mazy <am@orthanc.team>
parents: 5811
diff changeset
355 ReplaceTagKeyword(folderName, "{SeriesDescription}", tags, "NO_SERIES_DESCRIPTION");
3f7985dc2df4 fixes in advanced-storage plugin
Alain Mazy <am@orthanc.team>
parents: 5811
diff changeset
356 ReplaceTagKeyword(folderName, "{SOPInstanceUID}", tags, "NO_SOP_INSTANCE_UID");
3f7985dc2df4 fixes in advanced-storage plugin
Alain Mazy <am@orthanc.team>
parents: 5811
diff changeset
357 ReplaceIntTagKeyword(folderName, "{SeriesNumber}", tags, "NO_SERIES_NUMBER", 0);
3f7985dc2df4 fixes in advanced-storage plugin
Alain Mazy <am@orthanc.team>
parents: 5811
diff changeset
358 ReplaceIntTagKeyword(folderName, "{InstanceNumber}", tags, "NO_INSTANCE_NUMBER", 0);
3f7985dc2df4 fixes in advanced-storage plugin
Alain Mazy <am@orthanc.team>
parents: 5811
diff changeset
359 ReplaceIntTagKeyword(folderName, "{pad4(SeriesNumber)}", tags, "NO_SERIES_NUMBER", 4, "SeriesNumber");
3f7985dc2df4 fixes in advanced-storage plugin
Alain Mazy <am@orthanc.team>
parents: 5811
diff changeset
360 ReplaceIntTagKeyword(folderName, "{pad4(InstanceNumber)}", tags, "NO_INSTANCE_NUMBER", 4, "InstanceNumber");
3f7985dc2df4 fixes in advanced-storage plugin
Alain Mazy <am@orthanc.team>
parents: 5811
diff changeset
361 ReplaceIntTagKeyword(folderName, "{pad6(SeriesNumber)}", tags, "NO_SERIES_NUMBER", 6, "SeriesNumber");
3f7985dc2df4 fixes in advanced-storage plugin
Alain Mazy <am@orthanc.team>
parents: 5811
diff changeset
362 ReplaceIntTagKeyword(folderName, "{pad6(InstanceNumber)}", tags, "NO_INSTANCE_NUMBER", 6, "InstanceNumber");
3f7985dc2df4 fixes in advanced-storage plugin
Alain Mazy <am@orthanc.team>
parents: 5811
diff changeset
363 ReplaceIntTagKeyword(folderName, "{pad8(SeriesNumber)}", tags, "NO_SERIES_NUMBER", 8, "SeriesNumber");
3f7985dc2df4 fixes in advanced-storage plugin
Alain Mazy <am@orthanc.team>
parents: 5811
diff changeset
364 ReplaceIntTagKeyword(folderName, "{pad8(InstanceNumber)}", tags, "NO_INSTANCE_NUMBER", 8, "InstanceNumber");
5811
a451777236fb advanced storage: fix + customizable path
Alain Mazy <am@orthanc.team>
parents: 5808
diff changeset
365
5812
3f7985dc2df4 fixes in advanced-storage plugin
Alain Mazy <am@orthanc.team>
parents: 5811
diff changeset
366 Orthanc::DicomInstanceHasher hasher(tags["PatientID"].asString(), tags["StudyInstanceUID"].asString(), tags["SeriesInstanceUID"].asString(), tags["SOPInstanceUID"].asString());
3f7985dc2df4 fixes in advanced-storage plugin
Alain Mazy <am@orthanc.team>
parents: 5811
diff changeset
367 std::string orthancPatientId = hasher.HashPatient();
3f7985dc2df4 fixes in advanced-storage plugin
Alain Mazy <am@orthanc.team>
parents: 5811
diff changeset
368 std::string orthancStudyId = hasher.HashStudy();
3f7985dc2df4 fixes in advanced-storage plugin
Alain Mazy <am@orthanc.team>
parents: 5811
diff changeset
369 std::string orthancSeriesId = hasher.HashSeries();
3f7985dc2df4 fixes in advanced-storage plugin
Alain Mazy <am@orthanc.team>
parents: 5811
diff changeset
370 std::string orthancInstanceId = hasher.HashInstance();
3f7985dc2df4 fixes in advanced-storage plugin
Alain Mazy <am@orthanc.team>
parents: 5811
diff changeset
371
3f7985dc2df4 fixes in advanced-storage plugin
Alain Mazy <am@orthanc.team>
parents: 5811
diff changeset
372 ReplaceOrthancID(folderName, "{OrthancPatientID}", orthancPatientId, 0, 0);
3f7985dc2df4 fixes in advanced-storage plugin
Alain Mazy <am@orthanc.team>
parents: 5811
diff changeset
373 ReplaceOrthancID(folderName, "{OrthancStudyID}", orthancStudyId, 0, 0);
3f7985dc2df4 fixes in advanced-storage plugin
Alain Mazy <am@orthanc.team>
parents: 5811
diff changeset
374 ReplaceOrthancID(folderName, "{OrthancSeriesID}", orthancSeriesId, 0, 0);
3f7985dc2df4 fixes in advanced-storage plugin
Alain Mazy <am@orthanc.team>
parents: 5811
diff changeset
375 ReplaceOrthancID(folderName, "{OrthancInstanceID}", orthancInstanceId, 0, 0);
3f7985dc2df4 fixes in advanced-storage plugin
Alain Mazy <am@orthanc.team>
parents: 5811
diff changeset
376
3f7985dc2df4 fixes in advanced-storage plugin
Alain Mazy <am@orthanc.team>
parents: 5811
diff changeset
377 ReplaceOrthancID(folderName, "{01(OrthancPatientID)}", orthancPatientId, 0, 2);
3f7985dc2df4 fixes in advanced-storage plugin
Alain Mazy <am@orthanc.team>
parents: 5811
diff changeset
378 ReplaceOrthancID(folderName, "{01(OrthancStudyID)}", orthancStudyId, 0, 2);
3f7985dc2df4 fixes in advanced-storage plugin
Alain Mazy <am@orthanc.team>
parents: 5811
diff changeset
379 ReplaceOrthancID(folderName, "{01(OrthancSeriesID)}", orthancSeriesId, 0, 2);
3f7985dc2df4 fixes in advanced-storage plugin
Alain Mazy <am@orthanc.team>
parents: 5811
diff changeset
380 ReplaceOrthancID(folderName, "{01(OrthancInstanceID)}", orthancInstanceId, 0, 2);
3f7985dc2df4 fixes in advanced-storage plugin
Alain Mazy <am@orthanc.team>
parents: 5811
diff changeset
381
3f7985dc2df4 fixes in advanced-storage plugin
Alain Mazy <am@orthanc.team>
parents: 5811
diff changeset
382 ReplaceOrthancID(folderName, "{23(OrthancPatientID)}", orthancPatientId, 2, 2);
3f7985dc2df4 fixes in advanced-storage plugin
Alain Mazy <am@orthanc.team>
parents: 5811
diff changeset
383 ReplaceOrthancID(folderName, "{23(OrthancStudyID)}", orthancStudyId, 2, 2);
3f7985dc2df4 fixes in advanced-storage plugin
Alain Mazy <am@orthanc.team>
parents: 5811
diff changeset
384 ReplaceOrthancID(folderName, "{23(OrthancSeriesID)}", orthancSeriesId, 2, 2);
3f7985dc2df4 fixes in advanced-storage plugin
Alain Mazy <am@orthanc.team>
parents: 5811
diff changeset
385 ReplaceOrthancID(folderName, "{23(OrthancInstanceID)}", orthancInstanceId, 2, 2);
3f7985dc2df4 fixes in advanced-storage plugin
Alain Mazy <am@orthanc.team>
parents: 5811
diff changeset
386
3f7985dc2df4 fixes in advanced-storage plugin
Alain Mazy <am@orthanc.team>
parents: 5811
diff changeset
387 if (folderName.find("{UUID}") != std::string::npos)
5081
c673997507ea advanced storage cont
Alain Mazy <am@osimis.io>
parents: 5080
diff changeset
388 {
5812
3f7985dc2df4 fixes in advanced-storage plugin
Alain Mazy <am@orthanc.team>
parents: 5811
diff changeset
389 boost::replace_all(folderName, "{UUID}", uuid);
5811
a451777236fb advanced storage: fix + customizable path
Alain Mazy <am@orthanc.team>
parents: 5808
diff changeset
390 }
a451777236fb advanced storage: fix + customizable path
Alain Mazy <am@orthanc.team>
parents: 5808
diff changeset
391
5812
3f7985dc2df4 fixes in advanced-storage plugin
Alain Mazy <am@orthanc.team>
parents: 5811
diff changeset
392 if (folderName.find("{.ext}") != std::string::npos)
5811
a451777236fb advanced storage: fix + customizable path
Alain Mazy <am@orthanc.team>
parents: 5808
diff changeset
393 {
5812
3f7985dc2df4 fixes in advanced-storage plugin
Alain Mazy <am@orthanc.team>
parents: 5811
diff changeset
394 boost::replace_all(folderName, "{.ext}", GetExtension(type, isCompressed));
5811
a451777236fb advanced storage: fix + customizable path
Alain Mazy <am@orthanc.team>
parents: 5808
diff changeset
395 }
a451777236fb advanced storage: fix + customizable path
Alain Mazy <am@orthanc.team>
parents: 5808
diff changeset
396
a451777236fb advanced storage: fix + customizable path
Alain Mazy <am@orthanc.team>
parents: 5808
diff changeset
397 path /= folderName;
5081
c673997507ea advanced storage cont
Alain Mazy <am@osimis.io>
parents: 5080
diff changeset
398 }
5811
a451777236fb advanced storage: fix + customizable path
Alain Mazy <am@orthanc.team>
parents: 5808
diff changeset
399
a451777236fb advanced storage: fix + customizable path
Alain Mazy <am@orthanc.team>
parents: 5808
diff changeset
400 return path;
5081
c673997507ea advanced storage cont
Alain Mazy <am@osimis.io>
parents: 5080
diff changeset
401 }
c673997507ea advanced storage cont
Alain Mazy <am@osimis.io>
parents: 5080
diff changeset
402
c673997507ea advanced storage cont
Alain Mazy <am@osimis.io>
parents: 5080
diff changeset
403 return GetLegacyRelativePath(uuid);
5080
d7274e43ea7c allow plugins to store a customData in the Attachments table to e.g. store custom paths without requiring an external DB
Alain Mazy <am@osimis.io>
parents:
diff changeset
404 }
d7274e43ea7c allow plugins to store a customData in the Attachments table to e.g. store custom paths without requiring an external DB
Alain Mazy <am@osimis.io>
parents:
diff changeset
405
d7274e43ea7c allow plugins to store a customData in the Attachments table to e.g. store custom paths without requiring an external DB
Alain Mazy <am@osimis.io>
parents:
diff changeset
406
d7274e43ea7c allow plugins to store a customData in the Attachments table to e.g. store custom paths without requiring an external DB
Alain Mazy <am@osimis.io>
parents:
diff changeset
407 OrthancPluginErrorCode StorageCreate(OrthancPluginMemoryBuffer* customData,
d7274e43ea7c allow plugins to store a customData in the Attachments table to e.g. store custom paths without requiring an external DB
Alain Mazy <am@osimis.io>
parents:
diff changeset
408 const char* uuid,
d7274e43ea7c allow plugins to store a customData in the Attachments table to e.g. store custom paths without requiring an external DB
Alain Mazy <am@osimis.io>
parents:
diff changeset
409 const Json::Value& tags,
d7274e43ea7c allow plugins to store a customData in the Attachments table to e.g. store custom paths without requiring an external DB
Alain Mazy <am@osimis.io>
parents:
diff changeset
410 const void* content,
d7274e43ea7c allow plugins to store a customData in the Attachments table to e.g. store custom paths without requiring an external DB
Alain Mazy <am@osimis.io>
parents:
diff changeset
411 int64_t size,
d7274e43ea7c allow plugins to store a customData in the Attachments table to e.g. store custom paths without requiring an external DB
Alain Mazy <am@osimis.io>
parents:
diff changeset
412 OrthancPluginContentType type,
d7274e43ea7c allow plugins to store a customData in the Attachments table to e.g. store custom paths without requiring an external DB
Alain Mazy <am@osimis.io>
parents:
diff changeset
413 bool isCompressed)
d7274e43ea7c allow plugins to store a customData in the Attachments table to e.g. store custom paths without requiring an external DB
Alain Mazy <am@osimis.io>
parents:
diff changeset
414 {
d7274e43ea7c allow plugins to store a customData in the Attachments table to e.g. store custom paths without requiring an external DB
Alain Mazy <am@osimis.io>
parents:
diff changeset
415 fs::path relativePath = GetRelativePathFromTags(tags, uuid, type, isCompressed);
5081
c673997507ea advanced storage cont
Alain Mazy <am@osimis.io>
parents: 5080
diff changeset
416 fs::path rootPath = GetRootPath();
c673997507ea advanced storage cont
Alain Mazy <am@osimis.io>
parents: 5080
diff changeset
417 fs::path path = rootPath / relativePath;
c673997507ea advanced storage cont
Alain Mazy <am@osimis.io>
parents: 5080
diff changeset
418
c673997507ea advanced storage cont
Alain Mazy <am@osimis.io>
parents: 5080
diff changeset
419 // check that the final path is not 'above' the root path (this could happen if e.g., a PatientName is ../../../../toto)
5082
Alain Mazy <am@osimis.io>
parents: 5081
diff changeset
420 // fs::canonical() can not be used for that since the file needs to exist
Alain Mazy <am@osimis.io>
parents: 5081
diff changeset
421 // so far, we'll just forbid path containing '..' since they might be suspicious
Alain Mazy <am@osimis.io>
parents: 5081
diff changeset
422 if (path.string().find("..") != std::string::npos)
5081
c673997507ea advanced storage cont
Alain Mazy <am@osimis.io>
parents: 5080
diff changeset
423 {
5812
3f7985dc2df4 fixes in advanced-storage plugin
Alain Mazy <am@orthanc.team>
parents: 5811
diff changeset
424 relativePath = GetLegacyRelativePath(uuid);
3f7985dc2df4 fixes in advanced-storage plugin
Alain Mazy <am@orthanc.team>
parents: 5811
diff changeset
425 fs::path legacyPath = rootPath / relativePath;
5082
Alain Mazy <am@osimis.io>
parents: 5081
diff changeset
426 LOG(WARNING) << "Advanced Storage - WAS02 - Path is suspicious since it contains '..': '" << path.string() << "' will be stored in '" << legacyPath << "'";
Alain Mazy <am@osimis.io>
parents: 5081
diff changeset
427 path = legacyPath;
5081
c673997507ea advanced storage cont
Alain Mazy <am@osimis.io>
parents: 5080
diff changeset
428 }
5080
d7274e43ea7c allow plugins to store a customData in the Attachments table to e.g. store custom paths without requiring an external DB
Alain Mazy <am@osimis.io>
parents:
diff changeset
429
5081
c673997507ea advanced storage cont
Alain Mazy <am@osimis.io>
parents: 5080
diff changeset
430 // check path length !!!!!, if too long, go back to legacy path and issue a warning
c673997507ea advanced storage cont
Alain Mazy <am@osimis.io>
parents: 5080
diff changeset
431 if (path.string().size() > maxPathLength_)
c673997507ea advanced storage cont
Alain Mazy <am@osimis.io>
parents: 5080
diff changeset
432 {
5812
3f7985dc2df4 fixes in advanced-storage plugin
Alain Mazy <am@orthanc.team>
parents: 5811
diff changeset
433 relativePath = GetLegacyRelativePath(uuid);
3f7985dc2df4 fixes in advanced-storage plugin
Alain Mazy <am@orthanc.team>
parents: 5811
diff changeset
434 fs::path legacyPath = rootPath / relativePath;
5081
c673997507ea advanced storage cont
Alain Mazy <am@osimis.io>
parents: 5080
diff changeset
435 LOG(WARNING) << "Advanced Storage - WAS01 - Path is too long: '" << path.string() << "' will be stored in '" << legacyPath << "'";
c673997507ea advanced storage cont
Alain Mazy <am@osimis.io>
parents: 5080
diff changeset
436 path = legacyPath;
c673997507ea advanced storage cont
Alain Mazy <am@osimis.io>
parents: 5080
diff changeset
437 }
c673997507ea advanced storage cont
Alain Mazy <am@osimis.io>
parents: 5080
diff changeset
438
c673997507ea advanced storage cont
Alain Mazy <am@osimis.io>
parents: 5080
diff changeset
439 if (fs::exists(path))
5080
d7274e43ea7c allow plugins to store a customData in the Attachments table to e.g. store custom paths without requiring an external DB
Alain Mazy <am@osimis.io>
parents:
diff changeset
440 {
d7274e43ea7c allow plugins to store a customData in the Attachments table to e.g. store custom paths without requiring an external DB
Alain Mazy <am@osimis.io>
parents:
diff changeset
441 // Extremely unlikely case if uuid is included in the path: This Uuid has already been created
d7274e43ea7c allow plugins to store a customData in the Attachments table to e.g. store custom paths without requiring an external DB
Alain Mazy <am@osimis.io>
parents:
diff changeset
442 // in the past.
5081
c673997507ea advanced storage cont
Alain Mazy <am@osimis.io>
parents: 5080
diff changeset
443 throw Orthanc::OrthancException(Orthanc::ErrorCode_InternalError, "Advanced Storage - path already exists");
5080
d7274e43ea7c allow plugins to store a customData in the Attachments table to e.g. store custom paths without requiring an external DB
Alain Mazy <am@osimis.io>
parents:
diff changeset
444
d7274e43ea7c allow plugins to store a customData in the Attachments table to e.g. store custom paths without requiring an external DB
Alain Mazy <am@osimis.io>
parents:
diff changeset
445 // TODO for the future: handle duplicates path (e.g: there's no uuid in the path and we are uploading the same file again)
d7274e43ea7c allow plugins to store a customData in the Attachments table to e.g. store custom paths without requiring an external DB
Alain Mazy <am@osimis.io>
parents:
diff changeset
446 }
d7274e43ea7c allow plugins to store a customData in the Attachments table to e.g. store custom paths without requiring an external DB
Alain Mazy <am@osimis.io>
parents:
diff changeset
447
5812
3f7985dc2df4 fixes in advanced-storage plugin
Alain Mazy <am@orthanc.team>
parents: 5811
diff changeset
448 std::string customDataString;
3f7985dc2df4 fixes in advanced-storage plugin
Alain Mazy <am@orthanc.team>
parents: 5811
diff changeset
449 GetCustomData(customDataString, relativePath);
3f7985dc2df4 fixes in advanced-storage plugin
Alain Mazy <am@orthanc.team>
parents: 5811
diff changeset
450
3f7985dc2df4 fixes in advanced-storage plugin
Alain Mazy <am@orthanc.team>
parents: 5811
diff changeset
451 LOG(INFO) << "Advanced Storage - creating attachment \"" << uuid << "\" of type " << static_cast<int>(type) << " (path = " + path.string() + ")";
3f7985dc2df4 fixes in advanced-storage plugin
Alain Mazy <am@orthanc.team>
parents: 5811
diff changeset
452
3f7985dc2df4 fixes in advanced-storage plugin
Alain Mazy <am@orthanc.team>
parents: 5811
diff changeset
453
5081
c673997507ea advanced storage cont
Alain Mazy <am@osimis.io>
parents: 5080
diff changeset
454 if (fs::exists(path.parent_path()))
5080
d7274e43ea7c allow plugins to store a customData in the Attachments table to e.g. store custom paths without requiring an external DB
Alain Mazy <am@osimis.io>
parents:
diff changeset
455 {
5081
c673997507ea advanced storage cont
Alain Mazy <am@osimis.io>
parents: 5080
diff changeset
456 if (!fs::is_directory(path.parent_path()))
5080
d7274e43ea7c allow plugins to store a customData in the Attachments table to e.g. store custom paths without requiring an external DB
Alain Mazy <am@osimis.io>
parents:
diff changeset
457 {
d7274e43ea7c allow plugins to store a customData in the Attachments table to e.g. store custom paths without requiring an external DB
Alain Mazy <am@osimis.io>
parents:
diff changeset
458 throw Orthanc::OrthancException(Orthanc::ErrorCode_DirectoryOverFile);
d7274e43ea7c allow plugins to store a customData in the Attachments table to e.g. store custom paths without requiring an external DB
Alain Mazy <am@osimis.io>
parents:
diff changeset
459 }
d7274e43ea7c allow plugins to store a customData in the Attachments table to e.g. store custom paths without requiring an external DB
Alain Mazy <am@osimis.io>
parents:
diff changeset
460 }
d7274e43ea7c allow plugins to store a customData in the Attachments table to e.g. store custom paths without requiring an external DB
Alain Mazy <am@osimis.io>
parents:
diff changeset
461 else
d7274e43ea7c allow plugins to store a customData in the Attachments table to e.g. store custom paths without requiring an external DB
Alain Mazy <am@osimis.io>
parents:
diff changeset
462 {
5081
c673997507ea advanced storage cont
Alain Mazy <am@osimis.io>
parents: 5080
diff changeset
463 if (!fs::create_directories(path.parent_path()))
5080
d7274e43ea7c allow plugins to store a customData in the Attachments table to e.g. store custom paths without requiring an external DB
Alain Mazy <am@osimis.io>
parents:
diff changeset
464 {
d7274e43ea7c allow plugins to store a customData in the Attachments table to e.g. store custom paths without requiring an external DB
Alain Mazy <am@osimis.io>
parents:
diff changeset
465 throw Orthanc::OrthancException(Orthanc::ErrorCode_FileStorageCannotWrite);
d7274e43ea7c allow plugins to store a customData in the Attachments table to e.g. store custom paths without requiring an external DB
Alain Mazy <am@osimis.io>
parents:
diff changeset
466 }
d7274e43ea7c allow plugins to store a customData in the Attachments table to e.g. store custom paths without requiring an external DB
Alain Mazy <am@osimis.io>
parents:
diff changeset
467 }
d7274e43ea7c allow plugins to store a customData in the Attachments table to e.g. store custom paths without requiring an external DB
Alain Mazy <am@osimis.io>
parents:
diff changeset
468
5081
c673997507ea advanced storage cont
Alain Mazy <am@osimis.io>
parents: 5080
diff changeset
469 Orthanc::SystemToolbox::WriteFile(content, size, path.string(), fsyncOnWrite_);
5080
d7274e43ea7c allow plugins to store a customData in the Attachments table to e.g. store custom paths without requiring an external DB
Alain Mazy <am@osimis.io>
parents:
diff changeset
470
d7274e43ea7c allow plugins to store a customData in the Attachments table to e.g. store custom paths without requiring an external DB
Alain Mazy <am@osimis.io>
parents:
diff changeset
471 OrthancPluginCreateMemoryBuffer(OrthancPlugins::GetGlobalContext(), customData, customDataString.size());
d7274e43ea7c allow plugins to store a customData in the Attachments table to e.g. store custom paths without requiring an external DB
Alain Mazy <am@osimis.io>
parents:
diff changeset
472 memcpy(customData->data, customDataString.data(), customDataString.size());
d7274e43ea7c allow plugins to store a customData in the Attachments table to e.g. store custom paths without requiring an external DB
Alain Mazy <am@osimis.io>
parents:
diff changeset
473
d7274e43ea7c allow plugins to store a customData in the Attachments table to e.g. store custom paths without requiring an external DB
Alain Mazy <am@osimis.io>
parents:
diff changeset
474 return OrthancPluginErrorCode_Success;
d7274e43ea7c allow plugins to store a customData in the Attachments table to e.g. store custom paths without requiring an external DB
Alain Mazy <am@osimis.io>
parents:
diff changeset
475
d7274e43ea7c allow plugins to store a customData in the Attachments table to e.g. store custom paths without requiring an external DB
Alain Mazy <am@osimis.io>
parents:
diff changeset
476 }
d7274e43ea7c allow plugins to store a customData in the Attachments table to e.g. store custom paths without requiring an external DB
Alain Mazy <am@osimis.io>
parents:
diff changeset
477
d7274e43ea7c allow plugins to store a customData in the Attachments table to e.g. store custom paths without requiring an external DB
Alain Mazy <am@osimis.io>
parents:
diff changeset
478 OrthancPluginErrorCode StorageCreateInstance(OrthancPluginMemoryBuffer* customData,
d7274e43ea7c allow plugins to store a customData in the Attachments table to e.g. store custom paths without requiring an external DB
Alain Mazy <am@osimis.io>
parents:
diff changeset
479 const char* uuid,
d7274e43ea7c allow plugins to store a customData in the Attachments table to e.g. store custom paths without requiring an external DB
Alain Mazy <am@osimis.io>
parents:
diff changeset
480 const OrthancPluginDicomInstance* instance,
d7274e43ea7c allow plugins to store a customData in the Attachments table to e.g. store custom paths without requiring an external DB
Alain Mazy <am@osimis.io>
parents:
diff changeset
481 const void* content,
d7274e43ea7c allow plugins to store a customData in the Attachments table to e.g. store custom paths without requiring an external DB
Alain Mazy <am@osimis.io>
parents:
diff changeset
482 int64_t size,
d7274e43ea7c allow plugins to store a customData in the Attachments table to e.g. store custom paths without requiring an external DB
Alain Mazy <am@osimis.io>
parents:
diff changeset
483 OrthancPluginContentType type,
d7274e43ea7c allow plugins to store a customData in the Attachments table to e.g. store custom paths without requiring an external DB
Alain Mazy <am@osimis.io>
parents:
diff changeset
484 bool isCompressed)
d7274e43ea7c allow plugins to store a customData in the Attachments table to e.g. store custom paths without requiring an external DB
Alain Mazy <am@osimis.io>
parents:
diff changeset
485 {
d7274e43ea7c allow plugins to store a customData in the Attachments table to e.g. store custom paths without requiring an external DB
Alain Mazy <am@osimis.io>
parents:
diff changeset
486 try
d7274e43ea7c allow plugins to store a customData in the Attachments table to e.g. store custom paths without requiring an external DB
Alain Mazy <am@osimis.io>
parents:
diff changeset
487 {
d7274e43ea7c allow plugins to store a customData in the Attachments table to e.g. store custom paths without requiring an external DB
Alain Mazy <am@osimis.io>
parents:
diff changeset
488 OrthancPlugins::DicomInstance dicomInstance(instance);
d7274e43ea7c allow plugins to store a customData in the Attachments table to e.g. store custom paths without requiring an external DB
Alain Mazy <am@osimis.io>
parents:
diff changeset
489 Json::Value tags;
d7274e43ea7c allow plugins to store a customData in the Attachments table to e.g. store custom paths without requiring an external DB
Alain Mazy <am@osimis.io>
parents:
diff changeset
490 dicomInstance.GetSimplifiedJson(tags);
d7274e43ea7c allow plugins to store a customData in the Attachments table to e.g. store custom paths without requiring an external DB
Alain Mazy <am@osimis.io>
parents:
diff changeset
491
d7274e43ea7c allow plugins to store a customData in the Attachments table to e.g. store custom paths without requiring an external DB
Alain Mazy <am@osimis.io>
parents:
diff changeset
492 return StorageCreate(customData, uuid, tags, content, size, type, isCompressed);
d7274e43ea7c allow plugins to store a customData in the Attachments table to e.g. store custom paths without requiring an external DB
Alain Mazy <am@osimis.io>
parents:
diff changeset
493 }
d7274e43ea7c allow plugins to store a customData in the Attachments table to e.g. store custom paths without requiring an external DB
Alain Mazy <am@osimis.io>
parents:
diff changeset
494 catch (Orthanc::OrthancException& e)
d7274e43ea7c allow plugins to store a customData in the Attachments table to e.g. store custom paths without requiring an external DB
Alain Mazy <am@osimis.io>
parents:
diff changeset
495 {
d7274e43ea7c allow plugins to store a customData in the Attachments table to e.g. store custom paths without requiring an external DB
Alain Mazy <am@osimis.io>
parents:
diff changeset
496 return static_cast<OrthancPluginErrorCode>(e.GetErrorCode());
d7274e43ea7c allow plugins to store a customData in the Attachments table to e.g. store custom paths without requiring an external DB
Alain Mazy <am@osimis.io>
parents:
diff changeset
497 }
d7274e43ea7c allow plugins to store a customData in the Attachments table to e.g. store custom paths without requiring an external DB
Alain Mazy <am@osimis.io>
parents:
diff changeset
498 catch (...)
d7274e43ea7c allow plugins to store a customData in the Attachments table to e.g. store custom paths without requiring an external DB
Alain Mazy <am@osimis.io>
parents:
diff changeset
499 {
d7274e43ea7c allow plugins to store a customData in the Attachments table to e.g. store custom paths without requiring an external DB
Alain Mazy <am@osimis.io>
parents:
diff changeset
500 return OrthancPluginErrorCode_StorageAreaPlugin;
d7274e43ea7c allow plugins to store a customData in the Attachments table to e.g. store custom paths without requiring an external DB
Alain Mazy <am@osimis.io>
parents:
diff changeset
501 }
d7274e43ea7c allow plugins to store a customData in the Attachments table to e.g. store custom paths without requiring an external DB
Alain Mazy <am@osimis.io>
parents:
diff changeset
502
d7274e43ea7c allow plugins to store a customData in the Attachments table to e.g. store custom paths without requiring an external DB
Alain Mazy <am@osimis.io>
parents:
diff changeset
503 return OrthancPluginErrorCode_Success;
d7274e43ea7c allow plugins to store a customData in the Attachments table to e.g. store custom paths without requiring an external DB
Alain Mazy <am@osimis.io>
parents:
diff changeset
504 }
d7274e43ea7c allow plugins to store a customData in the Attachments table to e.g. store custom paths without requiring an external DB
Alain Mazy <am@osimis.io>
parents:
diff changeset
505
d7274e43ea7c allow plugins to store a customData in the Attachments table to e.g. store custom paths without requiring an external DB
Alain Mazy <am@osimis.io>
parents:
diff changeset
506
d7274e43ea7c allow plugins to store a customData in the Attachments table to e.g. store custom paths without requiring an external DB
Alain Mazy <am@osimis.io>
parents:
diff changeset
507 OrthancPluginErrorCode StorageCreateAttachment(OrthancPluginMemoryBuffer* customData,
d7274e43ea7c allow plugins to store a customData in the Attachments table to e.g. store custom paths without requiring an external DB
Alain Mazy <am@osimis.io>
parents:
diff changeset
508 const char* uuid,
d7274e43ea7c allow plugins to store a customData in the Attachments table to e.g. store custom paths without requiring an external DB
Alain Mazy <am@osimis.io>
parents:
diff changeset
509 const char* resourceId,
d7274e43ea7c allow plugins to store a customData in the Attachments table to e.g. store custom paths without requiring an external DB
Alain Mazy <am@osimis.io>
parents:
diff changeset
510 OrthancPluginResourceType resourceType,
d7274e43ea7c allow plugins to store a customData in the Attachments table to e.g. store custom paths without requiring an external DB
Alain Mazy <am@osimis.io>
parents:
diff changeset
511 const void* content,
d7274e43ea7c allow plugins to store a customData in the Attachments table to e.g. store custom paths without requiring an external DB
Alain Mazy <am@osimis.io>
parents:
diff changeset
512 int64_t size,
d7274e43ea7c allow plugins to store a customData in the Attachments table to e.g. store custom paths without requiring an external DB
Alain Mazy <am@osimis.io>
parents:
diff changeset
513 OrthancPluginContentType type,
d7274e43ea7c allow plugins to store a customData in the Attachments table to e.g. store custom paths without requiring an external DB
Alain Mazy <am@osimis.io>
parents:
diff changeset
514 bool isCompressed)
d7274e43ea7c allow plugins to store a customData in the Attachments table to e.g. store custom paths without requiring an external DB
Alain Mazy <am@osimis.io>
parents:
diff changeset
515 {
d7274e43ea7c allow plugins to store a customData in the Attachments table to e.g. store custom paths without requiring an external DB
Alain Mazy <am@osimis.io>
parents:
diff changeset
516 try
d7274e43ea7c allow plugins to store a customData in the Attachments table to e.g. store custom paths without requiring an external DB
Alain Mazy <am@osimis.io>
parents:
diff changeset
517 {
5807
8279eaab0d1d merged default -> attach-custom-data
Alain Mazy <am@orthanc.team>
parents: 5085
diff changeset
518 LOG(INFO) << "Creating attachment \"" << uuid << "\"";
5080
d7274e43ea7c allow plugins to store a customData in the Attachments table to e.g. store custom paths without requiring an external DB
Alain Mazy <am@osimis.io>
parents:
diff changeset
519
d7274e43ea7c allow plugins to store a customData in the Attachments table to e.g. store custom paths without requiring an external DB
Alain Mazy <am@osimis.io>
parents:
diff changeset
520 //TODO_CUSTOM_DATA: get tags from the Rest API...
d7274e43ea7c allow plugins to store a customData in the Attachments table to e.g. store custom paths without requiring an external DB
Alain Mazy <am@osimis.io>
parents:
diff changeset
521 Json::Value tags;
d7274e43ea7c allow plugins to store a customData in the Attachments table to e.g. store custom paths without requiring an external DB
Alain Mazy <am@osimis.io>
parents:
diff changeset
522
d7274e43ea7c allow plugins to store a customData in the Attachments table to e.g. store custom paths without requiring an external DB
Alain Mazy <am@osimis.io>
parents:
diff changeset
523 return StorageCreate(customData, uuid, tags, content, size, type, isCompressed);
d7274e43ea7c allow plugins to store a customData in the Attachments table to e.g. store custom paths without requiring an external DB
Alain Mazy <am@osimis.io>
parents:
diff changeset
524 }
d7274e43ea7c allow plugins to store a customData in the Attachments table to e.g. store custom paths without requiring an external DB
Alain Mazy <am@osimis.io>
parents:
diff changeset
525 catch (Orthanc::OrthancException& e)
d7274e43ea7c allow plugins to store a customData in the Attachments table to e.g. store custom paths without requiring an external DB
Alain Mazy <am@osimis.io>
parents:
diff changeset
526 {
d7274e43ea7c allow plugins to store a customData in the Attachments table to e.g. store custom paths without requiring an external DB
Alain Mazy <am@osimis.io>
parents:
diff changeset
527 return static_cast<OrthancPluginErrorCode>(e.GetErrorCode());
d7274e43ea7c allow plugins to store a customData in the Attachments table to e.g. store custom paths without requiring an external DB
Alain Mazy <am@osimis.io>
parents:
diff changeset
528 }
d7274e43ea7c allow plugins to store a customData in the Attachments table to e.g. store custom paths without requiring an external DB
Alain Mazy <am@osimis.io>
parents:
diff changeset
529 catch (...)
d7274e43ea7c allow plugins to store a customData in the Attachments table to e.g. store custom paths without requiring an external DB
Alain Mazy <am@osimis.io>
parents:
diff changeset
530 {
d7274e43ea7c allow plugins to store a customData in the Attachments table to e.g. store custom paths without requiring an external DB
Alain Mazy <am@osimis.io>
parents:
diff changeset
531 return OrthancPluginErrorCode_StorageAreaPlugin;
d7274e43ea7c allow plugins to store a customData in the Attachments table to e.g. store custom paths without requiring an external DB
Alain Mazy <am@osimis.io>
parents:
diff changeset
532 }
d7274e43ea7c allow plugins to store a customData in the Attachments table to e.g. store custom paths without requiring an external DB
Alain Mazy <am@osimis.io>
parents:
diff changeset
533
d7274e43ea7c allow plugins to store a customData in the Attachments table to e.g. store custom paths without requiring an external DB
Alain Mazy <am@osimis.io>
parents:
diff changeset
534 return OrthancPluginErrorCode_Success;
d7274e43ea7c allow plugins to store a customData in the Attachments table to e.g. store custom paths without requiring an external DB
Alain Mazy <am@osimis.io>
parents:
diff changeset
535 }
d7274e43ea7c allow plugins to store a customData in the Attachments table to e.g. store custom paths without requiring an external DB
Alain Mazy <am@osimis.io>
parents:
diff changeset
536
d7274e43ea7c allow plugins to store a customData in the Attachments table to e.g. store custom paths without requiring an external DB
Alain Mazy <am@osimis.io>
parents:
diff changeset
537 OrthancPluginErrorCode StorageReadWhole(OrthancPluginMemoryBuffer64* target,
d7274e43ea7c allow plugins to store a customData in the Attachments table to e.g. store custom paths without requiring an external DB
Alain Mazy <am@osimis.io>
parents:
diff changeset
538 const char* uuid,
d7274e43ea7c allow plugins to store a customData in the Attachments table to e.g. store custom paths without requiring an external DB
Alain Mazy <am@osimis.io>
parents:
diff changeset
539 const char* customData,
d7274e43ea7c allow plugins to store a customData in the Attachments table to e.g. store custom paths without requiring an external DB
Alain Mazy <am@osimis.io>
parents:
diff changeset
540 OrthancPluginContentType type)
d7274e43ea7c allow plugins to store a customData in the Attachments table to e.g. store custom paths without requiring an external DB
Alain Mazy <am@osimis.io>
parents:
diff changeset
541 {
5081
c673997507ea advanced storage cont
Alain Mazy <am@osimis.io>
parents: 5080
diff changeset
542 std::string path = GetPath(uuid, customData).string();
5080
d7274e43ea7c allow plugins to store a customData in the Attachments table to e.g. store custom paths without requiring an external DB
Alain Mazy <am@osimis.io>
parents:
diff changeset
543
5081
c673997507ea advanced storage cont
Alain Mazy <am@osimis.io>
parents: 5080
diff changeset
544 LOG(INFO) << "Advanced Storage - Reading whole attachment \"" << uuid << "\" of type " << static_cast<int>(type) << " (path = " + path + ")";
5080
d7274e43ea7c allow plugins to store a customData in the Attachments table to e.g. store custom paths without requiring an external DB
Alain Mazy <am@osimis.io>
parents:
diff changeset
545
d7274e43ea7c allow plugins to store a customData in the Attachments table to e.g. store custom paths without requiring an external DB
Alain Mazy <am@osimis.io>
parents:
diff changeset
546 if (!Orthanc::SystemToolbox::IsRegularFile(path))
d7274e43ea7c allow plugins to store a customData in the Attachments table to e.g. store custom paths without requiring an external DB
Alain Mazy <am@osimis.io>
parents:
diff changeset
547 {
5807
8279eaab0d1d merged default -> attach-custom-data
Alain Mazy <am@orthanc.team>
parents: 5085
diff changeset
548 LOG(ERROR) << "The path does not point to a regular file: " << path;
5080
d7274e43ea7c allow plugins to store a customData in the Attachments table to e.g. store custom paths without requiring an external DB
Alain Mazy <am@osimis.io>
parents:
diff changeset
549 return OrthancPluginErrorCode_InexistentFile;
d7274e43ea7c allow plugins to store a customData in the Attachments table to e.g. store custom paths without requiring an external DB
Alain Mazy <am@osimis.io>
parents:
diff changeset
550 }
d7274e43ea7c allow plugins to store a customData in the Attachments table to e.g. store custom paths without requiring an external DB
Alain Mazy <am@osimis.io>
parents:
diff changeset
551
d7274e43ea7c allow plugins to store a customData in the Attachments table to e.g. store custom paths without requiring an external DB
Alain Mazy <am@osimis.io>
parents:
diff changeset
552 try
d7274e43ea7c allow plugins to store a customData in the Attachments table to e.g. store custom paths without requiring an external DB
Alain Mazy <am@osimis.io>
parents:
diff changeset
553 {
d7274e43ea7c allow plugins to store a customData in the Attachments table to e.g. store custom paths without requiring an external DB
Alain Mazy <am@osimis.io>
parents:
diff changeset
554 fs::ifstream f;
d7274e43ea7c allow plugins to store a customData in the Attachments table to e.g. store custom paths without requiring an external DB
Alain Mazy <am@osimis.io>
parents:
diff changeset
555 f.open(path, std::ifstream::in | std::ifstream::binary);
d7274e43ea7c allow plugins to store a customData in the Attachments table to e.g. store custom paths without requiring an external DB
Alain Mazy <am@osimis.io>
parents:
diff changeset
556 if (!f.good())
d7274e43ea7c allow plugins to store a customData in the Attachments table to e.g. store custom paths without requiring an external DB
Alain Mazy <am@osimis.io>
parents:
diff changeset
557 {
5807
8279eaab0d1d merged default -> attach-custom-data
Alain Mazy <am@orthanc.team>
parents: 5085
diff changeset
558 LOG(ERROR) << "The path does not point to a regular file: " << path;
5080
d7274e43ea7c allow plugins to store a customData in the Attachments table to e.g. store custom paths without requiring an external DB
Alain Mazy <am@osimis.io>
parents:
diff changeset
559 return OrthancPluginErrorCode_InexistentFile;
d7274e43ea7c allow plugins to store a customData in the Attachments table to e.g. store custom paths without requiring an external DB
Alain Mazy <am@osimis.io>
parents:
diff changeset
560 }
d7274e43ea7c allow plugins to store a customData in the Attachments table to e.g. store custom paths without requiring an external DB
Alain Mazy <am@osimis.io>
parents:
diff changeset
561
d7274e43ea7c allow plugins to store a customData in the Attachments table to e.g. store custom paths without requiring an external DB
Alain Mazy <am@osimis.io>
parents:
diff changeset
562 // get file size
d7274e43ea7c allow plugins to store a customData in the Attachments table to e.g. store custom paths without requiring an external DB
Alain Mazy <am@osimis.io>
parents:
diff changeset
563 f.seekg(0, std::ios::end);
d7274e43ea7c allow plugins to store a customData in the Attachments table to e.g. store custom paths without requiring an external DB
Alain Mazy <am@osimis.io>
parents:
diff changeset
564 std::streamsize fileSize = f.tellg();
d7274e43ea7c allow plugins to store a customData in the Attachments table to e.g. store custom paths without requiring an external DB
Alain Mazy <am@osimis.io>
parents:
diff changeset
565 f.seekg(0, std::ios::beg);
d7274e43ea7c allow plugins to store a customData in the Attachments table to e.g. store custom paths without requiring an external DB
Alain Mazy <am@osimis.io>
parents:
diff changeset
566
d7274e43ea7c allow plugins to store a customData in the Attachments table to e.g. store custom paths without requiring an external DB
Alain Mazy <am@osimis.io>
parents:
diff changeset
567 // The ReadWhole must allocate the buffer itself
d7274e43ea7c allow plugins to store a customData in the Attachments table to e.g. store custom paths without requiring an external DB
Alain Mazy <am@osimis.io>
parents:
diff changeset
568 if (OrthancPluginCreateMemoryBuffer64(OrthancPlugins::GetGlobalContext(), target, fileSize) != OrthancPluginErrorCode_Success)
d7274e43ea7c allow plugins to store a customData in the Attachments table to e.g. store custom paths without requiring an external DB
Alain Mazy <am@osimis.io>
parents:
diff changeset
569 {
5807
8279eaab0d1d merged default -> attach-custom-data
Alain Mazy <am@orthanc.team>
parents: 5085
diff changeset
570 LOG(ERROR) << "Unable to allocate memory to read file: " << path;
5080
d7274e43ea7c allow plugins to store a customData in the Attachments table to e.g. store custom paths without requiring an external DB
Alain Mazy <am@osimis.io>
parents:
diff changeset
571 return OrthancPluginErrorCode_NotEnoughMemory;
d7274e43ea7c allow plugins to store a customData in the Attachments table to e.g. store custom paths without requiring an external DB
Alain Mazy <am@osimis.io>
parents:
diff changeset
572 }
d7274e43ea7c allow plugins to store a customData in the Attachments table to e.g. store custom paths without requiring an external DB
Alain Mazy <am@osimis.io>
parents:
diff changeset
573
d7274e43ea7c allow plugins to store a customData in the Attachments table to e.g. store custom paths without requiring an external DB
Alain Mazy <am@osimis.io>
parents:
diff changeset
574 if (fileSize != 0)
d7274e43ea7c allow plugins to store a customData in the Attachments table to e.g. store custom paths without requiring an external DB
Alain Mazy <am@osimis.io>
parents:
diff changeset
575 {
d7274e43ea7c allow plugins to store a customData in the Attachments table to e.g. store custom paths without requiring an external DB
Alain Mazy <am@osimis.io>
parents:
diff changeset
576 f.read(reinterpret_cast<char*>(target->data), fileSize);
d7274e43ea7c allow plugins to store a customData in the Attachments table to e.g. store custom paths without requiring an external DB
Alain Mazy <am@osimis.io>
parents:
diff changeset
577 }
d7274e43ea7c allow plugins to store a customData in the Attachments table to e.g. store custom paths without requiring an external DB
Alain Mazy <am@osimis.io>
parents:
diff changeset
578
d7274e43ea7c allow plugins to store a customData in the Attachments table to e.g. store custom paths without requiring an external DB
Alain Mazy <am@osimis.io>
parents:
diff changeset
579 f.close();
d7274e43ea7c allow plugins to store a customData in the Attachments table to e.g. store custom paths without requiring an external DB
Alain Mazy <am@osimis.io>
parents:
diff changeset
580 }
d7274e43ea7c allow plugins to store a customData in the Attachments table to e.g. store custom paths without requiring an external DB
Alain Mazy <am@osimis.io>
parents:
diff changeset
581 catch (...)
d7274e43ea7c allow plugins to store a customData in the Attachments table to e.g. store custom paths without requiring an external DB
Alain Mazy <am@osimis.io>
parents:
diff changeset
582 {
5807
8279eaab0d1d merged default -> attach-custom-data
Alain Mazy <am@orthanc.team>
parents: 5085
diff changeset
583 LOG(ERROR) << "Unexpected error while reading: " << path;
5080
d7274e43ea7c allow plugins to store a customData in the Attachments table to e.g. store custom paths without requiring an external DB
Alain Mazy <am@osimis.io>
parents:
diff changeset
584 return OrthancPluginErrorCode_StorageAreaPlugin;
d7274e43ea7c allow plugins to store a customData in the Attachments table to e.g. store custom paths without requiring an external DB
Alain Mazy <am@osimis.io>
parents:
diff changeset
585 }
d7274e43ea7c allow plugins to store a customData in the Attachments table to e.g. store custom paths without requiring an external DB
Alain Mazy <am@osimis.io>
parents:
diff changeset
586
d7274e43ea7c allow plugins to store a customData in the Attachments table to e.g. store custom paths without requiring an external DB
Alain Mazy <am@osimis.io>
parents:
diff changeset
587 return OrthancPluginErrorCode_Success;
d7274e43ea7c allow plugins to store a customData in the Attachments table to e.g. store custom paths without requiring an external DB
Alain Mazy <am@osimis.io>
parents:
diff changeset
588 }
d7274e43ea7c allow plugins to store a customData in the Attachments table to e.g. store custom paths without requiring an external DB
Alain Mazy <am@osimis.io>
parents:
diff changeset
589
d7274e43ea7c allow plugins to store a customData in the Attachments table to e.g. store custom paths without requiring an external DB
Alain Mazy <am@osimis.io>
parents:
diff changeset
590
d7274e43ea7c allow plugins to store a customData in the Attachments table to e.g. store custom paths without requiring an external DB
Alain Mazy <am@osimis.io>
parents:
diff changeset
591 OrthancPluginErrorCode StorageReadRange (OrthancPluginMemoryBuffer64* target,
d7274e43ea7c allow plugins to store a customData in the Attachments table to e.g. store custom paths without requiring an external DB
Alain Mazy <am@osimis.io>
parents:
diff changeset
592 const char* uuid,
d7274e43ea7c allow plugins to store a customData in the Attachments table to e.g. store custom paths without requiring an external DB
Alain Mazy <am@osimis.io>
parents:
diff changeset
593 const char* customData,
d7274e43ea7c allow plugins to store a customData in the Attachments table to e.g. store custom paths without requiring an external DB
Alain Mazy <am@osimis.io>
parents:
diff changeset
594 OrthancPluginContentType type,
d7274e43ea7c allow plugins to store a customData in the Attachments table to e.g. store custom paths without requiring an external DB
Alain Mazy <am@osimis.io>
parents:
diff changeset
595 uint64_t rangeStart)
d7274e43ea7c allow plugins to store a customData in the Attachments table to e.g. store custom paths without requiring an external DB
Alain Mazy <am@osimis.io>
parents:
diff changeset
596 {
5081
c673997507ea advanced storage cont
Alain Mazy <am@osimis.io>
parents: 5080
diff changeset
597 std::string path = GetPath(uuid, customData).string();
5080
d7274e43ea7c allow plugins to store a customData in the Attachments table to e.g. store custom paths without requiring an external DB
Alain Mazy <am@osimis.io>
parents:
diff changeset
598
5081
c673997507ea advanced storage cont
Alain Mazy <am@osimis.io>
parents: 5080
diff changeset
599 LOG(INFO) << "Advanced Storage - Reading range of attachment \"" << uuid << "\" of type " << static_cast<int>(type) << " (path = " + path + ")";
5080
d7274e43ea7c allow plugins to store a customData in the Attachments table to e.g. store custom paths without requiring an external DB
Alain Mazy <am@osimis.io>
parents:
diff changeset
600
d7274e43ea7c allow plugins to store a customData in the Attachments table to e.g. store custom paths without requiring an external DB
Alain Mazy <am@osimis.io>
parents:
diff changeset
601 if (!Orthanc::SystemToolbox::IsRegularFile(path))
d7274e43ea7c allow plugins to store a customData in the Attachments table to e.g. store custom paths without requiring an external DB
Alain Mazy <am@osimis.io>
parents:
diff changeset
602 {
5807
8279eaab0d1d merged default -> attach-custom-data
Alain Mazy <am@orthanc.team>
parents: 5085
diff changeset
603 LOG(ERROR) << "The path does not point to a regular file: " << path;
5080
d7274e43ea7c allow plugins to store a customData in the Attachments table to e.g. store custom paths without requiring an external DB
Alain Mazy <am@osimis.io>
parents:
diff changeset
604 return OrthancPluginErrorCode_InexistentFile;
d7274e43ea7c allow plugins to store a customData in the Attachments table to e.g. store custom paths without requiring an external DB
Alain Mazy <am@osimis.io>
parents:
diff changeset
605 }
d7274e43ea7c allow plugins to store a customData in the Attachments table to e.g. store custom paths without requiring an external DB
Alain Mazy <am@osimis.io>
parents:
diff changeset
606
d7274e43ea7c allow plugins to store a customData in the Attachments table to e.g. store custom paths without requiring an external DB
Alain Mazy <am@osimis.io>
parents:
diff changeset
607 try
d7274e43ea7c allow plugins to store a customData in the Attachments table to e.g. store custom paths without requiring an external DB
Alain Mazy <am@osimis.io>
parents:
diff changeset
608 {
d7274e43ea7c allow plugins to store a customData in the Attachments table to e.g. store custom paths without requiring an external DB
Alain Mazy <am@osimis.io>
parents:
diff changeset
609 fs::ifstream f;
d7274e43ea7c allow plugins to store a customData in the Attachments table to e.g. store custom paths without requiring an external DB
Alain Mazy <am@osimis.io>
parents:
diff changeset
610 f.open(path, std::ifstream::in | std::ifstream::binary);
d7274e43ea7c allow plugins to store a customData in the Attachments table to e.g. store custom paths without requiring an external DB
Alain Mazy <am@osimis.io>
parents:
diff changeset
611 if (!f.good())
d7274e43ea7c allow plugins to store a customData in the Attachments table to e.g. store custom paths without requiring an external DB
Alain Mazy <am@osimis.io>
parents:
diff changeset
612 {
5807
8279eaab0d1d merged default -> attach-custom-data
Alain Mazy <am@orthanc.team>
parents: 5085
diff changeset
613 LOG(ERROR) << "The path does not point to a regular file: " << path;
5080
d7274e43ea7c allow plugins to store a customData in the Attachments table to e.g. store custom paths without requiring an external DB
Alain Mazy <am@osimis.io>
parents:
diff changeset
614 return OrthancPluginErrorCode_InexistentFile;
d7274e43ea7c allow plugins to store a customData in the Attachments table to e.g. store custom paths without requiring an external DB
Alain Mazy <am@osimis.io>
parents:
diff changeset
615 }
d7274e43ea7c allow plugins to store a customData in the Attachments table to e.g. store custom paths without requiring an external DB
Alain Mazy <am@osimis.io>
parents:
diff changeset
616
d7274e43ea7c allow plugins to store a customData in the Attachments table to e.g. store custom paths without requiring an external DB
Alain Mazy <am@osimis.io>
parents:
diff changeset
617 f.seekg(rangeStart, std::ios::beg);
d7274e43ea7c allow plugins to store a customData in the Attachments table to e.g. store custom paths without requiring an external DB
Alain Mazy <am@osimis.io>
parents:
diff changeset
618
d7274e43ea7c allow plugins to store a customData in the Attachments table to e.g. store custom paths without requiring an external DB
Alain Mazy <am@osimis.io>
parents:
diff changeset
619 // The ReadRange uses a target that has already been allocated by orthanc
d7274e43ea7c allow plugins to store a customData in the Attachments table to e.g. store custom paths without requiring an external DB
Alain Mazy <am@osimis.io>
parents:
diff changeset
620 f.read(reinterpret_cast<char*>(target->data), target->size);
d7274e43ea7c allow plugins to store a customData in the Attachments table to e.g. store custom paths without requiring an external DB
Alain Mazy <am@osimis.io>
parents:
diff changeset
621
d7274e43ea7c allow plugins to store a customData in the Attachments table to e.g. store custom paths without requiring an external DB
Alain Mazy <am@osimis.io>
parents:
diff changeset
622 f.close();
d7274e43ea7c allow plugins to store a customData in the Attachments table to e.g. store custom paths without requiring an external DB
Alain Mazy <am@osimis.io>
parents:
diff changeset
623 }
d7274e43ea7c allow plugins to store a customData in the Attachments table to e.g. store custom paths without requiring an external DB
Alain Mazy <am@osimis.io>
parents:
diff changeset
624 catch (...)
d7274e43ea7c allow plugins to store a customData in the Attachments table to e.g. store custom paths without requiring an external DB
Alain Mazy <am@osimis.io>
parents:
diff changeset
625 {
5807
8279eaab0d1d merged default -> attach-custom-data
Alain Mazy <am@orthanc.team>
parents: 5085
diff changeset
626 LOG(ERROR) << "Unexpected error while reading: " << path;
5080
d7274e43ea7c allow plugins to store a customData in the Attachments table to e.g. store custom paths without requiring an external DB
Alain Mazy <am@osimis.io>
parents:
diff changeset
627 return OrthancPluginErrorCode_StorageAreaPlugin;
d7274e43ea7c allow plugins to store a customData in the Attachments table to e.g. store custom paths without requiring an external DB
Alain Mazy <am@osimis.io>
parents:
diff changeset
628 }
d7274e43ea7c allow plugins to store a customData in the Attachments table to e.g. store custom paths without requiring an external DB
Alain Mazy <am@osimis.io>
parents:
diff changeset
629
d7274e43ea7c allow plugins to store a customData in the Attachments table to e.g. store custom paths without requiring an external DB
Alain Mazy <am@osimis.io>
parents:
diff changeset
630 return OrthancPluginErrorCode_Success;
d7274e43ea7c allow plugins to store a customData in the Attachments table to e.g. store custom paths without requiring an external DB
Alain Mazy <am@osimis.io>
parents:
diff changeset
631 }
d7274e43ea7c allow plugins to store a customData in the Attachments table to e.g. store custom paths without requiring an external DB
Alain Mazy <am@osimis.io>
parents:
diff changeset
632
d7274e43ea7c allow plugins to store a customData in the Attachments table to e.g. store custom paths without requiring an external DB
Alain Mazy <am@osimis.io>
parents:
diff changeset
633
d7274e43ea7c allow plugins to store a customData in the Attachments table to e.g. store custom paths without requiring an external DB
Alain Mazy <am@osimis.io>
parents:
diff changeset
634 OrthancPluginErrorCode StorageRemove (const char* uuid,
d7274e43ea7c allow plugins to store a customData in the Attachments table to e.g. store custom paths without requiring an external DB
Alain Mazy <am@osimis.io>
parents:
diff changeset
635 const char* customData,
d7274e43ea7c allow plugins to store a customData in the Attachments table to e.g. store custom paths without requiring an external DB
Alain Mazy <am@osimis.io>
parents:
diff changeset
636 OrthancPluginContentType type)
d7274e43ea7c allow plugins to store a customData in the Attachments table to e.g. store custom paths without requiring an external DB
Alain Mazy <am@osimis.io>
parents:
diff changeset
637 {
5081
c673997507ea advanced storage cont
Alain Mazy <am@osimis.io>
parents: 5080
diff changeset
638 fs::path path = GetPath(uuid, customData);
5080
d7274e43ea7c allow plugins to store a customData in the Attachments table to e.g. store custom paths without requiring an external DB
Alain Mazy <am@osimis.io>
parents:
diff changeset
639
5081
c673997507ea advanced storage cont
Alain Mazy <am@osimis.io>
parents: 5080
diff changeset
640 LOG(INFO) << "Advanced Storage - Deleting attachment \"" << uuid << "\" of type " << static_cast<int>(type) << " (path = " + path.string() + ")";
5080
d7274e43ea7c allow plugins to store a customData in the Attachments table to e.g. store custom paths without requiring an external DB
Alain Mazy <am@osimis.io>
parents:
diff changeset
641
d7274e43ea7c allow plugins to store a customData in the Attachments table to e.g. store custom paths without requiring an external DB
Alain Mazy <am@osimis.io>
parents:
diff changeset
642 try
d7274e43ea7c allow plugins to store a customData in the Attachments table to e.g. store custom paths without requiring an external DB
Alain Mazy <am@osimis.io>
parents:
diff changeset
643 {
5081
c673997507ea advanced storage cont
Alain Mazy <am@osimis.io>
parents: 5080
diff changeset
644 fs::remove(path);
5080
d7274e43ea7c allow plugins to store a customData in the Attachments table to e.g. store custom paths without requiring an external DB
Alain Mazy <am@osimis.io>
parents:
diff changeset
645 }
d7274e43ea7c allow plugins to store a customData in the Attachments table to e.g. store custom paths without requiring an external DB
Alain Mazy <am@osimis.io>
parents:
diff changeset
646 catch (...)
d7274e43ea7c allow plugins to store a customData in the Attachments table to e.g. store custom paths without requiring an external DB
Alain Mazy <am@osimis.io>
parents:
diff changeset
647 {
d7274e43ea7c allow plugins to store a customData in the Attachments table to e.g. store custom paths without requiring an external DB
Alain Mazy <am@osimis.io>
parents:
diff changeset
648 // Ignore the error
d7274e43ea7c allow plugins to store a customData in the Attachments table to e.g. store custom paths without requiring an external DB
Alain Mazy <am@osimis.io>
parents:
diff changeset
649 }
d7274e43ea7c allow plugins to store a customData in the Attachments table to e.g. store custom paths without requiring an external DB
Alain Mazy <am@osimis.io>
parents:
diff changeset
650
d7274e43ea7c allow plugins to store a customData in the Attachments table to e.g. store custom paths without requiring an external DB
Alain Mazy <am@osimis.io>
parents:
diff changeset
651 // Remove the empty parent directories, (ignoring the error code if these directories are not empty)
d7274e43ea7c allow plugins to store a customData in the Attachments table to e.g. store custom paths without requiring an external DB
Alain Mazy <am@osimis.io>
parents:
diff changeset
652
d7274e43ea7c allow plugins to store a customData in the Attachments table to e.g. store custom paths without requiring an external DB
Alain Mazy <am@osimis.io>
parents:
diff changeset
653 try
d7274e43ea7c allow plugins to store a customData in the Attachments table to e.g. store custom paths without requiring an external DB
Alain Mazy <am@osimis.io>
parents:
diff changeset
654 {
5081
c673997507ea advanced storage cont
Alain Mazy <am@osimis.io>
parents: 5080
diff changeset
655 fs::path parent = path.parent_path();
5080
d7274e43ea7c allow plugins to store a customData in the Attachments table to e.g. store custom paths without requiring an external DB
Alain Mazy <am@osimis.io>
parents:
diff changeset
656
5081
c673997507ea advanced storage cont
Alain Mazy <am@osimis.io>
parents: 5080
diff changeset
657 while (parent != GetRootPath())
5080
d7274e43ea7c allow plugins to store a customData in the Attachments table to e.g. store custom paths without requiring an external DB
Alain Mazy <am@osimis.io>
parents:
diff changeset
658 {
d7274e43ea7c allow plugins to store a customData in the Attachments table to e.g. store custom paths without requiring an external DB
Alain Mazy <am@osimis.io>
parents:
diff changeset
659 fs::remove(parent);
d7274e43ea7c allow plugins to store a customData in the Attachments table to e.g. store custom paths without requiring an external DB
Alain Mazy <am@osimis.io>
parents:
diff changeset
660 parent = parent.parent_path();
d7274e43ea7c allow plugins to store a customData in the Attachments table to e.g. store custom paths without requiring an external DB
Alain Mazy <am@osimis.io>
parents:
diff changeset
661 }
d7274e43ea7c allow plugins to store a customData in the Attachments table to e.g. store custom paths without requiring an external DB
Alain Mazy <am@osimis.io>
parents:
diff changeset
662 }
d7274e43ea7c allow plugins to store a customData in the Attachments table to e.g. store custom paths without requiring an external DB
Alain Mazy <am@osimis.io>
parents:
diff changeset
663 catch (...)
d7274e43ea7c allow plugins to store a customData in the Attachments table to e.g. store custom paths without requiring an external DB
Alain Mazy <am@osimis.io>
parents:
diff changeset
664 {
d7274e43ea7c allow plugins to store a customData in the Attachments table to e.g. store custom paths without requiring an external DB
Alain Mazy <am@osimis.io>
parents:
diff changeset
665 // Ignore the error
d7274e43ea7c allow plugins to store a customData in the Attachments table to e.g. store custom paths without requiring an external DB
Alain Mazy <am@osimis.io>
parents:
diff changeset
666 }
d7274e43ea7c allow plugins to store a customData in the Attachments table to e.g. store custom paths without requiring an external DB
Alain Mazy <am@osimis.io>
parents:
diff changeset
667
d7274e43ea7c allow plugins to store a customData in the Attachments table to e.g. store custom paths without requiring an external DB
Alain Mazy <am@osimis.io>
parents:
diff changeset
668 return OrthancPluginErrorCode_Success;
d7274e43ea7c allow plugins to store a customData in the Attachments table to e.g. store custom paths without requiring an external DB
Alain Mazy <am@osimis.io>
parents:
diff changeset
669 }
d7274e43ea7c allow plugins to store a customData in the Attachments table to e.g. store custom paths without requiring an external DB
Alain Mazy <am@osimis.io>
parents:
diff changeset
670
d7274e43ea7c allow plugins to store a customData in the Attachments table to e.g. store custom paths without requiring an external DB
Alain Mazy <am@osimis.io>
parents:
diff changeset
671 extern "C"
d7274e43ea7c allow plugins to store a customData in the Attachments table to e.g. store custom paths without requiring an external DB
Alain Mazy <am@osimis.io>
parents:
diff changeset
672 {
d7274e43ea7c allow plugins to store a customData in the Attachments table to e.g. store custom paths without requiring an external DB
Alain Mazy <am@osimis.io>
parents:
diff changeset
673
d7274e43ea7c allow plugins to store a customData in the Attachments table to e.g. store custom paths without requiring an external DB
Alain Mazy <am@osimis.io>
parents:
diff changeset
674 ORTHANC_PLUGINS_API int32_t OrthancPluginInitialize(OrthancPluginContext* context)
d7274e43ea7c allow plugins to store a customData in the Attachments table to e.g. store custom paths without requiring an external DB
Alain Mazy <am@osimis.io>
parents:
diff changeset
675 {
d7274e43ea7c allow plugins to store a customData in the Attachments table to e.g. store custom paths without requiring an external DB
Alain Mazy <am@osimis.io>
parents:
diff changeset
676 OrthancPlugins::SetGlobalContext(context);
d7274e43ea7c allow plugins to store a customData in the Attachments table to e.g. store custom paths without requiring an external DB
Alain Mazy <am@osimis.io>
parents:
diff changeset
677 Orthanc::Logging::InitializePluginContext(context);
d7274e43ea7c allow plugins to store a customData in the Attachments table to e.g. store custom paths without requiring an external DB
Alain Mazy <am@osimis.io>
parents:
diff changeset
678
d7274e43ea7c allow plugins to store a customData in the Attachments table to e.g. store custom paths without requiring an external DB
Alain Mazy <am@osimis.io>
parents:
diff changeset
679 /* Check the version of the Orthanc core */
d7274e43ea7c allow plugins to store a customData in the Attachments table to e.g. store custom paths without requiring an external DB
Alain Mazy <am@osimis.io>
parents:
diff changeset
680 if (OrthancPluginCheckVersion(context) == 0)
d7274e43ea7c allow plugins to store a customData in the Attachments table to e.g. store custom paths without requiring an external DB
Alain Mazy <am@osimis.io>
parents:
diff changeset
681 {
d7274e43ea7c allow plugins to store a customData in the Attachments table to e.g. store custom paths without requiring an external DB
Alain Mazy <am@osimis.io>
parents:
diff changeset
682 OrthancPlugins::ReportMinimalOrthancVersion(ORTHANC_PLUGINS_MINIMAL_MAJOR_NUMBER,
d7274e43ea7c allow plugins to store a customData in the Attachments table to e.g. store custom paths without requiring an external DB
Alain Mazy <am@osimis.io>
parents:
diff changeset
683 ORTHANC_PLUGINS_MINIMAL_MINOR_NUMBER,
d7274e43ea7c allow plugins to store a customData in the Attachments table to e.g. store custom paths without requiring an external DB
Alain Mazy <am@osimis.io>
parents:
diff changeset
684 ORTHANC_PLUGINS_MINIMAL_REVISION_NUMBER);
d7274e43ea7c allow plugins to store a customData in the Attachments table to e.g. store custom paths without requiring an external DB
Alain Mazy <am@osimis.io>
parents:
diff changeset
685 return -1;
d7274e43ea7c allow plugins to store a customData in the Attachments table to e.g. store custom paths without requiring an external DB
Alain Mazy <am@osimis.io>
parents:
diff changeset
686 }
d7274e43ea7c allow plugins to store a customData in the Attachments table to e.g. store custom paths without requiring an external DB
Alain Mazy <am@osimis.io>
parents:
diff changeset
687
5807
8279eaab0d1d merged default -> attach-custom-data
Alain Mazy <am@orthanc.team>
parents: 5085
diff changeset
688 LOG(WARNING) << "AdvancedStorage plugin is initializing";
8279eaab0d1d merged default -> attach-custom-data
Alain Mazy <am@orthanc.team>
parents: 5085
diff changeset
689 OrthancPluginSetDescription2(context, ORTHANC_PLUGIN_NAME, "Provides alternative layout for your storage.");
5080
d7274e43ea7c allow plugins to store a customData in the Attachments table to e.g. store custom paths without requiring an external DB
Alain Mazy <am@osimis.io>
parents:
diff changeset
690
d7274e43ea7c allow plugins to store a customData in the Attachments table to e.g. store custom paths without requiring an external DB
Alain Mazy <am@osimis.io>
parents:
diff changeset
691 OrthancPlugins::OrthancConfiguration orthancConfiguration;
d7274e43ea7c allow plugins to store a customData in the Attachments table to e.g. store custom paths without requiring an external DB
Alain Mazy <am@osimis.io>
parents:
diff changeset
692
d7274e43ea7c allow plugins to store a customData in the Attachments table to e.g. store custom paths without requiring an external DB
Alain Mazy <am@osimis.io>
parents:
diff changeset
693 OrthancPlugins::OrthancConfiguration advancedStorage;
d7274e43ea7c allow plugins to store a customData in the Attachments table to e.g. store custom paths without requiring an external DB
Alain Mazy <am@osimis.io>
parents:
diff changeset
694 orthancConfiguration.GetSection(advancedStorage, "AdvancedStorage");
d7274e43ea7c allow plugins to store a customData in the Attachments table to e.g. store custom paths without requiring an external DB
Alain Mazy <am@osimis.io>
parents:
diff changeset
695
d7274e43ea7c allow plugins to store a customData in the Attachments table to e.g. store custom paths without requiring an external DB
Alain Mazy <am@osimis.io>
parents:
diff changeset
696 bool enabled = advancedStorage.GetBooleanValue("Enable", false);
d7274e43ea7c allow plugins to store a customData in the Attachments table to e.g. store custom paths without requiring an external DB
Alain Mazy <am@osimis.io>
parents:
diff changeset
697 if (enabled)
d7274e43ea7c allow plugins to store a customData in the Attachments table to e.g. store custom paths without requiring an external DB
Alain Mazy <am@osimis.io>
parents:
diff changeset
698 {
d7274e43ea7c allow plugins to store a customData in the Attachments table to e.g. store custom paths without requiring an external DB
Alain Mazy <am@osimis.io>
parents:
diff changeset
699 /*
d7274e43ea7c allow plugins to store a customData in the Attachments table to e.g. store custom paths without requiring an external DB
Alain Mazy <am@osimis.io>
parents:
diff changeset
700 {
d7274e43ea7c allow plugins to store a customData in the Attachments table to e.g. store custom paths without requiring an external DB
Alain Mazy <am@osimis.io>
parents:
diff changeset
701 "AdvancedStorage": {
d7274e43ea7c allow plugins to store a customData in the Attachments table to e.g. store custom paths without requiring an external DB
Alain Mazy <am@osimis.io>
parents:
diff changeset
702
d7274e43ea7c allow plugins to store a customData in the Attachments table to e.g. store custom paths without requiring an external DB
Alain Mazy <am@osimis.io>
parents:
diff changeset
703 // Enables/disables the plugin
d7274e43ea7c allow plugins to store a customData in the Attachments table to e.g. store custom paths without requiring an external DB
Alain Mazy <am@osimis.io>
parents:
diff changeset
704 "Enable": false,
5081
c673997507ea advanced storage cont
Alain Mazy <am@osimis.io>
parents: 5080
diff changeset
705
5824
Alain Mazy <am@orthanc.team>
parents: 5823
diff changeset
706 // Enables/disables support for multiple StorageDirectories (disabled by default)
5823
a856763e5736 fix SDK for custom-data in attachments
Alain Mazy <am@orthanc.team>
parents: 5812
diff changeset
707 // Note: when saving a file, the plugin stores only the storage-id in the SQL DB
5081
c673997507ea advanced storage cont
Alain Mazy <am@osimis.io>
parents: 5080
diff changeset
708 "MultipleStorages" : {
c673997507ea advanced storage cont
Alain Mazy <am@osimis.io>
parents: 5080
diff changeset
709 "Storages" : {
5823
a856763e5736 fix SDK for custom-data in attachments
Alain Mazy <am@orthanc.team>
parents: 5812
diff changeset
710 // Therefore, storage path may change in case you move your data from one place to another.
a856763e5736 fix SDK for custom-data in attachments
Alain Mazy <am@orthanc.team>
parents: 5812
diff changeset
711 // The storgae ids may never change since they are stored in DB; you can only add new ones.
5081
c673997507ea advanced storage cont
Alain Mazy <am@osimis.io>
parents: 5080
diff changeset
712 "1" : "/var/lib/orthanc/db",
c673997507ea advanced storage cont
Alain Mazy <am@osimis.io>
parents: 5080
diff changeset
713 "2" : "/mnt/disk2/orthanc"
c673997507ea advanced storage cont
Alain Mazy <am@osimis.io>
parents: 5080
diff changeset
714 },
c673997507ea advanced storage cont
Alain Mazy <am@osimis.io>
parents: 5080
diff changeset
715
5823
a856763e5736 fix SDK for custom-data in attachments
Alain Mazy <am@orthanc.team>
parents: 5812
diff changeset
716 // The storage on which new data is stored.
5081
c673997507ea advanced storage cont
Alain Mazy <am@osimis.io>
parents: 5080
diff changeset
717 // There's currently no automatic changes of disks
c673997507ea advanced storage cont
Alain Mazy <am@osimis.io>
parents: 5080
diff changeset
718 "CurrentStorage" : "2",
c673997507ea advanced storage cont
Alain Mazy <am@osimis.io>
parents: 5080
diff changeset
719 },
c673997507ea advanced storage cont
Alain Mazy <am@osimis.io>
parents: 5080
diff changeset
720
5812
3f7985dc2df4 fixes in advanced-storage plugin
Alain Mazy <am@orthanc.team>
parents: 5811
diff changeset
721 // Defines the storage structure and file namings.
3f7985dc2df4 fixes in advanced-storage plugin
Alain Mazy <am@orthanc.team>
parents: 5811
diff changeset
722 // These keywords can be used to generate the path:
3f7985dc2df4 fixes in advanced-storage plugin
Alain Mazy <am@orthanc.team>
parents: 5811
diff changeset
723 // Attachment info:
3f7985dc2df4 fixes in advanced-storage plugin
Alain Mazy <am@orthanc.team>
parents: 5811
diff changeset
724 // {UUID} : A unique file identifier
3f7985dc2df4 fixes in advanced-storage plugin
Alain Mazy <am@orthanc.team>
parents: 5811
diff changeset
725 // {01(UUID)} : The first 2 characters of the file UUID
3f7985dc2df4 fixes in advanced-storage plugin
Alain Mazy <am@orthanc.team>
parents: 5811
diff changeset
726 // {23(UUID)} : The 3rd and 4th characters of the file UUID
3f7985dc2df4 fixes in advanced-storage plugin
Alain Mazy <am@orthanc.team>
parents: 5811
diff changeset
727 // {.ext} : The file extension
3f7985dc2df4 fixes in advanced-storage plugin
Alain Mazy <am@orthanc.team>
parents: 5811
diff changeset
728 // DICOM TAGS:
3f7985dc2df4 fixes in advanced-storage plugin
Alain Mazy <am@orthanc.team>
parents: 5811
diff changeset
729 // {PatientID}, {PatientName}, {PatientBirthDate}
3f7985dc2df4 fixes in advanced-storage plugin
Alain Mazy <am@orthanc.team>
parents: 5811
diff changeset
730 // {StudyInstanceUID}, {SeriesInstanceUID}, {SOPInstanceUID}
3f7985dc2df4 fixes in advanced-storage plugin
Alain Mazy <am@orthanc.team>
parents: 5811
diff changeset
731 // {StudyDescription}, {SeriesDescription}
3f7985dc2df4 fixes in advanced-storage plugin
Alain Mazy <am@orthanc.team>
parents: 5811
diff changeset
732 // {StudyDate}, {AccessionNumber}, {InstanceNumber}, {SeriesNumber}
3f7985dc2df4 fixes in advanced-storage plugin
Alain Mazy <am@orthanc.team>
parents: 5811
diff changeset
733 // Transformed DICOM TAGS:
3f7985dc2df4 fixes in advanced-storage plugin
Alain Mazy <am@orthanc.team>
parents: 5811
diff changeset
734 // {split(StudyDate)} : 3 subfolders: YYYY/MM/DD
3f7985dc2df4 fixes in advanced-storage plugin
Alain Mazy <am@orthanc.team>
parents: 5811
diff changeset
735 // {split(PatientBirthDate)} : 3 subfolders: YYYY/MM/DD
3f7985dc2df4 fixes in advanced-storage plugin
Alain Mazy <am@orthanc.team>
parents: 5811
diff changeset
736 // {pad4(InstanceNumber)} : the instance number padded with zeroes to have 4 characters
3f7985dc2df4 fixes in advanced-storage plugin
Alain Mazy <am@orthanc.team>
parents: 5811
diff changeset
737 // {pad4(SeriesNumber)} : the instance number padded with zeroes to have 4 characters
3f7985dc2df4 fixes in advanced-storage plugin
Alain Mazy <am@orthanc.team>
parents: 5811
diff changeset
738 // {pad6(InstanceNumber)} : the instance number padded with zeroes to have 6 characters
3f7985dc2df4 fixes in advanced-storage plugin
Alain Mazy <am@orthanc.team>
parents: 5811
diff changeset
739 // {pad6(SeriesNumber)} : the instance number padded with zeroes to have 6 characters
3f7985dc2df4 fixes in advanced-storage plugin
Alain Mazy <am@orthanc.team>
parents: 5811
diff changeset
740 // {pad8(InstanceNumber)} : the instance number padded with zeroes to have 8 characters
3f7985dc2df4 fixes in advanced-storage plugin
Alain Mazy <am@orthanc.team>
parents: 5811
diff changeset
741 // {pad8(SeriesNumber)} : the instance number padded with zeroes to have 8 characters
3f7985dc2df4 fixes in advanced-storage plugin
Alain Mazy <am@orthanc.team>
parents: 5811
diff changeset
742 // Orthanc IDs:
3f7985dc2df4 fixes in advanced-storage plugin
Alain Mazy <am@orthanc.team>
parents: 5811
diff changeset
743 // {OrthancPatientID}, {OrthancStudyID}, {OrthancSeriesID}, {OrthancInstanceID}
3f7985dc2df4 fixes in advanced-storage plugin
Alain Mazy <am@orthanc.team>
parents: 5811
diff changeset
744 // Transformed Orthanc IDs:
3f7985dc2df4 fixes in advanced-storage plugin
Alain Mazy <am@orthanc.team>
parents: 5811
diff changeset
745 // {01(OrthancPatientID)}, {01(OrthancStudyID)}, ... : the first 2 characters of the Orthanc ID
3f7985dc2df4 fixes in advanced-storage plugin
Alain Mazy <am@orthanc.team>
parents: 5811
diff changeset
746 // {23(OrthancPatientID)}, {23(OrthancStudyID)}, ... : the 3rd and 4th characters of the Orthanc ID
3f7985dc2df4 fixes in advanced-storage plugin
Alain Mazy <am@orthanc.team>
parents: 5811
diff changeset
747 // Examples:
3f7985dc2df4 fixes in advanced-storage plugin
Alain Mazy <am@orthanc.team>
parents: 5811
diff changeset
748 // "OrthancDefault" is a special value to use the same structure as the Orthanc core.
3f7985dc2df4 fixes in advanced-storage plugin
Alain Mazy <am@orthanc.team>
parents: 5811
diff changeset
749 // This option consumes less space in the SQL DB since the path must not be saved in DB.
3f7985dc2df4 fixes in advanced-storage plugin
Alain Mazy <am@orthanc.team>
parents: 5811
diff changeset
750 // "{01(UUID)}/{23(UUID)}/{UUID}{.ext}" is equivalent with the structure of the Orthanc core with and added file extension
3f7985dc2df4 fixes in advanced-storage plugin
Alain Mazy <am@orthanc.team>
parents: 5811
diff changeset
751 // "{split(StudyDate)}/{StudyInstanceUID} - {PatientID}/{SeriesInstanceUID}/{pad6(InstanceNumber)} - {UUID}{.ext}"
3f7985dc2df4 fixes in advanced-storage plugin
Alain Mazy <am@orthanc.team>
parents: 5811
diff changeset
752 // "{PatientID} - {PatientName}/{StudyDate} - {StudyInstanceUID} - {StudyDescription}/{SeriesInstanceUID}/{UUID}{.ext}"
3f7985dc2df4 fixes in advanced-storage plugin
Alain Mazy <am@orthanc.team>
parents: 5811
diff changeset
753 // Notes:
3f7985dc2df4 fixes in advanced-storage plugin
Alain Mazy <am@orthanc.team>
parents: 5811
diff changeset
754 // - To prevent files from being overwritten, it is very important that their path is unique !
3f7985dc2df4 fixes in advanced-storage plugin
Alain Mazy <am@orthanc.team>
parents: 5811
diff changeset
755 // Therefore, your NamingScheme must always include:
3f7985dc2df4 fixes in advanced-storage plugin
Alain Mazy <am@orthanc.team>
parents: 5811
diff changeset
756 // - either the file {UUID} (this is mandatory in this Beta version !!!!!)
5823
a856763e5736 fix SDK for custom-data in attachments
Alain Mazy <am@orthanc.team>
parents: 5812
diff changeset
757 // - MAYBE IN A LATER BETA VERSION: at least a patient identifier {PatientID} or {OrthancPatientID},
5812
3f7985dc2df4 fixes in advanced-storage plugin
Alain Mazy <am@orthanc.team>
parents: 5811
diff changeset
758 // a study identifier {StudyInstanceUID} or {OrthancStudyID},
3f7985dc2df4 fixes in advanced-storage plugin
Alain Mazy <am@orthanc.team>
parents: 5811
diff changeset
759 // a series identifier {SeriesInstanceUID} or {OrthancSeriesID},
3f7985dc2df4 fixes in advanced-storage plugin
Alain Mazy <am@orthanc.team>
parents: 5811
diff changeset
760 // an instance identifier {SOPInstanceUID} or {OrthancInstanceID}
3f7985dc2df4 fixes in advanced-storage plugin
Alain Mazy <am@orthanc.team>
parents: 5811
diff changeset
761 // - The NamingScheme defines a RELATIVE path to either the "StorageDirectory" of Orthanc or one of
3f7985dc2df4 fixes in advanced-storage plugin
Alain Mazy <am@orthanc.team>
parents: 5811
diff changeset
762 // the "MultipleStorages" of this plugin.
5824
Alain Mazy <am@orthanc.team>
parents: 5823
diff changeset
763 // - The relative path generated from the NamingScheme is stored in the SQL DB. Therefore, you may change the
5823
a856763e5736 fix SDK for custom-data in attachments
Alain Mazy <am@orthanc.team>
parents: 5812
diff changeset
764 // NamingScheme at any time and you'll still be able to access previously saved files.
5081
c673997507ea advanced storage cont
Alain Mazy <am@osimis.io>
parents: 5080
diff changeset
765 "NamingScheme" : "OrthancDefault",
c673997507ea advanced storage cont
Alain Mazy <am@osimis.io>
parents: 5080
diff changeset
766
c673997507ea advanced storage cont
Alain Mazy <am@osimis.io>
parents: 5080
diff changeset
767 // Defines the maximum length for path used in the storage. If a file is longer
c673997507ea advanced storage cont
Alain Mazy <am@osimis.io>
parents: 5080
diff changeset
768 // than this limit, it is stored with the default orthanc naming scheme
c673997507ea advanced storage cont
Alain Mazy <am@osimis.io>
parents: 5080
diff changeset
769 // (and a warning is issued).
c673997507ea advanced storage cont
Alain Mazy <am@osimis.io>
parents: 5080
diff changeset
770 // Note, on Windows, the maximum path length is 260 bytes by default but can be increased
c673997507ea advanced storage cont
Alain Mazy <am@osimis.io>
parents: 5080
diff changeset
771 // through a configuration.
5812
3f7985dc2df4 fixes in advanced-storage plugin
Alain Mazy <am@orthanc.team>
parents: 5811
diff changeset
772 "MaxPathLength" : 256,
3f7985dc2df4 fixes in advanced-storage plugin
Alain Mazy <am@orthanc.team>
parents: 5811
diff changeset
773
3f7985dc2df4 fixes in advanced-storage plugin
Alain Mazy <am@orthanc.team>
parents: 5811
diff changeset
774 // When saving non DICOM attachments, Orthanc does not have access to the DICOM tags
3f7985dc2df4 fixes in advanced-storage plugin
Alain Mazy <am@orthanc.team>
parents: 5811
diff changeset
775 // and can therefore not compute a path using the NamingScheme.
3f7985dc2df4 fixes in advanced-storage plugin
Alain Mazy <am@orthanc.team>
parents: 5811
diff changeset
776 // Therefore, all non DICOM attachements are grouped in a subfolder using the
3f7985dc2df4 fixes in advanced-storage plugin
Alain Mazy <am@orthanc.team>
parents: 5811
diff changeset
777 // legacy structure. With this option, you can define a root folder for these
3f7985dc2df4 fixes in advanced-storage plugin
Alain Mazy <am@orthanc.team>
parents: 5811
diff changeset
778 // non DICOM attachments
3f7985dc2df4 fixes in advanced-storage plugin
Alain Mazy <am@orthanc.team>
parents: 5811
diff changeset
779 // e.g: "OtherAttachmentsPrefix": "_attachments"
5823
a856763e5736 fix SDK for custom-data in attachments
Alain Mazy <am@orthanc.team>
parents: 5812
diff changeset
780 // Notes:
a856763e5736 fix SDK for custom-data in attachments
Alain Mazy <am@orthanc.team>
parents: 5812
diff changeset
781 // - When using a prefix, the path is saved in the SQL DB. Therefore, you may change the OtherAttachmentsPrefix
a856763e5736 fix SDK for custom-data in attachments
Alain Mazy <am@orthanc.team>
parents: 5812
diff changeset
782 // at any time and you'll still be able to access previously saved files.
5812
3f7985dc2df4 fixes in advanced-storage plugin
Alain Mazy <am@orthanc.team>
parents: 5811
diff changeset
783 "OtherAttachmentsPrefix": "",
5080
d7274e43ea7c allow plugins to store a customData in the Attachments table to e.g. store custom paths without requiring an external DB
Alain Mazy <am@osimis.io>
parents:
diff changeset
784 }
d7274e43ea7c allow plugins to store a customData in the Attachments table to e.g. store custom paths without requiring an external DB
Alain Mazy <am@osimis.io>
parents:
diff changeset
785 }
d7274e43ea7c allow plugins to store a customData in the Attachments table to e.g. store custom paths without requiring an external DB
Alain Mazy <am@osimis.io>
parents:
diff changeset
786 */
d7274e43ea7c allow plugins to store a customData in the Attachments table to e.g. store custom paths without requiring an external DB
Alain Mazy <am@osimis.io>
parents:
diff changeset
787
5081
c673997507ea advanced storage cont
Alain Mazy <am@osimis.io>
parents: 5080
diff changeset
788 fsyncOnWrite_ = orthancConfiguration.GetBooleanValue("SyncStorageArea", true);
c673997507ea advanced storage cont
Alain Mazy <am@osimis.io>
parents: 5080
diff changeset
789
c673997507ea advanced storage cont
Alain Mazy <am@osimis.io>
parents: 5080
diff changeset
790 const Json::Value& pluginJson = advancedStorage.GetJson();
c673997507ea advanced storage cont
Alain Mazy <am@osimis.io>
parents: 5080
diff changeset
791
c673997507ea advanced storage cont
Alain Mazy <am@osimis.io>
parents: 5080
diff changeset
792 namingScheme_ = advancedStorage.GetStringValue("NamingScheme", "OrthancDefault");
5812
3f7985dc2df4 fixes in advanced-storage plugin
Alain Mazy <am@orthanc.team>
parents: 5811
diff changeset
793 if (namingScheme_ != "OrthancDefault")
5811
a451777236fb advanced storage: fix + customizable path
Alain Mazy <am@orthanc.team>
parents: 5808
diff changeset
794 {
5812
3f7985dc2df4 fixes in advanced-storage plugin
Alain Mazy <am@orthanc.team>
parents: 5811
diff changeset
795 // when using a custom scheme, to avoid collisions, you must include, at least the attachment UUID
3f7985dc2df4 fixes in advanced-storage plugin
Alain Mazy <am@orthanc.team>
parents: 5811
diff changeset
796 // or each of the DICOM IDs or orthanc IDs
3f7985dc2df4 fixes in advanced-storage plugin
Alain Mazy <am@orthanc.team>
parents: 5811
diff changeset
797 if (namingScheme_.find("{UUID}") == std::string::npos)
3f7985dc2df4 fixes in advanced-storage plugin
Alain Mazy <am@orthanc.team>
parents: 5811
diff changeset
798 {
3f7985dc2df4 fixes in advanced-storage plugin
Alain Mazy <am@orthanc.team>
parents: 5811
diff changeset
799 LOG(ERROR) << "AdvancedStorage - To avoid files from being overwritten, your naming scheme shall alway contain the {UUID} (at least in this beta version !!!).";
3f7985dc2df4 fixes in advanced-storage plugin
Alain Mazy <am@orthanc.team>
parents: 5811
diff changeset
800 return -1;
3f7985dc2df4 fixes in advanced-storage plugin
Alain Mazy <am@orthanc.team>
parents: 5811
diff changeset
801
3f7985dc2df4 fixes in advanced-storage plugin
Alain Mazy <am@orthanc.team>
parents: 5811
diff changeset
802 if (namingScheme_.find("PatientID") == std::string::npos && namingScheme_.find("OrthancPatientID") == std::string::npos)
3f7985dc2df4 fixes in advanced-storage plugin
Alain Mazy <am@orthanc.team>
parents: 5811
diff changeset
803 {
3f7985dc2df4 fixes in advanced-storage plugin
Alain Mazy <am@orthanc.team>
parents: 5811
diff changeset
804 LOG(ERROR) << "AdvancedStorage - To avoid files from being overwritten, your naming scheme shall alway contain either the {UUID} or 4 DICOM identifiers ({PatientID}, {StudyInstanceUID}, {SeriesInstanceUID}, {SOPInstanceUID}) or 4 Orthanc identifiers ({PatientOrthancID}, {StudyOrthancID}, {SeriesOrthancID}, {SOPInstanceUID}).";
3f7985dc2df4 fixes in advanced-storage plugin
Alain Mazy <am@orthanc.team>
parents: 5811
diff changeset
805 return -1;
3f7985dc2df4 fixes in advanced-storage plugin
Alain Mazy <am@orthanc.team>
parents: 5811
diff changeset
806 }
3f7985dc2df4 fixes in advanced-storage plugin
Alain Mazy <am@orthanc.team>
parents: 5811
diff changeset
807
3f7985dc2df4 fixes in advanced-storage plugin
Alain Mazy <am@orthanc.team>
parents: 5811
diff changeset
808 if (namingScheme_.find("StudyInstanceUID") == std::string::npos && namingScheme_.find("OrthancStudyID") == std::string::npos)
3f7985dc2df4 fixes in advanced-storage plugin
Alain Mazy <am@orthanc.team>
parents: 5811
diff changeset
809 {
3f7985dc2df4 fixes in advanced-storage plugin
Alain Mazy <am@orthanc.team>
parents: 5811
diff changeset
810 LOG(ERROR) << "AdvancedStorage - To avoid files from being overwritten, your naming scheme shall alway contain either the {UUID} or 4 DICOM identifiers ({PatientID}, {StudyInstanceUID}, {SeriesInstanceUID}, {SOPInstanceUID}) or 4 Orthanc identifiers ({PatientOrthancID}, {StudyOrthancID}, {SeriesOrthancID}, {SOPInstanceUID}).";
3f7985dc2df4 fixes in advanced-storage plugin
Alain Mazy <am@orthanc.team>
parents: 5811
diff changeset
811 return -1;
3f7985dc2df4 fixes in advanced-storage plugin
Alain Mazy <am@orthanc.team>
parents: 5811
diff changeset
812 }
3f7985dc2df4 fixes in advanced-storage plugin
Alain Mazy <am@orthanc.team>
parents: 5811
diff changeset
813
3f7985dc2df4 fixes in advanced-storage plugin
Alain Mazy <am@orthanc.team>
parents: 5811
diff changeset
814 if (namingScheme_.find("SeriesInstanceUID") == std::string::npos && namingScheme_.find("OrthancSeriesID") == std::string::npos)
3f7985dc2df4 fixes in advanced-storage plugin
Alain Mazy <am@orthanc.team>
parents: 5811
diff changeset
815 {
3f7985dc2df4 fixes in advanced-storage plugin
Alain Mazy <am@orthanc.team>
parents: 5811
diff changeset
816 LOG(ERROR) << "AdvancedStorage - To avoid files from being overwritten, your naming scheme shall alway contain either the {UUID} or 4 DICOM identifiers ({PatientID}, {StudyInstanceUID}, {SeriesInstanceUID}, {SOPInstanceUID}) or 4 Orthanc identifiers ({PatientOrthancID}, {StudyOrthancID}, {SeriesOrthancID}, {SOPInstanceUID}).";
3f7985dc2df4 fixes in advanced-storage plugin
Alain Mazy <am@orthanc.team>
parents: 5811
diff changeset
817 return -1;
3f7985dc2df4 fixes in advanced-storage plugin
Alain Mazy <am@orthanc.team>
parents: 5811
diff changeset
818 }
3f7985dc2df4 fixes in advanced-storage plugin
Alain Mazy <am@orthanc.team>
parents: 5811
diff changeset
819
3f7985dc2df4 fixes in advanced-storage plugin
Alain Mazy <am@orthanc.team>
parents: 5811
diff changeset
820 if (namingScheme_.find("SOPInstanceUID") == std::string::npos && namingScheme_.find("OrthancInstanceID") == std::string::npos)
3f7985dc2df4 fixes in advanced-storage plugin
Alain Mazy <am@orthanc.team>
parents: 5811
diff changeset
821 {
3f7985dc2df4 fixes in advanced-storage plugin
Alain Mazy <am@orthanc.team>
parents: 5811
diff changeset
822 LOG(ERROR) << "AdvancedStorage - To avoid files from being overwritten, your naming scheme shall alway contain either the {UUID} or 4 DICOM identifiers ({PatientID}, {StudyInstanceUID}, {SeriesInstanceUID}, {SOPInstanceUID}) or 4 Orthanc identifiers ({PatientOrthancID}, {StudyOrthancID}, {SeriesOrthancID}, {SOPInstanceUID}).";
3f7985dc2df4 fixes in advanced-storage plugin
Alain Mazy <am@orthanc.team>
parents: 5811
diff changeset
823 return -1;
3f7985dc2df4 fixes in advanced-storage plugin
Alain Mazy <am@orthanc.team>
parents: 5811
diff changeset
824 }
3f7985dc2df4 fixes in advanced-storage plugin
Alain Mazy <am@orthanc.team>
parents: 5811
diff changeset
825 }
5811
a451777236fb advanced storage: fix + customizable path
Alain Mazy <am@orthanc.team>
parents: 5808
diff changeset
826 }
5081
c673997507ea advanced storage cont
Alain Mazy <am@osimis.io>
parents: 5080
diff changeset
827
5812
3f7985dc2df4 fixes in advanced-storage plugin
Alain Mazy <am@orthanc.team>
parents: 5811
diff changeset
828 otherAttachmentsPrefix_ = advancedStorage.GetStringValue("OtherAttachmentsPrefix", "");
3f7985dc2df4 fixes in advanced-storage plugin
Alain Mazy <am@orthanc.team>
parents: 5811
diff changeset
829 LOG(WARNING) << "AdvancedStorage - Path to the other attachments root: " << otherAttachmentsPrefix_;
3f7985dc2df4 fixes in advanced-storage plugin
Alain Mazy <am@orthanc.team>
parents: 5811
diff changeset
830
5081
c673997507ea advanced storage cont
Alain Mazy <am@osimis.io>
parents: 5080
diff changeset
831 // if we have enabled multiple storage after files have been saved without this plugin, we still need the default StorageDirectory
c673997507ea advanced storage cont
Alain Mazy <am@osimis.io>
parents: 5080
diff changeset
832 rootPath_ = fs::path(orthancConfiguration.GetStringValue("StorageDirectory", "OrthancStorage"));
c673997507ea advanced storage cont
Alain Mazy <am@osimis.io>
parents: 5080
diff changeset
833 LOG(WARNING) << "AdvancedStorage - Path to the default storage area: " << rootPath_.string();
c673997507ea advanced storage cont
Alain Mazy <am@osimis.io>
parents: 5080
diff changeset
834
5812
3f7985dc2df4 fixes in advanced-storage plugin
Alain Mazy <am@orthanc.team>
parents: 5811
diff changeset
835 maxPathLength_ = advancedStorage.GetIntegerValue("MaxPathLength", 256);
5081
c673997507ea advanced storage cont
Alain Mazy <am@osimis.io>
parents: 5080
diff changeset
836 LOG(WARNING) << "AdvancedStorage - Maximum path length: " << maxPathLength_;
c673997507ea advanced storage cont
Alain Mazy <am@osimis.io>
parents: 5080
diff changeset
837
c673997507ea advanced storage cont
Alain Mazy <am@osimis.io>
parents: 5080
diff changeset
838 if (!rootPath_.is_absolute())
c673997507ea advanced storage cont
Alain Mazy <am@osimis.io>
parents: 5080
diff changeset
839 {
5811
a451777236fb advanced storage: fix + customizable path
Alain Mazy <am@orthanc.team>
parents: 5808
diff changeset
840 LOG(ERROR) << "AdvancedStorage - Path to the default storage area should be an absolute path " << rootPath_ << " (\"StorageDirectory\" in main Orthanc configuration)";
5081
c673997507ea advanced storage cont
Alain Mazy <am@osimis.io>
parents: 5080
diff changeset
841 return -1;
c673997507ea advanced storage cont
Alain Mazy <am@osimis.io>
parents: 5080
diff changeset
842 }
c673997507ea advanced storage cont
Alain Mazy <am@osimis.io>
parents: 5080
diff changeset
843
c673997507ea advanced storage cont
Alain Mazy <am@osimis.io>
parents: 5080
diff changeset
844 if (rootPath_.size() > (maxPathLength_ - legacyPathLength))
c673997507ea advanced storage cont
Alain Mazy <am@osimis.io>
parents: 5080
diff changeset
845 {
c673997507ea advanced storage cont
Alain Mazy <am@osimis.io>
parents: 5080
diff changeset
846 LOG(ERROR) << "AdvancedStorage - Path to the default storage is too long";
c673997507ea advanced storage cont
Alain Mazy <am@osimis.io>
parents: 5080
diff changeset
847 return -1;
c673997507ea advanced storage cont
Alain Mazy <am@osimis.io>
parents: 5080
diff changeset
848 }
c673997507ea advanced storage cont
Alain Mazy <am@osimis.io>
parents: 5080
diff changeset
849
c673997507ea advanced storage cont
Alain Mazy <am@osimis.io>
parents: 5080
diff changeset
850 if (pluginJson.isMember("MultipleStorages"))
c673997507ea advanced storage cont
Alain Mazy <am@osimis.io>
parents: 5080
diff changeset
851 {
c673997507ea advanced storage cont
Alain Mazy <am@osimis.io>
parents: 5080
diff changeset
852 multipleStoragesEnabled_ = true;
c673997507ea advanced storage cont
Alain Mazy <am@osimis.io>
parents: 5080
diff changeset
853 const Json::Value& multipleStoragesJson = pluginJson["MultipleStorages"];
c673997507ea advanced storage cont
Alain Mazy <am@osimis.io>
parents: 5080
diff changeset
854
c673997507ea advanced storage cont
Alain Mazy <am@osimis.io>
parents: 5080
diff changeset
855 if (multipleStoragesJson.isMember("Storages") && multipleStoragesJson.isObject() && multipleStoragesJson.isMember("CurrentStorage") && multipleStoragesJson["CurrentStorage"].isString())
c673997507ea advanced storage cont
Alain Mazy <am@osimis.io>
parents: 5080
diff changeset
856 {
c673997507ea advanced storage cont
Alain Mazy <am@osimis.io>
parents: 5080
diff changeset
857 const Json::Value& storagesJson = multipleStoragesJson["Storages"];
c673997507ea advanced storage cont
Alain Mazy <am@osimis.io>
parents: 5080
diff changeset
858 Json::Value::Members storageIds = storagesJson.getMemberNames();
c673997507ea advanced storage cont
Alain Mazy <am@osimis.io>
parents: 5080
diff changeset
859
c673997507ea advanced storage cont
Alain Mazy <am@osimis.io>
parents: 5080
diff changeset
860 for (Json::Value::Members::const_iterator it = storageIds.begin(); it != storageIds.end(); ++it)
c673997507ea advanced storage cont
Alain Mazy <am@osimis.io>
parents: 5080
diff changeset
861 {
c673997507ea advanced storage cont
Alain Mazy <am@osimis.io>
parents: 5080
diff changeset
862 const Json::Value& storagePath = storagesJson[*it];
c673997507ea advanced storage cont
Alain Mazy <am@osimis.io>
parents: 5080
diff changeset
863 if (!storagePath.isString())
c673997507ea advanced storage cont
Alain Mazy <am@osimis.io>
parents: 5080
diff changeset
864 {
c673997507ea advanced storage cont
Alain Mazy <am@osimis.io>
parents: 5080
diff changeset
865 LOG(ERROR) << "AdvancedStorage - Storage path is not a string " << *it;
c673997507ea advanced storage cont
Alain Mazy <am@osimis.io>
parents: 5080
diff changeset
866 return -1;
c673997507ea advanced storage cont
Alain Mazy <am@osimis.io>
parents: 5080
diff changeset
867 }
c673997507ea advanced storage cont
Alain Mazy <am@osimis.io>
parents: 5080
diff changeset
868
c673997507ea advanced storage cont
Alain Mazy <am@osimis.io>
parents: 5080
diff changeset
869 rootPaths_[*it] = storagePath.asString();
c673997507ea advanced storage cont
Alain Mazy <am@osimis.io>
parents: 5080
diff changeset
870
c673997507ea advanced storage cont
Alain Mazy <am@osimis.io>
parents: 5080
diff changeset
871 if (!rootPaths_[*it].is_absolute())
c673997507ea advanced storage cont
Alain Mazy <am@osimis.io>
parents: 5080
diff changeset
872 {
c673997507ea advanced storage cont
Alain Mazy <am@osimis.io>
parents: 5080
diff changeset
873 LOG(ERROR) << "AdvancedStorage - Storage path shall be absolute path '" << storagePath.asString() << "'";
c673997507ea advanced storage cont
Alain Mazy <am@osimis.io>
parents: 5080
diff changeset
874 return -1;
c673997507ea advanced storage cont
Alain Mazy <am@osimis.io>
parents: 5080
diff changeset
875 }
c673997507ea advanced storage cont
Alain Mazy <am@osimis.io>
parents: 5080
diff changeset
876
c673997507ea advanced storage cont
Alain Mazy <am@osimis.io>
parents: 5080
diff changeset
877 if (storagePath.asString().size() > (maxPathLength_ - legacyPathLength))
c673997507ea advanced storage cont
Alain Mazy <am@osimis.io>
parents: 5080
diff changeset
878 {
c673997507ea advanced storage cont
Alain Mazy <am@osimis.io>
parents: 5080
diff changeset
879 LOG(ERROR) << "AdvancedStorage - Storage path is too long '" << storagePath.asString() << "'";
c673997507ea advanced storage cont
Alain Mazy <am@osimis.io>
parents: 5080
diff changeset
880 return -1;
c673997507ea advanced storage cont
Alain Mazy <am@osimis.io>
parents: 5080
diff changeset
881 }
c673997507ea advanced storage cont
Alain Mazy <am@osimis.io>
parents: 5080
diff changeset
882 }
c673997507ea advanced storage cont
Alain Mazy <am@osimis.io>
parents: 5080
diff changeset
883
c673997507ea advanced storage cont
Alain Mazy <am@osimis.io>
parents: 5080
diff changeset
884 currentStorageId_ = multipleStoragesJson["CurrentStorage"].asString();
c673997507ea advanced storage cont
Alain Mazy <am@osimis.io>
parents: 5080
diff changeset
885
c673997507ea advanced storage cont
Alain Mazy <am@osimis.io>
parents: 5080
diff changeset
886 if (rootPaths_.find(currentStorageId_) == rootPaths_.end())
c673997507ea advanced storage cont
Alain Mazy <am@osimis.io>
parents: 5080
diff changeset
887 {
c673997507ea advanced storage cont
Alain Mazy <am@osimis.io>
parents: 5080
diff changeset
888 LOG(ERROR) << "AdvancedStorage - CurrentStorage is not defined in Storages list: " << currentStorageId_;
c673997507ea advanced storage cont
Alain Mazy <am@osimis.io>
parents: 5080
diff changeset
889 return -1;
c673997507ea advanced storage cont
Alain Mazy <am@osimis.io>
parents: 5080
diff changeset
890 }
c673997507ea advanced storage cont
Alain Mazy <am@osimis.io>
parents: 5080
diff changeset
891
c673997507ea advanced storage cont
Alain Mazy <am@osimis.io>
parents: 5080
diff changeset
892 LOG(WARNING) << "AdvancedStorage - multiple storages enabled. Current storage : " << rootPaths_[currentStorageId_].string();
c673997507ea advanced storage cont
Alain Mazy <am@osimis.io>
parents: 5080
diff changeset
893 }
c673997507ea advanced storage cont
Alain Mazy <am@osimis.io>
parents: 5080
diff changeset
894 }
5080
d7274e43ea7c allow plugins to store a customData in the Attachments table to e.g. store custom paths without requiring an external DB
Alain Mazy <am@osimis.io>
parents:
diff changeset
895
d7274e43ea7c allow plugins to store a customData in the Attachments table to e.g. store custom paths without requiring an external DB
Alain Mazy <am@osimis.io>
parents:
diff changeset
896 OrthancPluginRegisterStorageArea3(context, StorageCreateInstance, StorageCreateAttachment, StorageReadWhole, StorageReadRange, StorageRemove);
d7274e43ea7c allow plugins to store a customData in the Attachments table to e.g. store custom paths without requiring an external DB
Alain Mazy <am@osimis.io>
parents:
diff changeset
897 }
d7274e43ea7c allow plugins to store a customData in the Attachments table to e.g. store custom paths without requiring an external DB
Alain Mazy <am@osimis.io>
parents:
diff changeset
898 else
d7274e43ea7c allow plugins to store a customData in the Attachments table to e.g. store custom paths without requiring an external DB
Alain Mazy <am@osimis.io>
parents:
diff changeset
899 {
5807
8279eaab0d1d merged default -> attach-custom-data
Alain Mazy <am@orthanc.team>
parents: 5085
diff changeset
900 LOG(WARNING) << "AdvancedStorage plugin is disabled by the configuration file";
5080
d7274e43ea7c allow plugins to store a customData in the Attachments table to e.g. store custom paths without requiring an external DB
Alain Mazy <am@osimis.io>
parents:
diff changeset
901 }
d7274e43ea7c allow plugins to store a customData in the Attachments table to e.g. store custom paths without requiring an external DB
Alain Mazy <am@osimis.io>
parents:
diff changeset
902
d7274e43ea7c allow plugins to store a customData in the Attachments table to e.g. store custom paths without requiring an external DB
Alain Mazy <am@osimis.io>
parents:
diff changeset
903 return 0;
d7274e43ea7c allow plugins to store a customData in the Attachments table to e.g. store custom paths without requiring an external DB
Alain Mazy <am@osimis.io>
parents:
diff changeset
904 }
d7274e43ea7c allow plugins to store a customData in the Attachments table to e.g. store custom paths without requiring an external DB
Alain Mazy <am@osimis.io>
parents:
diff changeset
905
d7274e43ea7c allow plugins to store a customData in the Attachments table to e.g. store custom paths without requiring an external DB
Alain Mazy <am@osimis.io>
parents:
diff changeset
906
d7274e43ea7c allow plugins to store a customData in the Attachments table to e.g. store custom paths without requiring an external DB
Alain Mazy <am@osimis.io>
parents:
diff changeset
907 ORTHANC_PLUGINS_API void OrthancPluginFinalize()
d7274e43ea7c allow plugins to store a customData in the Attachments table to e.g. store custom paths without requiring an external DB
Alain Mazy <am@osimis.io>
parents:
diff changeset
908 {
5807
8279eaab0d1d merged default -> attach-custom-data
Alain Mazy <am@orthanc.team>
parents: 5085
diff changeset
909 LOG(WARNING) << "AdvancedStorage plugin is finalizing";
5080
d7274e43ea7c allow plugins to store a customData in the Attachments table to e.g. store custom paths without requiring an external DB
Alain Mazy <am@osimis.io>
parents:
diff changeset
910 }
d7274e43ea7c allow plugins to store a customData in the Attachments table to e.g. store custom paths without requiring an external DB
Alain Mazy <am@osimis.io>
parents:
diff changeset
911
d7274e43ea7c allow plugins to store a customData in the Attachments table to e.g. store custom paths without requiring an external DB
Alain Mazy <am@osimis.io>
parents:
diff changeset
912
d7274e43ea7c allow plugins to store a customData in the Attachments table to e.g. store custom paths without requiring an external DB
Alain Mazy <am@osimis.io>
parents:
diff changeset
913 ORTHANC_PLUGINS_API const char* OrthancPluginGetName()
d7274e43ea7c allow plugins to store a customData in the Attachments table to e.g. store custom paths without requiring an external DB
Alain Mazy <am@osimis.io>
parents:
diff changeset
914 {
5807
8279eaab0d1d merged default -> attach-custom-data
Alain Mazy <am@orthanc.team>
parents: 5085
diff changeset
915 return ORTHANC_PLUGIN_NAME;
5080
d7274e43ea7c allow plugins to store a customData in the Attachments table to e.g. store custom paths without requiring an external DB
Alain Mazy <am@osimis.io>
parents:
diff changeset
916 }
d7274e43ea7c allow plugins to store a customData in the Attachments table to e.g. store custom paths without requiring an external DB
Alain Mazy <am@osimis.io>
parents:
diff changeset
917
d7274e43ea7c allow plugins to store a customData in the Attachments table to e.g. store custom paths without requiring an external DB
Alain Mazy <am@osimis.io>
parents:
diff changeset
918
d7274e43ea7c allow plugins to store a customData in the Attachments table to e.g. store custom paths without requiring an external DB
Alain Mazy <am@osimis.io>
parents:
diff changeset
919 ORTHANC_PLUGINS_API const char* OrthancPluginGetVersion()
d7274e43ea7c allow plugins to store a customData in the Attachments table to e.g. store custom paths without requiring an external DB
Alain Mazy <am@osimis.io>
parents:
diff changeset
920 {
5807
8279eaab0d1d merged default -> attach-custom-data
Alain Mazy <am@orthanc.team>
parents: 5085
diff changeset
921 return ADVANCED_STORAGE_VERSION;
5080
d7274e43ea7c allow plugins to store a customData in the Attachments table to e.g. store custom paths without requiring an external DB
Alain Mazy <am@osimis.io>
parents:
diff changeset
922 }
d7274e43ea7c allow plugins to store a customData in the Attachments table to e.g. store custom paths without requiring an external DB
Alain Mazy <am@osimis.io>
parents:
diff changeset
923 }