annotate OrthancServer/Plugins/Samples/AdvancedStorage/Plugin.cpp @ 5811:a451777236fb attach-custom-data tip

advanced storage: fix + customizable path
author Alain Mazy <am@orthanc.team>
date Tue, 24 Sep 2024 17:52:45 +0200
parents 63c025cf6958
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_;
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
54 bool fsyncOnWrite_ = true;
5081
c673997507ea advanced storage cont
Alain Mazy <am@osimis.io>
parents: 5080
diff changeset
55 size_t maxPathLength_ = 256;
c673997507ea advanced storage cont
Alain Mazy <am@osimis.io>
parents: 5080
diff changeset
56 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
57
c673997507ea advanced storage cont
Alain Mazy <am@osimis.io>
parents: 5080
diff changeset
58 fs::path GetRootPath()
c673997507ea advanced storage cont
Alain Mazy <am@osimis.io>
parents: 5080
diff changeset
59 {
c673997507ea advanced storage cont
Alain Mazy <am@osimis.io>
parents: 5080
diff changeset
60 if (multipleStoragesEnabled_)
c673997507ea advanced storage cont
Alain Mazy <am@osimis.io>
parents: 5080
diff changeset
61 {
c673997507ea advanced storage cont
Alain Mazy <am@osimis.io>
parents: 5080
diff changeset
62 return rootPaths_[currentStorageId_];
c673997507ea advanced storage cont
Alain Mazy <am@osimis.io>
parents: 5080
diff changeset
63 }
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 return rootPath_;
c673997507ea advanced storage cont
Alain Mazy <am@osimis.io>
parents: 5080
diff changeset
66 }
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 fs::path GetRootPath(const std::string& storageId)
c673997507ea advanced storage cont
Alain Mazy <am@osimis.io>
parents: 5080
diff changeset
69 {
c673997507ea advanced storage cont
Alain Mazy <am@osimis.io>
parents: 5080
diff changeset
70 if (multipleStoragesEnabled_)
c673997507ea advanced storage cont
Alain Mazy <am@osimis.io>
parents: 5080
diff changeset
71 {
c673997507ea advanced storage cont
Alain Mazy <am@osimis.io>
parents: 5080
diff changeset
72 if (rootPaths_.find(storageId) == rootPaths_.end())
c673997507ea advanced storage cont
Alain Mazy <am@osimis.io>
parents: 5080
diff changeset
73 {
c673997507ea advanced storage cont
Alain Mazy <am@osimis.io>
parents: 5080
diff changeset
74 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
75 }
c673997507ea advanced storage cont
Alain Mazy <am@osimis.io>
parents: 5080
diff changeset
76 return rootPaths_[storageId];
c673997507ea advanced storage cont
Alain Mazy <am@osimis.io>
parents: 5080
diff changeset
77 }
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 return rootPath_;
c673997507ea advanced storage cont
Alain Mazy <am@osimis.io>
parents: 5080
diff changeset
80 }
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
81
d7274e43ea7c allow plugins to store a 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 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
84 {
d7274e43ea7c allow plugins to store a 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 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
86 {
d7274e43ea7c allow plugins to store a 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 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
88 }
d7274e43ea7c allow plugins to store a 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
5081
c673997507ea advanced storage cont
Alain Mazy <am@osimis.io>
parents: 5080
diff changeset
90 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
91
d7274e43ea7c allow plugins to store a 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 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
93 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
94 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
95
d7274e43ea7c allow plugins to store a customData in the Attachments table to e.g. store custom paths without requiring an external DB
Alain Mazy <am@osimis.io>
parents:
diff changeset
96 #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
97 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
98 #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
99
d7274e43ea7c allow plugins to store a 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 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
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
5081
c673997507ea advanced storage cont
Alain Mazy <am@osimis.io>
parents: 5080
diff changeset
103 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
104 {
5081
c673997507ea advanced storage cont
Alain Mazy <am@osimis.io>
parents: 5080
diff changeset
105 fs::path path;
c673997507ea advanced storage cont
Alain Mazy <am@osimis.io>
parents: 5080
diff changeset
106
c673997507ea advanced storage cont
Alain Mazy <am@osimis.io>
parents: 5080
diff changeset
107 if (!customDataString.empty())
c673997507ea advanced storage cont
Alain Mazy <am@osimis.io>
parents: 5080
diff changeset
108 {
c673997507ea advanced storage cont
Alain Mazy <am@osimis.io>
parents: 5080
diff changeset
109 Json::Value customData;
c673997507ea advanced storage cont
Alain Mazy <am@osimis.io>
parents: 5080
diff changeset
110 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
111
5081
c673997507ea advanced storage cont
Alain Mazy <am@osimis.io>
parents: 5080
diff changeset
112 if (customData["Version"].asInt() == 1)
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
113 {
5081
c673997507ea advanced storage cont
Alain Mazy <am@osimis.io>
parents: 5080
diff changeset
114 if (customData.isMember("StorageId"))
c673997507ea advanced storage cont
Alain Mazy <am@osimis.io>
parents: 5080
diff changeset
115 {
c673997507ea advanced storage cont
Alain Mazy <am@osimis.io>
parents: 5080
diff changeset
116 path = GetRootPath(customData["StorageId"].asString());
c673997507ea advanced storage cont
Alain Mazy <am@osimis.io>
parents: 5080
diff changeset
117 }
c673997507ea advanced storage cont
Alain Mazy <am@osimis.io>
parents: 5080
diff changeset
118 else
c673997507ea advanced storage cont
Alain Mazy <am@osimis.io>
parents: 5080
diff changeset
119 {
c673997507ea advanced storage cont
Alain Mazy <am@osimis.io>
parents: 5080
diff changeset
120 path = GetRootPath();
c673997507ea advanced storage cont
Alain Mazy <am@osimis.io>
parents: 5080
diff changeset
121 }
c673997507ea advanced storage cont
Alain Mazy <am@osimis.io>
parents: 5080
diff changeset
122
c673997507ea advanced storage cont
Alain Mazy <am@osimis.io>
parents: 5080
diff changeset
123 if (customData.isMember("Path"))
c673997507ea advanced storage cont
Alain Mazy <am@osimis.io>
parents: 5080
diff changeset
124 {
c673997507ea advanced storage cont
Alain Mazy <am@osimis.io>
parents: 5080
diff changeset
125 path /= customData["Path"].asString();
c673997507ea advanced storage cont
Alain Mazy <am@osimis.io>
parents: 5080
diff changeset
126 }
c673997507ea advanced storage cont
Alain Mazy <am@osimis.io>
parents: 5080
diff changeset
127 else
c673997507ea advanced storage cont
Alain Mazy <am@osimis.io>
parents: 5080
diff changeset
128 { // we are in "legacy mode" for the path part
c673997507ea advanced storage cont
Alain Mazy <am@osimis.io>
parents: 5080
diff changeset
129 path /= GetLegacyRelativePath(uuid);
c673997507ea advanced storage cont
Alain Mazy <am@osimis.io>
parents: 5080
diff changeset
130 }
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
131 }
d7274e43ea7c allow plugins to store a customData in the Attachments table to e.g. store custom paths without requiring an external DB
Alain Mazy <am@osimis.io>
parents:
diff changeset
132 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
133 {
5081
c673997507ea advanced storage cont
Alain Mazy <am@osimis.io>
parents: 5080
diff changeset
134 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
135 }
d7274e43ea7c allow plugins to store a customData in the Attachments table to e.g. store custom paths without requiring an external DB
Alain Mazy <am@osimis.io>
parents:
diff changeset
136 }
5081
c673997507ea advanced storage cont
Alain Mazy <am@osimis.io>
parents: 5080
diff changeset
137 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
138 {
5081
c673997507ea advanced storage cont
Alain Mazy <am@osimis.io>
parents: 5080
diff changeset
139 path = 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
140 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
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
d7274e43ea7c allow plugins to store a customData in the Attachments table to e.g. store custom paths without requiring an external DB
Alain Mazy <am@osimis.io>
parents:
diff changeset
143 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
144 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
145 }
d7274e43ea7c allow plugins to store a 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
5081
c673997507ea advanced storage cont
Alain Mazy <am@osimis.io>
parents: 5080
diff changeset
147 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
148 {
5081
c673997507ea advanced storage cont
Alain Mazy <am@osimis.io>
parents: 5080
diff changeset
149 // 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
150 if (namingScheme_ == "OrthancDefault" && !multipleStoragesEnabled_)
c673997507ea advanced storage cont
Alain Mazy <am@osimis.io>
parents: 5080
diff changeset
151 {
c673997507ea advanced storage cont
Alain Mazy <am@osimis.io>
parents: 5080
diff changeset
152 return;
c673997507ea advanced storage cont
Alain Mazy <am@osimis.io>
parents: 5080
diff changeset
153 }
c673997507ea advanced storage cont
Alain Mazy <am@osimis.io>
parents: 5080
diff changeset
154
c673997507ea advanced storage cont
Alain Mazy <am@osimis.io>
parents: 5080
diff changeset
155 Json::Value customDataJson;
c673997507ea advanced storage cont
Alain Mazy <am@osimis.io>
parents: 5080
diff changeset
156 customDataJson["Version"] = 1;
c673997507ea advanced storage cont
Alain Mazy <am@osimis.io>
parents: 5080
diff changeset
157
5808
63c025cf6958 cleanup
Alain Mazy <am@orthanc.team>
parents: 5807
diff changeset
158 // 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
159 if (namingScheme_ != "OrthancDefault")
5808
63c025cf6958 cleanup
Alain Mazy <am@orthanc.team>
parents: 5807
diff changeset
160 {
5081
c673997507ea advanced storage cont
Alain Mazy <am@osimis.io>
parents: 5080
diff changeset
161 customDataJson["Path"] = path.string();
c673997507ea advanced storage cont
Alain Mazy <am@osimis.io>
parents: 5080
diff changeset
162 }
c673997507ea advanced storage cont
Alain Mazy <am@osimis.io>
parents: 5080
diff changeset
163
c673997507ea advanced storage cont
Alain Mazy <am@osimis.io>
parents: 5080
diff changeset
164 if (multipleStoragesEnabled_)
c673997507ea advanced storage cont
Alain Mazy <am@osimis.io>
parents: 5080
diff changeset
165 {
c673997507ea advanced storage cont
Alain Mazy <am@osimis.io>
parents: 5080
diff changeset
166 customDataJson["StorageId"] = currentStorageId_;
c673997507ea advanced storage cont
Alain Mazy <am@osimis.io>
parents: 5080
diff changeset
167 }
c673997507ea advanced storage cont
Alain Mazy <am@osimis.io>
parents: 5080
diff changeset
168
5808
63c025cf6958 cleanup
Alain Mazy <am@orthanc.team>
parents: 5807
diff changeset
169 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
170 }
d7274e43ea7c allow plugins to store a customData in the Attachments table to e.g. store custom paths without requiring an external DB
Alain Mazy <am@osimis.io>
parents:
diff changeset
171
5811
a451777236fb advanced storage: fix + customizable path
Alain Mazy <am@orthanc.team>
parents: 5808
diff changeset
172 // void AddSplitDateDicomTagToPath(fs::path& path, const Json::Value& tags, const char* tagName, const char* defaultValue = NULL)
a451777236fb advanced storage: fix + customizable path
Alain Mazy <am@orthanc.team>
parents: 5808
diff changeset
173 // {
a451777236fb advanced storage: fix + customizable path
Alain Mazy <am@orthanc.team>
parents: 5808
diff changeset
174 // if (tags.isMember(tagName) && tags[tagName].asString().size() == 8)
a451777236fb advanced storage: fix + customizable path
Alain Mazy <am@orthanc.team>
parents: 5808
diff changeset
175 // {
a451777236fb advanced storage: fix + customizable path
Alain Mazy <am@orthanc.team>
parents: 5808
diff changeset
176 // std::string date = tags[tagName].asString();
a451777236fb advanced storage: fix + customizable path
Alain Mazy <am@orthanc.team>
parents: 5808
diff changeset
177 // path /= date.substr(0, 4);
a451777236fb advanced storage: fix + customizable path
Alain Mazy <am@orthanc.team>
parents: 5808
diff changeset
178 // path /= date.substr(4, 2);
a451777236fb advanced storage: fix + customizable path
Alain Mazy <am@orthanc.team>
parents: 5808
diff changeset
179 // path /= date.substr(6, 2);
a451777236fb advanced storage: fix + customizable path
Alain Mazy <am@orthanc.team>
parents: 5808
diff changeset
180 // }
a451777236fb advanced storage: fix + customizable path
Alain Mazy <am@orthanc.team>
parents: 5808
diff changeset
181 // else if (defaultValue != NULL)
a451777236fb advanced storage: fix + customizable path
Alain Mazy <am@orthanc.team>
parents: 5808
diff changeset
182 // {
a451777236fb advanced storage: fix + customizable path
Alain Mazy <am@orthanc.team>
parents: 5808
diff changeset
183 // path /= defaultValue;
a451777236fb advanced storage: fix + customizable path
Alain Mazy <am@orthanc.team>
parents: 5808
diff changeset
184 // }
a451777236fb advanced storage: fix + customizable path
Alain Mazy <am@orthanc.team>
parents: 5808
diff changeset
185 // }
a451777236fb advanced storage: fix + customizable path
Alain Mazy <am@orthanc.team>
parents: 5808
diff changeset
186
a451777236fb advanced storage: fix + customizable path
Alain Mazy <am@orthanc.team>
parents: 5808
diff changeset
187 // void AddStringDicomTagToPath(fs::path& path, const Json::Value& tags, const char* tagName, const char* defaultValue = NULL)
a451777236fb advanced storage: fix + customizable path
Alain Mazy <am@orthanc.team>
parents: 5808
diff changeset
188 // {
a451777236fb advanced storage: fix + customizable path
Alain Mazy <am@orthanc.team>
parents: 5808
diff changeset
189 // if (tags.isMember(tagName) && tags[tagName].isString() && tags[tagName].asString().size() > 0)
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 // path /= tags[tagName].asString();
a451777236fb advanced storage: fix + customizable path
Alain Mazy <am@orthanc.team>
parents: 5808
diff changeset
192 // }
a451777236fb advanced storage: fix + customizable path
Alain Mazy <am@orthanc.team>
parents: 5808
diff changeset
193 // else if (defaultValue != NULL)
a451777236fb advanced storage: fix + customizable path
Alain Mazy <am@orthanc.team>
parents: 5808
diff changeset
194 // {
a451777236fb advanced storage: fix + customizable path
Alain Mazy <am@orthanc.team>
parents: 5808
diff changeset
195 // path /= defaultValue;
a451777236fb advanced storage: fix + customizable path
Alain Mazy <am@orthanc.team>
parents: 5808
diff changeset
196 // }
a451777236fb advanced storage: fix + customizable path
Alain Mazy <am@orthanc.team>
parents: 5808
diff changeset
197 // }
a451777236fb advanced storage: fix + customizable path
Alain Mazy <am@orthanc.team>
parents: 5808
diff changeset
198
a451777236fb advanced storage: fix + customizable path
Alain Mazy <am@orthanc.team>
parents: 5808
diff changeset
199 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
200 {
d7274e43ea7c allow plugins to store a 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 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
202 {
d7274e43ea7c allow plugins to store a 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 std::string date = tags[tagName].asString();
5811
a451777236fb advanced storage: fix + customizable path
Alain Mazy <am@orthanc.team>
parents: 5808
diff changeset
204 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
205 }
d7274e43ea7c allow plugins to store a 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 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
207 {
5811
a451777236fb advanced storage: fix + customizable path
Alain Mazy <am@orthanc.team>
parents: 5808
diff changeset
208 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
209 }
5811
a451777236fb advanced storage: fix + customizable path
Alain Mazy <am@orthanc.team>
parents: 5808
diff changeset
210
a451777236fb advanced storage: fix + customizable path
Alain Mazy <am@orthanc.team>
parents: 5808
diff changeset
211 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
212 }
d7274e43ea7c allow plugins to store a customData in the Attachments table to e.g. store custom paths without requiring an external DB
Alain Mazy <am@osimis.io>
parents:
diff changeset
213
5811
a451777236fb advanced storage: fix + customizable path
Alain Mazy <am@orthanc.team>
parents: 5808
diff changeset
214 std::string GetStringDicomTagForPath(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
215 {
d7274e43ea7c allow plugins to store a customData in the Attachments table to e.g. store custom paths without requiring an external DB
Alain Mazy <am@osimis.io>
parents:
diff changeset
216 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
217 {
5811
a451777236fb advanced storage: fix + customizable path
Alain Mazy <am@orthanc.team>
parents: 5808
diff changeset
218 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
219 }
d7274e43ea7c allow plugins to store a customData in the Attachments table to e.g. store custom paths without requiring an external DB
Alain Mazy <am@osimis.io>
parents:
diff changeset
220 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
221 {
5811
a451777236fb advanced storage: fix + customizable path
Alain Mazy <am@orthanc.team>
parents: 5808
diff changeset
222 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
223 }
5811
a451777236fb advanced storage: fix + customizable path
Alain Mazy <am@orthanc.team>
parents: 5808
diff changeset
224
a451777236fb advanced storage: fix + customizable path
Alain Mazy <am@orthanc.team>
parents: 5808
diff changeset
225 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
226 }
d7274e43ea7c allow plugins to store a customData in the Attachments table to e.g. store custom paths without requiring an external DB
Alain Mazy <am@osimis.io>
parents:
diff changeset
227
d7274e43ea7c allow plugins to store a customData in the Attachments table to e.g. store custom paths without requiring an external DB
Alain Mazy <am@osimis.io>
parents:
diff changeset
228 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
229 {
d7274e43ea7c allow plugins to store a customData in the Attachments table to e.g. store custom paths without requiring an external DB
Alain Mazy <am@osimis.io>
parents:
diff changeset
230 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
231 {
d7274e43ea7c allow plugins to store a customData in the Attachments table to e.g. store custom paths without requiring an external DB
Alain Mazy <am@osimis.io>
parents:
diff changeset
232 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
233 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
234 {
d7274e43ea7c allow plugins to store a customData in the Attachments table to e.g. store custom paths without requiring an external DB
Alain Mazy <am@osimis.io>
parents:
diff changeset
235 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
236 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
237 }
d7274e43ea7c allow plugins to store a customData in the Attachments table to e.g. store custom paths without requiring an external DB
Alain Mazy <am@osimis.io>
parents:
diff changeset
238 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
239 {
d7274e43ea7c allow plugins to store a customData in the Attachments table to e.g. store custom paths without requiring an external DB
Alain Mazy <am@osimis.io>
parents:
diff changeset
240 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
241 }
d7274e43ea7c allow plugins to store a customData in the Attachments table to e.g. store custom paths without requiring an external DB
Alain Mazy <am@osimis.io>
parents:
diff changeset
242 }
d7274e43ea7c allow plugins to store a customData in the Attachments table to e.g. store custom paths without requiring an external DB
Alain Mazy <am@osimis.io>
parents:
diff changeset
243 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
244 {
d7274e43ea7c allow plugins to store a customData in the Attachments table to e.g. store custom paths without requiring an external DB
Alain Mazy <am@osimis.io>
parents:
diff changeset
245 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
246 }
d7274e43ea7c allow plugins to store a customData in the Attachments table to e.g. store custom paths without requiring an external DB
Alain Mazy <am@osimis.io>
parents:
diff changeset
247 }
d7274e43ea7c allow plugins to store a customData in the Attachments table to e.g. store custom paths without requiring an external DB
Alain Mazy <am@osimis.io>
parents:
diff changeset
248
5081
c673997507ea advanced storage cont
Alain Mazy <am@osimis.io>
parents: 5080
diff changeset
249 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
250 {
d7274e43ea7c allow plugins to store a customData in the Attachments table to e.g. store custom paths without requiring an external DB
Alain Mazy <am@osimis.io>
parents:
diff changeset
251 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
252
d7274e43ea7c allow plugins to store a customData in the Attachments table to e.g. store custom paths without requiring an external DB
Alain Mazy <am@osimis.io>
parents:
diff changeset
253 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
254 {
d7274e43ea7c allow plugins to store a customData in the Attachments table to e.g. store custom paths without requiring an external DB
Alain Mazy <am@osimis.io>
parents:
diff changeset
255 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
256 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
257 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
258 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
259 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
260 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
261 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
262 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
263 }
d7274e43ea7c allow plugins to store a customData in the Attachments table to e.g. store custom paths without requiring an external DB
Alain Mazy <am@osimis.io>
parents:
diff changeset
264 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
265 {
d7274e43ea7c allow plugins to store a customData in the Attachments table to e.g. store custom paths without requiring an external DB
Alain Mazy <am@osimis.io>
parents:
diff changeset
266 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
267 }
d7274e43ea7c allow plugins to store a customData in the Attachments table to e.g. store custom paths without requiring an external DB
Alain Mazy <am@osimis.io>
parents:
diff changeset
268
5081
c673997507ea advanced storage cont
Alain Mazy <am@osimis.io>
parents: 5080
diff changeset
269 return extension;
c673997507ea advanced storage cont
Alain Mazy <am@osimis.io>
parents: 5080
diff changeset
270 }
c673997507ea advanced storage cont
Alain Mazy <am@osimis.io>
parents: 5080
diff changeset
271
c673997507ea advanced storage cont
Alain Mazy <am@osimis.io>
parents: 5080
diff changeset
272 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
273 {
c673997507ea advanced storage cont
Alain Mazy <am@osimis.io>
parents: 5080
diff changeset
274 fs::path path;
5811
a451777236fb advanced storage: fix + customizable path
Alain Mazy <am@orthanc.team>
parents: 5808
diff changeset
275 bool foundUuid = false;
5081
c673997507ea advanced storage cont
Alain Mazy <am@osimis.io>
parents: 5080
diff changeset
276
c673997507ea advanced storage cont
Alain Mazy <am@osimis.io>
parents: 5080
diff changeset
277 if (!tags.isNull())
c673997507ea advanced storage cont
Alain Mazy <am@osimis.io>
parents: 5080
diff changeset
278 {
5811
a451777236fb advanced storage: fix + customizable path
Alain Mazy <am@orthanc.team>
parents: 5808
diff changeset
279 std::vector<std::string> folderNames;
a451777236fb advanced storage: fix + customizable path
Alain Mazy <am@orthanc.team>
parents: 5808
diff changeset
280 Orthanc::Toolbox::SplitString(folderNames, namingScheme_, '/');
a451777236fb advanced storage: fix + customizable path
Alain Mazy <am@orthanc.team>
parents: 5808
diff changeset
281
a451777236fb advanced storage: fix + customizable path
Alain Mazy <am@orthanc.team>
parents: 5808
diff changeset
282 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
283 {
5811
a451777236fb advanced storage: fix + customizable path
Alain Mazy <am@orthanc.team>
parents: 5808
diff changeset
284 std::string folderName = *it;
a451777236fb advanced storage: fix + customizable path
Alain Mazy <am@orthanc.team>
parents: 5808
diff changeset
285
a451777236fb advanced storage: fix + customizable path
Alain Mazy <am@orthanc.team>
parents: 5808
diff changeset
286 if (folderName.find("$StudyDate$") != std::string::npos)
a451777236fb advanced storage: fix + customizable path
Alain Mazy <am@orthanc.team>
parents: 5808
diff changeset
287 {
a451777236fb advanced storage: fix + customizable path
Alain Mazy <am@orthanc.team>
parents: 5808
diff changeset
288 boost::replace_all(folderName, "$StudyDate$", GetStringDicomTagForPath(tags, "StudyDate", "NO_STUDY_DATE"));
a451777236fb advanced storage: fix + customizable path
Alain Mazy <am@orthanc.team>
parents: 5808
diff changeset
289 }
a451777236fb advanced storage: fix + customizable path
Alain Mazy <am@orthanc.team>
parents: 5808
diff changeset
290
a451777236fb advanced storage: fix + customizable path
Alain Mazy <am@orthanc.team>
parents: 5808
diff changeset
291 if (folderName.find("$split(StudyDate)$"))
a451777236fb advanced storage: fix + customizable path
Alain Mazy <am@orthanc.team>
parents: 5808
diff changeset
292 {
a451777236fb advanced storage: fix + customizable path
Alain Mazy <am@orthanc.team>
parents: 5808
diff changeset
293 boost::replace_all(folderName, "$split(StudyDate)$", GetSplitDateDicomTagToPath(tags, "StudyDate", "NO_STUDY_DATE"));
a451777236fb advanced storage: fix + customizable path
Alain Mazy <am@orthanc.team>
parents: 5808
diff changeset
294 }
a451777236fb advanced storage: fix + customizable path
Alain Mazy <am@orthanc.team>
parents: 5808
diff changeset
295
a451777236fb advanced storage: fix + customizable path
Alain Mazy <am@orthanc.team>
parents: 5808
diff changeset
296 if (folderName.find("$PatientBirthDate$") != std::string::npos)
a451777236fb advanced storage: fix + customizable path
Alain Mazy <am@orthanc.team>
parents: 5808
diff changeset
297 {
a451777236fb advanced storage: fix + customizable path
Alain Mazy <am@orthanc.team>
parents: 5808
diff changeset
298 boost::replace_all(folderName, "$PatientBirthDate$", GetStringDicomTagForPath(tags, "PatientBirthDate", "NO_PATIENT_BIRTH_DATE"));
a451777236fb advanced storage: fix + customizable path
Alain Mazy <am@orthanc.team>
parents: 5808
diff changeset
299 }
a451777236fb advanced storage: fix + customizable path
Alain Mazy <am@orthanc.team>
parents: 5808
diff changeset
300
a451777236fb advanced storage: fix + customizable path
Alain Mazy <am@orthanc.team>
parents: 5808
diff changeset
301 if (folderName.find("$split(PatientBirthDate)$"))
5081
c673997507ea advanced storage cont
Alain Mazy <am@osimis.io>
parents: 5080
diff changeset
302 {
5811
a451777236fb advanced storage: fix + customizable path
Alain Mazy <am@orthanc.team>
parents: 5808
diff changeset
303 boost::replace_all(folderName, "$split(PatientBirthDate)$", GetSplitDateDicomTagToPath(tags, "PatientBirthDate", "NO_PATIENT_BIRTH_DATE"));
a451777236fb advanced storage: fix + customizable path
Alain Mazy <am@orthanc.team>
parents: 5808
diff changeset
304 }
a451777236fb advanced storage: fix + customizable path
Alain Mazy <am@orthanc.team>
parents: 5808
diff changeset
305
a451777236fb advanced storage: fix + customizable path
Alain Mazy <am@orthanc.team>
parents: 5808
diff changeset
306 if (folderName.find("$PatientID$") != std::string::npos)
a451777236fb advanced storage: fix + customizable path
Alain Mazy <am@orthanc.team>
parents: 5808
diff changeset
307 {
a451777236fb advanced storage: fix + customizable path
Alain Mazy <am@orthanc.team>
parents: 5808
diff changeset
308 boost::replace_all(folderName, "$PatientID$", GetStringDicomTagForPath(tags, "PatientID", "EMPTY_PATIENT_ID"));
a451777236fb advanced storage: fix + customizable path
Alain Mazy <am@orthanc.team>
parents: 5808
diff changeset
309 }
a451777236fb advanced storage: fix + customizable path
Alain Mazy <am@orthanc.team>
parents: 5808
diff changeset
310
a451777236fb advanced storage: fix + customizable path
Alain Mazy <am@orthanc.team>
parents: 5808
diff changeset
311 if (folderName.find("$StudyDescription$") != std::string::npos)
a451777236fb advanced storage: fix + customizable path
Alain Mazy <am@orthanc.team>
parents: 5808
diff changeset
312 {
a451777236fb advanced storage: fix + customizable path
Alain Mazy <am@orthanc.team>
parents: 5808
diff changeset
313 boost::replace_all(folderName, "$StudyDescription$", GetStringDicomTagForPath(tags, "StudyDescription", "NO_STUDY_DESCRIPTION"));
a451777236fb advanced storage: fix + customizable path
Alain Mazy <am@orthanc.team>
parents: 5808
diff changeset
314 }
a451777236fb advanced storage: fix + customizable path
Alain Mazy <am@orthanc.team>
parents: 5808
diff changeset
315
a451777236fb advanced storage: fix + customizable path
Alain Mazy <am@orthanc.team>
parents: 5808
diff changeset
316 if (folderName.find("$SeriesDescription$") != std::string::npos)
a451777236fb advanced storage: fix + customizable path
Alain Mazy <am@orthanc.team>
parents: 5808
diff changeset
317 {
a451777236fb advanced storage: fix + customizable path
Alain Mazy <am@orthanc.team>
parents: 5808
diff changeset
318 boost::replace_all(folderName, "$SeriesDescription$", GetStringDicomTagForPath(tags, "SeriesDescription", "NO_SERIES_DESCRIPTION"));
a451777236fb advanced storage: fix + customizable path
Alain Mazy <am@orthanc.team>
parents: 5808
diff changeset
319 }
a451777236fb advanced storage: fix + customizable path
Alain Mazy <am@orthanc.team>
parents: 5808
diff changeset
320
a451777236fb advanced storage: fix + customizable path
Alain Mazy <am@orthanc.team>
parents: 5808
diff changeset
321 if (folderName.find("$StudyInstanceUID$") != std::string::npos)
a451777236fb advanced storage: fix + customizable path
Alain Mazy <am@orthanc.team>
parents: 5808
diff changeset
322 {
a451777236fb advanced storage: fix + customizable path
Alain Mazy <am@orthanc.team>
parents: 5808
diff changeset
323 boost::replace_all(folderName, "$StudyInstanceUID$", GetStringDicomTagForPath(tags, "StudyDescription", "NO_STUDY_INSTANCE_UID"));
5081
c673997507ea advanced storage cont
Alain Mazy <am@osimis.io>
parents: 5080
diff changeset
324 }
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
325
5811
a451777236fb advanced storage: fix + customizable path
Alain Mazy <am@orthanc.team>
parents: 5808
diff changeset
326 if (folderName.find("$SeriesInstanceUID$") != std::string::npos)
a451777236fb advanced storage: fix + customizable path
Alain Mazy <am@orthanc.team>
parents: 5808
diff changeset
327 {
a451777236fb advanced storage: fix + customizable path
Alain Mazy <am@orthanc.team>
parents: 5808
diff changeset
328 boost::replace_all(folderName, "$SeriesInstanceUID$", GetStringDicomTagForPath(tags, "SeriesInstanceUID", "NO_SERIES_INSTANCE_UID"));
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
a451777236fb advanced storage: fix + customizable path
Alain Mazy <am@orthanc.team>
parents: 5808
diff changeset
331 if (folderName.find("$SOPInstanceUID$") != std::string::npos)
a451777236fb advanced storage: fix + customizable path
Alain Mazy <am@orthanc.team>
parents: 5808
diff changeset
332 {
a451777236fb advanced storage: fix + customizable path
Alain Mazy <am@orthanc.team>
parents: 5808
diff changeset
333 boost::replace_all(folderName, "$SOPInstanceUID$", GetStringDicomTagForPath(tags, "SOPInstanceUID", "NO_SOP_INSTANCE_UID"));
a451777236fb advanced storage: fix + customizable path
Alain Mazy <am@orthanc.team>
parents: 5808
diff changeset
334 }
a451777236fb advanced storage: fix + customizable path
Alain Mazy <am@orthanc.team>
parents: 5808
diff changeset
335
a451777236fb advanced storage: fix + customizable path
Alain Mazy <am@orthanc.team>
parents: 5808
diff changeset
336 if (folderName.find("$OrthancPatientID$") != std::string::npos)
5081
c673997507ea advanced storage cont
Alain Mazy <am@osimis.io>
parents: 5080
diff changeset
337 {
5811
a451777236fb advanced storage: fix + customizable path
Alain Mazy <am@orthanc.team>
parents: 5808
diff changeset
338 Orthanc::DicomInstanceHasher hasher(tags["PatientID"].asString(), tags["StudyInstanceUID"].asString(), tags["SeriesInstanceUID"].asString(), tags["SOPInstanceUID"].asString());
a451777236fb advanced storage: fix + customizable path
Alain Mazy <am@orthanc.team>
parents: 5808
diff changeset
339 boost::replace_all(folderName, "$OrthancPatientID$", hasher.HashPatient());
a451777236fb advanced storage: fix + customizable path
Alain Mazy <am@orthanc.team>
parents: 5808
diff changeset
340 }
a451777236fb advanced storage: fix + customizable path
Alain Mazy <am@orthanc.team>
parents: 5808
diff changeset
341
a451777236fb advanced storage: fix + customizable path
Alain Mazy <am@orthanc.team>
parents: 5808
diff changeset
342 if (folderName.find("$OrthancStudyID$") != std::string::npos)
a451777236fb advanced storage: fix + customizable path
Alain Mazy <am@orthanc.team>
parents: 5808
diff changeset
343 {
a451777236fb advanced storage: fix + customizable path
Alain Mazy <am@orthanc.team>
parents: 5808
diff changeset
344 Orthanc::DicomInstanceHasher hasher(tags["PatientID"].asString(), tags["StudyInstanceUID"].asString(), tags["SeriesInstanceUID"].asString(), tags["SOPInstanceUID"].asString());
a451777236fb advanced storage: fix + customizable path
Alain Mazy <am@orthanc.team>
parents: 5808
diff changeset
345 boost::replace_all(folderName, "$OrthancStudyID$", hasher.HashPatient());
a451777236fb advanced storage: fix + customizable path
Alain Mazy <am@orthanc.team>
parents: 5808
diff changeset
346 }
a451777236fb advanced storage: fix + customizable path
Alain Mazy <am@orthanc.team>
parents: 5808
diff changeset
347
a451777236fb advanced storage: fix + customizable path
Alain Mazy <am@orthanc.team>
parents: 5808
diff changeset
348 if (folderName.find("$OrthancSeriesID$") != std::string::npos)
a451777236fb advanced storage: fix + customizable path
Alain Mazy <am@orthanc.team>
parents: 5808
diff changeset
349 {
a451777236fb advanced storage: fix + customizable path
Alain Mazy <am@orthanc.team>
parents: 5808
diff changeset
350 Orthanc::DicomInstanceHasher hasher(tags["PatientID"].asString(), tags["StudyInstanceUID"].asString(), tags["SeriesInstanceUID"].asString(), tags["SOPInstanceUID"].asString());
a451777236fb advanced storage: fix + customizable path
Alain Mazy <am@orthanc.team>
parents: 5808
diff changeset
351 boost::replace_all(folderName, "$OrthancSeriesID$", hasher.HashPatient());
5081
c673997507ea advanced storage cont
Alain Mazy <am@osimis.io>
parents: 5080
diff changeset
352 }
c673997507ea advanced storage cont
Alain Mazy <am@osimis.io>
parents: 5080
diff changeset
353
5811
a451777236fb advanced storage: fix + customizable path
Alain Mazy <am@orthanc.team>
parents: 5808
diff changeset
354 if (folderName.find("$OrthancInstanceID$") != std::string::npos)
a451777236fb advanced storage: fix + customizable path
Alain Mazy <am@orthanc.team>
parents: 5808
diff changeset
355 {
a451777236fb advanced storage: fix + customizable path
Alain Mazy <am@orthanc.team>
parents: 5808
diff changeset
356 Orthanc::DicomInstanceHasher hasher(tags["PatientID"].asString(), tags["StudyInstanceUID"].asString(), tags["SeriesInstanceUID"].asString(), tags["SOPInstanceUID"].asString());
a451777236fb advanced storage: fix + customizable path
Alain Mazy <am@orthanc.team>
parents: 5808
diff changeset
357 boost::replace_all(folderName, "$OrthancInstanceID$", hasher.HashPatient());
a451777236fb advanced storage: fix + customizable path
Alain Mazy <am@orthanc.team>
parents: 5808
diff changeset
358 }
a451777236fb advanced storage: fix + customizable path
Alain Mazy <am@orthanc.team>
parents: 5808
diff changeset
359
a451777236fb advanced storage: fix + customizable path
Alain Mazy <am@orthanc.team>
parents: 5808
diff changeset
360 if (folderName.find("$UUID$") != std::string::npos)
a451777236fb advanced storage: fix + customizable path
Alain Mazy <am@orthanc.team>
parents: 5808
diff changeset
361 {
a451777236fb advanced storage: fix + customizable path
Alain Mazy <am@orthanc.team>
parents: 5808
diff changeset
362 boost::replace_all(folderName, "$UUID$", uuid);
a451777236fb advanced storage: fix + customizable path
Alain Mazy <am@orthanc.team>
parents: 5808
diff changeset
363 foundUuid = true;
a451777236fb advanced storage: fix + customizable path
Alain Mazy <am@orthanc.team>
parents: 5808
diff changeset
364 }
5081
c673997507ea advanced storage cont
Alain Mazy <am@osimis.io>
parents: 5080
diff changeset
365
5811
a451777236fb advanced storage: fix + customizable path
Alain Mazy <am@orthanc.team>
parents: 5808
diff changeset
366 if (folderName.find("$.ext$") != std::string::npos)
a451777236fb advanced storage: fix + customizable path
Alain Mazy <am@orthanc.team>
parents: 5808
diff changeset
367 {
a451777236fb advanced storage: fix + customizable path
Alain Mazy <am@orthanc.team>
parents: 5808
diff changeset
368 boost::replace_all(folderName, "$.ext$", GetExtension(type, isCompressed));
a451777236fb advanced storage: fix + customizable path
Alain Mazy <am@orthanc.team>
parents: 5808
diff changeset
369 }
a451777236fb advanced storage: fix + customizable path
Alain Mazy <am@orthanc.team>
parents: 5808
diff changeset
370
a451777236fb advanced storage: fix + customizable path
Alain Mazy <am@orthanc.team>
parents: 5808
diff changeset
371 path /= folderName;
5081
c673997507ea advanced storage cont
Alain Mazy <am@osimis.io>
parents: 5080
diff changeset
372 }
5811
a451777236fb advanced storage: fix + customizable path
Alain Mazy <am@orthanc.team>
parents: 5808
diff changeset
373
a451777236fb advanced storage: fix + customizable path
Alain Mazy <am@orthanc.team>
parents: 5808
diff changeset
374 if (!foundUuid)
a451777236fb advanced storage: fix + customizable path
Alain Mazy <am@orthanc.team>
parents: 5808
diff changeset
375 {
a451777236fb advanced storage: fix + customizable path
Alain Mazy <am@orthanc.team>
parents: 5808
diff changeset
376 LOG(WARNING) << "Your naming scheme does not contain $UUID$. There is a high risk of files being overwritten. Using the default naming scheme.";
a451777236fb advanced storage: fix + customizable path
Alain Mazy <am@orthanc.team>
parents: 5808
diff changeset
377 return GetLegacyRelativePath(uuid);
a451777236fb advanced storage: fix + customizable path
Alain Mazy <am@orthanc.team>
parents: 5808
diff changeset
378 }
a451777236fb advanced storage: fix + customizable path
Alain Mazy <am@orthanc.team>
parents: 5808
diff changeset
379
a451777236fb advanced storage: fix + customizable path
Alain Mazy <am@orthanc.team>
parents: 5808
diff changeset
380 return path;
5081
c673997507ea advanced storage cont
Alain Mazy <am@osimis.io>
parents: 5080
diff changeset
381 }
c673997507ea advanced storage cont
Alain Mazy <am@osimis.io>
parents: 5080
diff changeset
382
c673997507ea advanced storage cont
Alain Mazy <am@osimis.io>
parents: 5080
diff changeset
383 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
384 }
d7274e43ea7c allow plugins to store a customData in the Attachments table to e.g. store custom paths without requiring an external DB
Alain Mazy <am@osimis.io>
parents:
diff changeset
385
d7274e43ea7c allow plugins to store a customData in the Attachments table to e.g. store custom paths without requiring an external DB
Alain Mazy <am@osimis.io>
parents:
diff changeset
386
d7274e43ea7c allow plugins to store a customData in the Attachments table to e.g. store custom paths without requiring an external DB
Alain Mazy <am@osimis.io>
parents:
diff changeset
387 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
388 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
389 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
390 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
391 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
392 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
393 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
394 {
d7274e43ea7c allow plugins to store a customData in the Attachments table to e.g. store custom paths without requiring an external DB
Alain Mazy <am@osimis.io>
parents:
diff changeset
395 fs::path relativePath = GetRelativePathFromTags(tags, uuid, type, isCompressed);
5081
c673997507ea advanced storage cont
Alain Mazy <am@osimis.io>
parents: 5080
diff changeset
396 std::string customDataString;
c673997507ea advanced storage cont
Alain Mazy <am@osimis.io>
parents: 5080
diff changeset
397 GetCustomData(customDataString, relativePath);
c673997507ea advanced storage cont
Alain Mazy <am@osimis.io>
parents: 5080
diff changeset
398
c673997507ea advanced storage cont
Alain Mazy <am@osimis.io>
parents: 5080
diff changeset
399 fs::path rootPath = GetRootPath();
c673997507ea advanced storage cont
Alain Mazy <am@osimis.io>
parents: 5080
diff changeset
400 fs::path path = rootPath / relativePath;
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 LOG(INFO) << "Advanced Storage - creating 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
403
5081
c673997507ea advanced storage cont
Alain Mazy <am@osimis.io>
parents: 5080
diff changeset
404 // 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
405 // fs::canonical() can not be used for that since the file needs to exist
Alain Mazy <am@osimis.io>
parents: 5081
diff changeset
406 // so far, we'll just forbid path containing '..' since they might be suspicious
Alain Mazy <am@osimis.io>
parents: 5081
diff changeset
407 if (path.string().find("..") != std::string::npos)
5081
c673997507ea advanced storage cont
Alain Mazy <am@osimis.io>
parents: 5080
diff changeset
408 {
5082
Alain Mazy <am@osimis.io>
parents: 5081
diff changeset
409 fs::path legacyPath = rootPath / GetLegacyRelativePath(uuid);
Alain Mazy <am@osimis.io>
parents: 5081
diff changeset
410 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
411 path = legacyPath;
5081
c673997507ea advanced storage cont
Alain Mazy <am@osimis.io>
parents: 5080
diff changeset
412 }
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
413
5081
c673997507ea advanced storage cont
Alain Mazy <am@osimis.io>
parents: 5080
diff changeset
414 // 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
415 if (path.string().size() > maxPathLength_)
c673997507ea advanced storage cont
Alain Mazy <am@osimis.io>
parents: 5080
diff changeset
416 {
c673997507ea advanced storage cont
Alain Mazy <am@osimis.io>
parents: 5080
diff changeset
417 fs::path legacyPath = rootPath / GetLegacyRelativePath(uuid);
c673997507ea advanced storage cont
Alain Mazy <am@osimis.io>
parents: 5080
diff changeset
418 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
419 path = legacyPath;
c673997507ea advanced storage cont
Alain Mazy <am@osimis.io>
parents: 5080
diff changeset
420 }
c673997507ea advanced storage cont
Alain Mazy <am@osimis.io>
parents: 5080
diff changeset
421
c673997507ea advanced storage cont
Alain Mazy <am@osimis.io>
parents: 5080
diff changeset
422 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
423 {
d7274e43ea7c allow plugins to store a customData in the Attachments table to e.g. store custom paths without requiring an external DB
Alain Mazy <am@osimis.io>
parents:
diff changeset
424 // 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
425 // in the past.
5081
c673997507ea advanced storage cont
Alain Mazy <am@osimis.io>
parents: 5080
diff changeset
426 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
427
d7274e43ea7c allow plugins to store a customData in the Attachments table to e.g. store custom paths without requiring an external DB
Alain Mazy <am@osimis.io>
parents:
diff changeset
428 // 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
429 }
d7274e43ea7c allow plugins to store a customData in the Attachments table to e.g. store custom paths without requiring an external DB
Alain Mazy <am@osimis.io>
parents:
diff changeset
430
5081
c673997507ea advanced storage cont
Alain Mazy <am@osimis.io>
parents: 5080
diff changeset
431 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
432 {
5081
c673997507ea advanced storage cont
Alain Mazy <am@osimis.io>
parents: 5080
diff changeset
433 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
434 {
d7274e43ea7c allow plugins to store a customData in the Attachments table to e.g. store custom paths without requiring an external DB
Alain Mazy <am@osimis.io>
parents:
diff changeset
435 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
436 }
d7274e43ea7c allow plugins to store a customData in the Attachments table to e.g. store custom paths without requiring an external DB
Alain Mazy <am@osimis.io>
parents:
diff changeset
437 }
d7274e43ea7c allow plugins to store a customData in the Attachments table to e.g. store custom paths without requiring an external DB
Alain Mazy <am@osimis.io>
parents:
diff changeset
438 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
439 {
5081
c673997507ea advanced storage cont
Alain Mazy <am@osimis.io>
parents: 5080
diff changeset
440 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
441 {
d7274e43ea7c allow plugins to store a 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 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
443 }
d7274e43ea7c allow plugins to store a 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
5081
c673997507ea advanced storage cont
Alain Mazy <am@osimis.io>
parents: 5080
diff changeset
446 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
447
d7274e43ea7c allow plugins to store a customData in the Attachments table to e.g. store custom paths without requiring an external DB
Alain Mazy <am@osimis.io>
parents:
diff changeset
448 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
449 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
450
d7274e43ea7c allow plugins to store a customData in the Attachments table to e.g. store custom paths without requiring an external DB
Alain Mazy <am@osimis.io>
parents:
diff changeset
451 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
452
d7274e43ea7c allow plugins to store a customData in the Attachments table to e.g. store custom paths without requiring an external DB
Alain Mazy <am@osimis.io>
parents:
diff changeset
453 }
d7274e43ea7c allow plugins to store a customData in the Attachments table to e.g. store custom paths without requiring an external DB
Alain Mazy <am@osimis.io>
parents:
diff changeset
454
d7274e43ea7c allow plugins to store a 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 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
456 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
457 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
458 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
459 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
460 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
461 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
462 {
d7274e43ea7c allow plugins to store a customData in the Attachments table to e.g. store custom paths without requiring an external DB
Alain Mazy <am@osimis.io>
parents:
diff changeset
463 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
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 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
466 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
467 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
468
d7274e43ea7c allow plugins to store a customData in the Attachments table to e.g. store custom paths without requiring an external DB
Alain Mazy <am@osimis.io>
parents:
diff changeset
469 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
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 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
472 {
d7274e43ea7c allow plugins to store a 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 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
474 }
d7274e43ea7c allow plugins to store a 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 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
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 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
478 }
d7274e43ea7c allow plugins to store a 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
d7274e43ea7c allow plugins to store a 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 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
481 }
d7274e43ea7c allow plugins to store a 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
d7274e43ea7c allow plugins to store a 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
d7274e43ea7c allow plugins to store a 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 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
485 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
486 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
487 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
488 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
489 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
490 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
491 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
492 {
d7274e43ea7c allow plugins to store a 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 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
494 {
5807
8279eaab0d1d merged default -> attach-custom-data
Alain Mazy <am@orthanc.team>
parents: 5085
diff changeset
495 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
496
d7274e43ea7c allow plugins to store a 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 //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
498 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
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 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
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 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
503 {
d7274e43ea7c allow plugins to store a 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 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
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 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
507 {
d7274e43ea7c allow plugins to store a 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 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
509 }
d7274e43ea7c allow plugins to store a 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
d7274e43ea7c allow plugins to store a 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 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
512 }
d7274e43ea7c allow plugins to store a 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
d7274e43ea7c allow plugins to store a 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 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
515 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
516 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
517 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
518 {
5081
c673997507ea advanced storage cont
Alain Mazy <am@osimis.io>
parents: 5080
diff changeset
519 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
520
5081
c673997507ea advanced storage cont
Alain Mazy <am@osimis.io>
parents: 5080
diff changeset
521 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
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 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
524 {
5807
8279eaab0d1d merged default -> attach-custom-data
Alain Mazy <am@orthanc.team>
parents: 5085
diff changeset
525 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
526 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
527 }
d7274e43ea7c allow plugins to store a 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 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
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 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
532 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
533 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
534 {
5807
8279eaab0d1d merged default -> attach-custom-data
Alain Mazy <am@orthanc.team>
parents: 5085
diff changeset
535 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
536 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
537 }
d7274e43ea7c allow plugins to store a 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
d7274e43ea7c allow plugins to store a 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 // 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
540 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
541 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
542 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
543
d7274e43ea7c allow plugins to store a customData in the Attachments table to e.g. store custom paths without requiring an external DB
Alain Mazy <am@osimis.io>
parents:
diff changeset
544 // 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
545 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
546 {
5807
8279eaab0d1d merged default -> attach-custom-data
Alain Mazy <am@orthanc.team>
parents: 5085
diff changeset
547 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
548 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
549 }
d7274e43ea7c allow plugins to store a 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 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
552 {
d7274e43ea7c allow plugins to store a 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 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
554 }
d7274e43ea7c allow plugins to store a 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
d7274e43ea7c allow plugins to store a 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 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
557 }
d7274e43ea7c allow plugins to store a customData in the Attachments table to e.g. store custom paths without requiring an external DB
Alain Mazy <am@osimis.io>
parents:
diff changeset
558 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
559 {
5807
8279eaab0d1d merged default -> attach-custom-data
Alain Mazy <am@orthanc.team>
parents: 5085
diff changeset
560 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
561 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
562 }
d7274e43ea7c allow plugins to store a 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
d7274e43ea7c allow plugins to store a 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 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
565 }
d7274e43ea7c allow plugins to store a 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
d7274e43ea7c allow plugins to store a 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 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
569 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
570 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
571 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
572 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
573 {
5081
c673997507ea advanced storage cont
Alain Mazy <am@osimis.io>
parents: 5080
diff changeset
574 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
575
5081
c673997507ea advanced storage cont
Alain Mazy <am@osimis.io>
parents: 5080
diff changeset
576 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
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 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
579 {
5807
8279eaab0d1d merged default -> attach-custom-data
Alain Mazy <am@orthanc.team>
parents: 5085
diff changeset
580 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
581 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
582 }
d7274e43ea7c allow plugins to store a customData in the Attachments table to e.g. store custom paths without requiring an external DB
Alain Mazy <am@osimis.io>
parents:
diff changeset
583
d7274e43ea7c allow plugins to store a 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 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
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 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
587 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
588 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
589 {
5807
8279eaab0d1d merged default -> attach-custom-data
Alain Mazy <am@orthanc.team>
parents: 5085
diff changeset
590 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
591 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
592 }
d7274e43ea7c allow plugins to store a 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
d7274e43ea7c allow plugins to store a 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 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
595
d7274e43ea7c allow plugins to store a 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 // 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
597 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
598
d7274e43ea7c allow plugins to store a customData in the Attachments table to e.g. store custom paths without requiring an external DB
Alain Mazy <am@osimis.io>
parents:
diff changeset
599 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
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 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
602 {
5807
8279eaab0d1d merged default -> attach-custom-data
Alain Mazy <am@orthanc.team>
parents: 5085
diff changeset
603 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
604 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
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 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
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
d7274e43ea7c allow plugins to store a 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
d7274e43ea7c allow plugins to store a 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 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
612 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
613 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
614 {
5081
c673997507ea advanced storage cont
Alain Mazy <am@osimis.io>
parents: 5080
diff changeset
615 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
616
5081
c673997507ea advanced storage cont
Alain Mazy <am@osimis.io>
parents: 5080
diff changeset
617 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
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 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
620 {
5081
c673997507ea advanced storage cont
Alain Mazy <am@osimis.io>
parents: 5080
diff changeset
621 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
622 }
d7274e43ea7c allow plugins to store a 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 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
624 {
d7274e43ea7c allow plugins to store a 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 // 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
626 }
d7274e43ea7c allow plugins to store a 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
d7274e43ea7c allow plugins to store a 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 // 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
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 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
631 {
5081
c673997507ea advanced storage cont
Alain Mazy <am@osimis.io>
parents: 5080
diff changeset
632 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
633
5081
c673997507ea advanced storage cont
Alain Mazy <am@osimis.io>
parents: 5080
diff changeset
634 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
635 {
d7274e43ea7c allow plugins to store a 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 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
637 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
638 }
d7274e43ea7c allow plugins to store a 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 }
d7274e43ea7c allow plugins to store a customData in the Attachments table to e.g. store custom paths without requiring an external DB
Alain Mazy <am@osimis.io>
parents:
diff changeset
640 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
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 // 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
643 }
d7274e43ea7c allow plugins to store a customData in the Attachments table to e.g. store custom paths without requiring an external DB
Alain Mazy <am@osimis.io>
parents:
diff changeset
644
d7274e43ea7c allow plugins to store a 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 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
646 }
d7274e43ea7c allow plugins to store a 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 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
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 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
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 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
654 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
655
d7274e43ea7c allow plugins to store a 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 /* 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
657 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
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 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
660 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
661 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
662 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
663 }
d7274e43ea7c allow plugins to store a 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
5807
8279eaab0d1d merged default -> attach-custom-data
Alain Mazy <am@orthanc.team>
parents: 5085
diff changeset
665 LOG(WARNING) << "AdvancedStorage plugin is initializing";
8279eaab0d1d merged default -> attach-custom-data
Alain Mazy <am@orthanc.team>
parents: 5085
diff changeset
666 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
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 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
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 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
671 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
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 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
674 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
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 /*
d7274e43ea7c allow plugins to store a 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 {
d7274e43ea7c allow plugins to store a 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 "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
679
d7274e43ea7c allow plugins to store a 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 // 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
681 "Enable": false,
5081
c673997507ea advanced storage cont
Alain Mazy <am@osimis.io>
parents: 5080
diff changeset
682
c673997507ea advanced storage cont
Alain Mazy <am@osimis.io>
parents: 5080
diff changeset
683 // Enables/disables support for multiple StorageDirectories
c673997507ea advanced storage cont
Alain Mazy <am@osimis.io>
parents: 5080
diff changeset
684 "MultipleStorages" : {
c673997507ea advanced storage cont
Alain Mazy <am@osimis.io>
parents: 5080
diff changeset
685 "Storages" : {
c673997507ea advanced storage cont
Alain Mazy <am@osimis.io>
parents: 5080
diff changeset
686 // The storgae ids below may never change since they are stored in DB
c673997507ea advanced storage cont
Alain Mazy <am@osimis.io>
parents: 5080
diff changeset
687 // The storage path may change in case you move your data from one place to the other
c673997507ea advanced storage cont
Alain Mazy <am@osimis.io>
parents: 5080
diff changeset
688 "1" : "/var/lib/orthanc/db",
c673997507ea advanced storage cont
Alain Mazy <am@osimis.io>
parents: 5080
diff changeset
689 "2" : "/mnt/disk2/orthanc"
c673997507ea advanced storage cont
Alain Mazy <am@osimis.io>
parents: 5080
diff changeset
690 },
c673997507ea advanced storage cont
Alain Mazy <am@osimis.io>
parents: 5080
diff changeset
691
c673997507ea advanced storage cont
Alain Mazy <am@osimis.io>
parents: 5080
diff changeset
692 // the storage on which new data is stored.
c673997507ea advanced storage cont
Alain Mazy <am@osimis.io>
parents: 5080
diff changeset
693 // There's currently no automatic changes of disks
c673997507ea advanced storage cont
Alain Mazy <am@osimis.io>
parents: 5080
diff changeset
694 "CurrentStorage" : "2",
c673997507ea advanced storage cont
Alain Mazy <am@osimis.io>
parents: 5080
diff changeset
695 },
c673997507ea advanced storage cont
Alain Mazy <am@osimis.io>
parents: 5080
diff changeset
696
c673997507ea advanced storage cont
Alain Mazy <am@osimis.io>
parents: 5080
diff changeset
697 // Defines the storage structure and file namings. Right now,
c673997507ea advanced storage cont
Alain Mazy <am@osimis.io>
parents: 5080
diff changeset
698 // only the "OrthancDefault" value shall be used in a production environment.
c673997507ea advanced storage cont
Alain Mazy <am@osimis.io>
parents: 5080
diff changeset
699 // All other values are currently experimental
c673997507ea advanced storage cont
Alain Mazy <am@osimis.io>
parents: 5080
diff changeset
700 // "OrthancDefault" = same structure and file naming as default orthanc,
c673997507ea advanced storage cont
Alain Mazy <am@osimis.io>
parents: 5080
diff changeset
701 // "Preset1-StudyDatePatientID" = split(StudyDate)/PatientID - PatientName/StudyDescription/SeriesInstanceUID/uuid.ext
5811
a451777236fb advanced storage: fix + customizable path
Alain Mazy <am@orthanc.team>
parents: 5808
diff changeset
702 // "Preset2-OrthancStudyID-OrthancSeriesID-UUID" = OrthancStudyID/OrthancSeriesID/uuid.ext
5081
c673997507ea advanced storage cont
Alain Mazy <am@osimis.io>
parents: 5080
diff changeset
703 "NamingScheme" : "OrthancDefault",
c673997507ea advanced storage cont
Alain Mazy <am@osimis.io>
parents: 5080
diff changeset
704
c673997507ea advanced storage cont
Alain Mazy <am@osimis.io>
parents: 5080
diff changeset
705 // 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
706 // 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
707 // (and a warning is issued).
c673997507ea advanced storage cont
Alain Mazy <am@osimis.io>
parents: 5080
diff changeset
708 // 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
709 // through a configuration.
c673997507ea advanced storage cont
Alain Mazy <am@osimis.io>
parents: 5080
diff changeset
710 "MaxPathLength" : 256
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
711 }
d7274e43ea7c allow plugins to store a customData in the Attachments table to e.g. store custom paths without requiring an external DB
Alain Mazy <am@osimis.io>
parents:
diff changeset
712 }
d7274e43ea7c allow plugins to store a customData in the Attachments table to e.g. store custom paths without requiring an external DB
Alain Mazy <am@osimis.io>
parents:
diff changeset
713 */
d7274e43ea7c allow plugins to store a customData in the Attachments table to e.g. store custom paths without requiring an external DB
Alain Mazy <am@osimis.io>
parents:
diff changeset
714
5081
c673997507ea advanced storage cont
Alain Mazy <am@osimis.io>
parents: 5080
diff changeset
715 fsyncOnWrite_ = orthancConfiguration.GetBooleanValue("SyncStorageArea", true);
c673997507ea advanced storage cont
Alain Mazy <am@osimis.io>
parents: 5080
diff changeset
716
c673997507ea advanced storage cont
Alain Mazy <am@osimis.io>
parents: 5080
diff changeset
717 const Json::Value& pluginJson = advancedStorage.GetJson();
c673997507ea advanced storage cont
Alain Mazy <am@osimis.io>
parents: 5080
diff changeset
718
c673997507ea advanced storage cont
Alain Mazy <am@osimis.io>
parents: 5080
diff changeset
719 namingScheme_ = advancedStorage.GetStringValue("NamingScheme", "OrthancDefault");
5811
a451777236fb advanced storage: fix + customizable path
Alain Mazy <am@orthanc.team>
parents: 5808
diff changeset
720 if (namingScheme_ != "OrthancDefault" && namingScheme_.find("$UUID") == std::string::npos)
a451777236fb advanced storage: fix + customizable path
Alain Mazy <am@orthanc.team>
parents: 5808
diff changeset
721 {
a451777236fb advanced storage: fix + customizable path
Alain Mazy <am@orthanc.team>
parents: 5808
diff changeset
722 LOG(ERROR) << "AdvancedStorage - Your naming scheme does not contain $UUID$. The risk of files being overwritten is to high.";
a451777236fb advanced storage: fix + customizable path
Alain Mazy <am@orthanc.team>
parents: 5808
diff changeset
723 return -1;
a451777236fb advanced storage: fix + customizable path
Alain Mazy <am@orthanc.team>
parents: 5808
diff changeset
724 }
5081
c673997507ea advanced storage cont
Alain Mazy <am@osimis.io>
parents: 5080
diff changeset
725
c673997507ea advanced storage cont
Alain Mazy <am@osimis.io>
parents: 5080
diff changeset
726 // 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
727 rootPath_ = fs::path(orthancConfiguration.GetStringValue("StorageDirectory", "OrthancStorage"));
c673997507ea advanced storage cont
Alain Mazy <am@osimis.io>
parents: 5080
diff changeset
728 LOG(WARNING) << "AdvancedStorage - Path to the default storage area: " << rootPath_.string();
c673997507ea advanced storage cont
Alain Mazy <am@osimis.io>
parents: 5080
diff changeset
729
c673997507ea advanced storage cont
Alain Mazy <am@osimis.io>
parents: 5080
diff changeset
730 maxPathLength_ = orthancConfiguration.GetIntegerValue("MaxPathLength", 256);
c673997507ea advanced storage cont
Alain Mazy <am@osimis.io>
parents: 5080
diff changeset
731 LOG(WARNING) << "AdvancedStorage - Maximum path length: " << maxPathLength_;
c673997507ea advanced storage cont
Alain Mazy <am@osimis.io>
parents: 5080
diff changeset
732
c673997507ea advanced storage cont
Alain Mazy <am@osimis.io>
parents: 5080
diff changeset
733 if (!rootPath_.is_absolute())
c673997507ea advanced storage cont
Alain Mazy <am@osimis.io>
parents: 5080
diff changeset
734 {
5811
a451777236fb advanced storage: fix + customizable path
Alain Mazy <am@orthanc.team>
parents: 5808
diff changeset
735 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
736 return -1;
c673997507ea advanced storage cont
Alain Mazy <am@osimis.io>
parents: 5080
diff changeset
737 }
c673997507ea advanced storage cont
Alain Mazy <am@osimis.io>
parents: 5080
diff changeset
738
c673997507ea advanced storage cont
Alain Mazy <am@osimis.io>
parents: 5080
diff changeset
739 if (rootPath_.size() > (maxPathLength_ - legacyPathLength))
c673997507ea advanced storage cont
Alain Mazy <am@osimis.io>
parents: 5080
diff changeset
740 {
c673997507ea advanced storage cont
Alain Mazy <am@osimis.io>
parents: 5080
diff changeset
741 LOG(ERROR) << "AdvancedStorage - Path to the default storage is too long";
c673997507ea advanced storage cont
Alain Mazy <am@osimis.io>
parents: 5080
diff changeset
742 return -1;
c673997507ea advanced storage cont
Alain Mazy <am@osimis.io>
parents: 5080
diff changeset
743 }
c673997507ea advanced storage cont
Alain Mazy <am@osimis.io>
parents: 5080
diff changeset
744
c673997507ea advanced storage cont
Alain Mazy <am@osimis.io>
parents: 5080
diff changeset
745 if (pluginJson.isMember("MultipleStorages"))
c673997507ea advanced storage cont
Alain Mazy <am@osimis.io>
parents: 5080
diff changeset
746 {
c673997507ea advanced storage cont
Alain Mazy <am@osimis.io>
parents: 5080
diff changeset
747 multipleStoragesEnabled_ = true;
c673997507ea advanced storage cont
Alain Mazy <am@osimis.io>
parents: 5080
diff changeset
748 const Json::Value& multipleStoragesJson = pluginJson["MultipleStorages"];
c673997507ea advanced storage cont
Alain Mazy <am@osimis.io>
parents: 5080
diff changeset
749
c673997507ea advanced storage cont
Alain Mazy <am@osimis.io>
parents: 5080
diff changeset
750 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
751 {
c673997507ea advanced storage cont
Alain Mazy <am@osimis.io>
parents: 5080
diff changeset
752 const Json::Value& storagesJson = multipleStoragesJson["Storages"];
c673997507ea advanced storage cont
Alain Mazy <am@osimis.io>
parents: 5080
diff changeset
753 Json::Value::Members storageIds = storagesJson.getMemberNames();
c673997507ea advanced storage cont
Alain Mazy <am@osimis.io>
parents: 5080
diff changeset
754
c673997507ea advanced storage cont
Alain Mazy <am@osimis.io>
parents: 5080
diff changeset
755 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
756 {
c673997507ea advanced storage cont
Alain Mazy <am@osimis.io>
parents: 5080
diff changeset
757 const Json::Value& storagePath = storagesJson[*it];
c673997507ea advanced storage cont
Alain Mazy <am@osimis.io>
parents: 5080
diff changeset
758 if (!storagePath.isString())
c673997507ea advanced storage cont
Alain Mazy <am@osimis.io>
parents: 5080
diff changeset
759 {
c673997507ea advanced storage cont
Alain Mazy <am@osimis.io>
parents: 5080
diff changeset
760 LOG(ERROR) << "AdvancedStorage - Storage path is not a string " << *it;
c673997507ea advanced storage cont
Alain Mazy <am@osimis.io>
parents: 5080
diff changeset
761 return -1;
c673997507ea advanced storage cont
Alain Mazy <am@osimis.io>
parents: 5080
diff changeset
762 }
c673997507ea advanced storage cont
Alain Mazy <am@osimis.io>
parents: 5080
diff changeset
763
c673997507ea advanced storage cont
Alain Mazy <am@osimis.io>
parents: 5080
diff changeset
764 rootPaths_[*it] = storagePath.asString();
c673997507ea advanced storage cont
Alain Mazy <am@osimis.io>
parents: 5080
diff changeset
765
c673997507ea advanced storage cont
Alain Mazy <am@osimis.io>
parents: 5080
diff changeset
766 if (!rootPaths_[*it].is_absolute())
c673997507ea advanced storage cont
Alain Mazy <am@osimis.io>
parents: 5080
diff changeset
767 {
c673997507ea advanced storage cont
Alain Mazy <am@osimis.io>
parents: 5080
diff changeset
768 LOG(ERROR) << "AdvancedStorage - Storage path shall be absolute path '" << storagePath.asString() << "'";
c673997507ea advanced storage cont
Alain Mazy <am@osimis.io>
parents: 5080
diff changeset
769 return -1;
c673997507ea advanced storage cont
Alain Mazy <am@osimis.io>
parents: 5080
diff changeset
770 }
c673997507ea advanced storage cont
Alain Mazy <am@osimis.io>
parents: 5080
diff changeset
771
c673997507ea advanced storage cont
Alain Mazy <am@osimis.io>
parents: 5080
diff changeset
772 if (storagePath.asString().size() > (maxPathLength_ - legacyPathLength))
c673997507ea advanced storage cont
Alain Mazy <am@osimis.io>
parents: 5080
diff changeset
773 {
c673997507ea advanced storage cont
Alain Mazy <am@osimis.io>
parents: 5080
diff changeset
774 LOG(ERROR) << "AdvancedStorage - Storage path is too long '" << storagePath.asString() << "'";
c673997507ea advanced storage cont
Alain Mazy <am@osimis.io>
parents: 5080
diff changeset
775 return -1;
c673997507ea advanced storage cont
Alain Mazy <am@osimis.io>
parents: 5080
diff changeset
776 }
c673997507ea advanced storage cont
Alain Mazy <am@osimis.io>
parents: 5080
diff changeset
777 }
c673997507ea advanced storage cont
Alain Mazy <am@osimis.io>
parents: 5080
diff changeset
778
c673997507ea advanced storage cont
Alain Mazy <am@osimis.io>
parents: 5080
diff changeset
779 currentStorageId_ = multipleStoragesJson["CurrentStorage"].asString();
c673997507ea advanced storage cont
Alain Mazy <am@osimis.io>
parents: 5080
diff changeset
780
c673997507ea advanced storage cont
Alain Mazy <am@osimis.io>
parents: 5080
diff changeset
781 if (rootPaths_.find(currentStorageId_) == rootPaths_.end())
c673997507ea advanced storage cont
Alain Mazy <am@osimis.io>
parents: 5080
diff changeset
782 {
c673997507ea advanced storage cont
Alain Mazy <am@osimis.io>
parents: 5080
diff changeset
783 LOG(ERROR) << "AdvancedStorage - CurrentStorage is not defined in Storages list: " << currentStorageId_;
c673997507ea advanced storage cont
Alain Mazy <am@osimis.io>
parents: 5080
diff changeset
784 return -1;
c673997507ea advanced storage cont
Alain Mazy <am@osimis.io>
parents: 5080
diff changeset
785 }
c673997507ea advanced storage cont
Alain Mazy <am@osimis.io>
parents: 5080
diff changeset
786
c673997507ea advanced storage cont
Alain Mazy <am@osimis.io>
parents: 5080
diff changeset
787 LOG(WARNING) << "AdvancedStorage - multiple storages enabled. Current storage : " << rootPaths_[currentStorageId_].string();
c673997507ea advanced storage cont
Alain Mazy <am@osimis.io>
parents: 5080
diff changeset
788 }
c673997507ea advanced storage cont
Alain Mazy <am@osimis.io>
parents: 5080
diff changeset
789 }
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
790
d7274e43ea7c allow plugins to store a customData in the Attachments table to e.g. store custom paths without requiring an external DB
Alain Mazy <am@osimis.io>
parents:
diff changeset
791 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
792 }
d7274e43ea7c allow plugins to store a customData in the Attachments table to e.g. store custom paths without requiring an external DB
Alain Mazy <am@osimis.io>
parents:
diff changeset
793 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
794 {
5807
8279eaab0d1d merged default -> attach-custom-data
Alain Mazy <am@orthanc.team>
parents: 5085
diff changeset
795 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
796 }
d7274e43ea7c allow plugins to store a customData in the Attachments table to e.g. store custom paths without requiring an external DB
Alain Mazy <am@osimis.io>
parents:
diff changeset
797
d7274e43ea7c allow plugins to store a customData in the Attachments table to e.g. store custom paths without requiring an external DB
Alain Mazy <am@osimis.io>
parents:
diff changeset
798 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
799 }
d7274e43ea7c allow plugins to store a customData in the Attachments table to e.g. store custom paths without requiring an external DB
Alain Mazy <am@osimis.io>
parents:
diff changeset
800
d7274e43ea7c allow plugins to store a customData in the Attachments table to e.g. store custom paths without requiring an external DB
Alain Mazy <am@osimis.io>
parents:
diff changeset
801
d7274e43ea7c allow plugins to store a customData in the Attachments table to e.g. store custom paths without requiring an external DB
Alain Mazy <am@osimis.io>
parents:
diff changeset
802 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
803 {
5807
8279eaab0d1d merged default -> attach-custom-data
Alain Mazy <am@orthanc.team>
parents: 5085
diff changeset
804 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
805 }
d7274e43ea7c allow plugins to store a customData in the Attachments table to e.g. store custom paths without requiring an external DB
Alain Mazy <am@osimis.io>
parents:
diff changeset
806
d7274e43ea7c allow plugins to store a customData in the Attachments table to e.g. store custom paths without requiring an external DB
Alain Mazy <am@osimis.io>
parents:
diff changeset
807
d7274e43ea7c allow plugins to store a customData in the Attachments table to e.g. store custom paths without requiring an external DB
Alain Mazy <am@osimis.io>
parents:
diff changeset
808 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
809 {
5807
8279eaab0d1d merged default -> attach-custom-data
Alain Mazy <am@orthanc.team>
parents: 5085
diff changeset
810 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
811 }
d7274e43ea7c allow plugins to store a customData in the Attachments table to e.g. store custom paths without requiring an external DB
Alain Mazy <am@osimis.io>
parents:
diff changeset
812
d7274e43ea7c allow plugins to store a customData in the Attachments table to e.g. store custom paths without requiring an external DB
Alain Mazy <am@osimis.io>
parents:
diff changeset
813
d7274e43ea7c allow plugins to store a customData in the Attachments table to e.g. store custom paths without requiring an external DB
Alain Mazy <am@osimis.io>
parents:
diff changeset
814 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
815 {
5807
8279eaab0d1d merged default -> attach-custom-data
Alain Mazy <am@orthanc.team>
parents: 5085
diff changeset
816 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
817 }
d7274e43ea7c allow plugins to store a customData in the Attachments table to e.g. store custom paths without requiring an external DB
Alain Mazy <am@osimis.io>
parents:
diff changeset
818 }