annotate Core/FileStorage/CompressedFileStorageAccessor.cpp @ 1401:67dca9b38c49

fix
author Sebastien Jodogne <s.jodogne@gmail.com>
date Mon, 01 Jun 2015 14:08:30 +0200
parents 6e7e5ed91c2d
children f967bdf8534e
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
221
e7432706b354 accessors to storage
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1 /**
e7432706b354 accessors to storage
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
2 * Orthanc - A Lightweight, RESTful DICOM Store
1288
6e7e5ed91c2d upgrade to year 2015
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1137
diff changeset
3 * Copyright (C) 2012-2015 Sebastien Jodogne, Medical Physics
6e7e5ed91c2d upgrade to year 2015
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1137
diff changeset
4 * Department, University Hospital of Liege, Belgium
221
e7432706b354 accessors to storage
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
5 *
e7432706b354 accessors to storage
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
6 * This program is free software: you can redistribute it and/or
e7432706b354 accessors to storage
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
7 * modify it under the terms of the GNU General Public License as
e7432706b354 accessors to storage
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
8 * published by the Free Software Foundation, either version 3 of the
e7432706b354 accessors to storage
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
9 * License, or (at your option) any later version.
e7432706b354 accessors to storage
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
10 *
e7432706b354 accessors to storage
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
11 * In addition, as a special exception, the copyright holders of this
e7432706b354 accessors to storage
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
12 * program give permission to link the code of its release with the
e7432706b354 accessors to storage
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
13 * OpenSSL project's "OpenSSL" library (or with modified versions of it
e7432706b354 accessors to storage
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
14 * that use the same license as the "OpenSSL" library), and distribute
e7432706b354 accessors to storage
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
15 * the linked executables. You must obey the GNU General Public License
e7432706b354 accessors to storage
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
16 * in all respects for all of the code used other than "OpenSSL". If you
e7432706b354 accessors to storage
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
17 * modify file(s) with this exception, you may extend this exception to
e7432706b354 accessors to storage
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
18 * your version of the file(s), but you are not obligated to do so. If
e7432706b354 accessors to storage
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
19 * you do not wish to do so, delete this exception statement from your
e7432706b354 accessors to storage
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
20 * version. If you delete this exception statement from all source files
e7432706b354 accessors to storage
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
21 * in the program, then also delete it here.
e7432706b354 accessors to storage
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
22 *
e7432706b354 accessors to storage
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
23 * This program is distributed in the hope that it will be useful, but
e7432706b354 accessors to storage
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
24 * WITHOUT ANY WARRANTY; without even the implied warranty of
e7432706b354 accessors to storage
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
25 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
e7432706b354 accessors to storage
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
26 * General Public License for more details.
e7432706b354 accessors to storage
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
27 *
e7432706b354 accessors to storage
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
28 * You should have received a copy of the GNU General Public License
e7432706b354 accessors to storage
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
29 * along with this program. If not, see <http://www.gnu.org/licenses/>.
e7432706b354 accessors to storage
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
30 **/
e7432706b354 accessors to storage
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
31
e7432706b354 accessors to storage
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
32
824
a811bdf8b8eb precompiled headers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 693
diff changeset
33 #include "../PrecompiledHeaders.h"
221
e7432706b354 accessors to storage
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
34 #include "CompressedFileStorageAccessor.h"
e7432706b354 accessors to storage
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
35
e7432706b354 accessors to storage
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
36 #include "../OrthancException.h"
e7432706b354 accessors to storage
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
37 #include "FileStorageAccessor.h"
e7432706b354 accessors to storage
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
38 #include "../HttpServer/BufferHttpSender.h"
1135
67c3c1e4a6e0 index-only mode, and custom storage area with plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1134
diff changeset
39 #include "../Uuid.h"
221
e7432706b354 accessors to storage
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
40
1124
790ff7a5b3bf IStorageArea abstraction
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1123
diff changeset
41 #include <memory>
1137
d9c27f9f1a51 OrthancPluginSetHttpHeader
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1135
diff changeset
42 #include <glog/logging.h>
1124
790ff7a5b3bf IStorageArea abstraction
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1123
diff changeset
43
221
e7432706b354 accessors to storage
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
44 namespace Orthanc
e7432706b354 accessors to storage
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
45 {
232
5368bbe813cf refactoring of attachments
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 221
diff changeset
46 FileInfo CompressedFileStorageAccessor::WriteInternal(const void* data,
5368bbe813cf refactoring of attachments
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 221
diff changeset
47 size_t size,
233
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 232
diff changeset
48 FileContentType type)
221
e7432706b354 accessors to storage
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
49 {
1135
67c3c1e4a6e0 index-only mode, and custom storage area with plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1134
diff changeset
50 std::string uuid = Toolbox::GenerateUuid();
67c3c1e4a6e0 index-only mode, and custom storage area with plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1134
diff changeset
51
693
01d8611c4a60 md5 for attached files
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 689
diff changeset
52 std::string md5;
01d8611c4a60 md5 for attached files
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 689
diff changeset
53
01d8611c4a60 md5 for attached files
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 689
diff changeset
54 if (storeMD5_)
01d8611c4a60 md5 for attached files
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 689
diff changeset
55 {
01d8611c4a60 md5 for attached files
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 689
diff changeset
56 Toolbox::ComputeMD5(md5, data, size);
01d8611c4a60 md5 for attached files
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 689
diff changeset
57 }
01d8611c4a60 md5 for attached files
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 689
diff changeset
58
221
e7432706b354 accessors to storage
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
59 switch (compressionType_)
e7432706b354 accessors to storage
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
60 {
e7432706b354 accessors to storage
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
61 case CompressionType_None:
232
5368bbe813cf refactoring of attachments
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 221
diff changeset
62 {
1135
67c3c1e4a6e0 index-only mode, and custom storage area with plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1134
diff changeset
63 GetStorageArea().Create(uuid.c_str(), data, size, type);
693
01d8611c4a60 md5 for attached files
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 689
diff changeset
64 return FileInfo(uuid, type, size, md5);
232
5368bbe813cf refactoring of attachments
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 221
diff changeset
65 }
221
e7432706b354 accessors to storage
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
66
e7432706b354 accessors to storage
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
67 case CompressionType_Zlib:
e7432706b354 accessors to storage
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
68 {
e7432706b354 accessors to storage
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
69 std::string compressed;
e7432706b354 accessors to storage
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
70 zlib_.Compress(compressed, data, size);
693
01d8611c4a60 md5 for attached files
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 689
diff changeset
71
01d8611c4a60 md5 for attached files
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 689
diff changeset
72 std::string compressedMD5;
01d8611c4a60 md5 for attached files
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 689
diff changeset
73
01d8611c4a60 md5 for attached files
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 689
diff changeset
74 if (storeMD5_)
01d8611c4a60 md5 for attached files
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 689
diff changeset
75 {
01d8611c4a60 md5 for attached files
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 689
diff changeset
76 Toolbox::ComputeMD5(compressedMD5, compressed);
01d8611c4a60 md5 for attached files
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 689
diff changeset
77 }
01d8611c4a60 md5 for attached files
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 689
diff changeset
78
1124
790ff7a5b3bf IStorageArea abstraction
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1123
diff changeset
79 if (compressed.size() > 0)
790ff7a5b3bf IStorageArea abstraction
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1123
diff changeset
80 {
1135
67c3c1e4a6e0 index-only mode, and custom storage area with plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1134
diff changeset
81 GetStorageArea().Create(uuid.c_str(), &compressed[0], compressed.size(), type);
1124
790ff7a5b3bf IStorageArea abstraction
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1123
diff changeset
82 }
790ff7a5b3bf IStorageArea abstraction
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1123
diff changeset
83 else
790ff7a5b3bf IStorageArea abstraction
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1123
diff changeset
84 {
1135
67c3c1e4a6e0 index-only mode, and custom storage area with plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1134
diff changeset
85 GetStorageArea().Create(uuid.c_str(), NULL, 0, type);
1124
790ff7a5b3bf IStorageArea abstraction
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1123
diff changeset
86 }
790ff7a5b3bf IStorageArea abstraction
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1123
diff changeset
87
693
01d8611c4a60 md5 for attached files
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 689
diff changeset
88 return FileInfo(uuid, type, size, md5,
01d8611c4a60 md5 for attached files
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 689
diff changeset
89 CompressionType_Zlib, compressed.size(), compressedMD5);
221
e7432706b354 accessors to storage
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
90 }
e7432706b354 accessors to storage
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
91
e7432706b354 accessors to storage
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
92 default:
e7432706b354 accessors to storage
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
93 throw OrthancException(ErrorCode_NotImplemented);
e7432706b354 accessors to storage
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
94 }
e7432706b354 accessors to storage
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
95 }
e7432706b354 accessors to storage
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
96
1134
ba9fd42284d0 preparing storage plugin
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1126
diff changeset
97
ba9fd42284d0 preparing storage plugin
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1126
diff changeset
98 CompressedFileStorageAccessor::CompressedFileStorageAccessor() :
ba9fd42284d0 preparing storage plugin
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1126
diff changeset
99 storage_(NULL),
ba9fd42284d0 preparing storage plugin
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1126
diff changeset
100 compressionType_(CompressionType_None)
ba9fd42284d0 preparing storage plugin
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1126
diff changeset
101 {
ba9fd42284d0 preparing storage plugin
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1126
diff changeset
102 }
ba9fd42284d0 preparing storage plugin
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1126
diff changeset
103
ba9fd42284d0 preparing storage plugin
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1126
diff changeset
104
1124
790ff7a5b3bf IStorageArea abstraction
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1123
diff changeset
105 CompressedFileStorageAccessor::CompressedFileStorageAccessor(IStorageArea& storage) :
1134
ba9fd42284d0 preparing storage plugin
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1126
diff changeset
106 storage_(&storage),
ba9fd42284d0 preparing storage plugin
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1126
diff changeset
107 compressionType_(CompressionType_None)
221
e7432706b354 accessors to storage
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
108 {
e7432706b354 accessors to storage
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
109 }
e7432706b354 accessors to storage
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
110
1134
ba9fd42284d0 preparing storage plugin
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1126
diff changeset
111
ba9fd42284d0 preparing storage plugin
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1126
diff changeset
112 IStorageArea& CompressedFileStorageAccessor::GetStorageArea()
ba9fd42284d0 preparing storage plugin
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1126
diff changeset
113 {
ba9fd42284d0 preparing storage plugin
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1126
diff changeset
114 if (storage_ == NULL)
ba9fd42284d0 preparing storage plugin
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1126
diff changeset
115 {
1137
d9c27f9f1a51 OrthancPluginSetHttpHeader
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1135
diff changeset
116 LOG(ERROR) << "No storage area is currently available";
1134
ba9fd42284d0 preparing storage plugin
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1126
diff changeset
117 throw OrthancException(ErrorCode_BadSequenceOfCalls);
ba9fd42284d0 preparing storage plugin
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1126
diff changeset
118 }
ba9fd42284d0 preparing storage plugin
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1126
diff changeset
119
ba9fd42284d0 preparing storage plugin
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1126
diff changeset
120 return *storage_;
ba9fd42284d0 preparing storage plugin
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1126
diff changeset
121 }
ba9fd42284d0 preparing storage plugin
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1126
diff changeset
122
ba9fd42284d0 preparing storage plugin
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1126
diff changeset
123
221
e7432706b354 accessors to storage
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
124 void CompressedFileStorageAccessor::Read(std::string& content,
1126
bf67431a7383 handling of file content type in IStorageArea
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1124
diff changeset
125 const std::string& uuid,
bf67431a7383 handling of file content type in IStorageArea
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1124
diff changeset
126 FileContentType type)
221
e7432706b354 accessors to storage
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
127 {
e7432706b354 accessors to storage
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
128 switch (compressionType_)
e7432706b354 accessors to storage
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
129 {
e7432706b354 accessors to storage
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
130 case CompressionType_None:
1134
ba9fd42284d0 preparing storage plugin
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1126
diff changeset
131 GetStorageArea().Read(content, uuid, type);
221
e7432706b354 accessors to storage
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
132 break;
e7432706b354 accessors to storage
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
133
e7432706b354 accessors to storage
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
134 case CompressionType_Zlib:
e7432706b354 accessors to storage
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
135 {
e7432706b354 accessors to storage
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
136 std::string compressed;
1134
ba9fd42284d0 preparing storage plugin
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1126
diff changeset
137 GetStorageArea().Read(compressed, uuid, type);
221
e7432706b354 accessors to storage
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
138 zlib_.Uncompress(content, compressed);
e7432706b354 accessors to storage
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
139 break;
e7432706b354 accessors to storage
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
140 }
e7432706b354 accessors to storage
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
141
e7432706b354 accessors to storage
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
142 default:
e7432706b354 accessors to storage
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
143 throw OrthancException(ErrorCode_NotImplemented);
e7432706b354 accessors to storage
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
144 }
e7432706b354 accessors to storage
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
145 }
e7432706b354 accessors to storage
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
146
1126
bf67431a7383 handling of file content type in IStorageArea
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1124
diff changeset
147 HttpFileSender* CompressedFileStorageAccessor::ConstructHttpFileSender(const std::string& uuid,
bf67431a7383 handling of file content type in IStorageArea
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1124
diff changeset
148 FileContentType type)
221
e7432706b354 accessors to storage
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
149 {
e7432706b354 accessors to storage
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
150 switch (compressionType_)
e7432706b354 accessors to storage
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
151 {
e7432706b354 accessors to storage
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
152 case CompressionType_None:
e7432706b354 accessors to storage
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
153 {
1134
ba9fd42284d0 preparing storage plugin
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1126
diff changeset
154 FileStorageAccessor uncompressedAccessor(GetStorageArea());
1126
bf67431a7383 handling of file content type in IStorageArea
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1124
diff changeset
155 return uncompressedAccessor.ConstructHttpFileSender(uuid, type);
221
e7432706b354 accessors to storage
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
156 }
e7432706b354 accessors to storage
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
157
e7432706b354 accessors to storage
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
158 case CompressionType_Zlib:
e7432706b354 accessors to storage
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
159 {
e7432706b354 accessors to storage
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
160 std::string compressed;
1134
ba9fd42284d0 preparing storage plugin
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1126
diff changeset
161 GetStorageArea().Read(compressed, uuid, type);
221
e7432706b354 accessors to storage
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
162
e7432706b354 accessors to storage
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
163 std::auto_ptr<BufferHttpSender> sender(new BufferHttpSender);
e7432706b354 accessors to storage
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
164 zlib_.Uncompress(sender->GetBuffer(), compressed);
e7432706b354 accessors to storage
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
165
e7432706b354 accessors to storage
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
166 return sender.release();
e7432706b354 accessors to storage
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
167 }
e7432706b354 accessors to storage
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
168
e7432706b354 accessors to storage
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
169 default:
e7432706b354 accessors to storage
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
170 throw OrthancException(ErrorCode_NotImplemented);
e7432706b354 accessors to storage
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
171 }
e7432706b354 accessors to storage
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
172 }
1134
ba9fd42284d0 preparing storage plugin
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1126
diff changeset
173
ba9fd42284d0 preparing storage plugin
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1126
diff changeset
174
ba9fd42284d0 preparing storage plugin
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1126
diff changeset
175 void CompressedFileStorageAccessor::Remove(const std::string& uuid,
ba9fd42284d0 preparing storage plugin
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1126
diff changeset
176 FileContentType type)
ba9fd42284d0 preparing storage plugin
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1126
diff changeset
177 {
ba9fd42284d0 preparing storage plugin
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1126
diff changeset
178 GetStorageArea().Remove(uuid, type);
ba9fd42284d0 preparing storage plugin
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1126
diff changeset
179 }
221
e7432706b354 accessors to storage
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
180 }