comparison OrthancServer/main.cpp @ 1127:f4e65808ea58

FilesystemStorageWithoutDicom
author Sebastien Jodogne <s.jodogne@gmail.com>
date Fri, 05 Sep 2014 17:12:08 +0200
parents 790ff7a5b3bf
children f739d3f6cfcf
comparison
equal deleted inserted replaced
1126:bf67431a7383 1127:f4e65808ea58
35 35
36 #include <fstream> 36 #include <fstream>
37 #include <glog/logging.h> 37 #include <glog/logging.h>
38 #include <boost/algorithm/string/predicate.hpp> 38 #include <boost/algorithm/string/predicate.hpp>
39 39
40 #include "../Core/Uuid.h"
40 #include "../Core/FileStorage/FilesystemStorage.h" 41 #include "../Core/FileStorage/FilesystemStorage.h"
41 #include "../Core/HttpServer/EmbeddedResourceHttpHandler.h" 42 #include "../Core/HttpServer/EmbeddedResourceHttpHandler.h"
42 #include "../Core/HttpServer/FilesystemHttpHandler.h" 43 #include "../Core/HttpServer/FilesystemHttpHandler.h"
43 #include "../Core/Lua/LuaFunctionCall.h" 44 #include "../Core/Lua/LuaFunctionCall.h"
44 #include "../Core/DicomFormat/DicomArray.h" 45 #include "../Core/DicomFormat/DicomArray.h"
313 } 314 }
314 } 315 }
315 316
316 317
317 318
319 class FilesystemStorageWithoutDicom : public IStorageArea
320 {
321 private:
322 FilesystemStorage storage_;
323
324 public:
325 FilesystemStorageWithoutDicom(const std::string& path) : storage_(path)
326 {
327 }
328
329 virtual std::string Create(const void* content,
330 size_t size,
331 FileContentType type)
332 {
333 if (type != FileContentType_Dicom)
334 {
335 return storage_.Create(content, size, type);
336 }
337 else
338 {
339 return Toolbox::GenerateUuid();
340 }
341 }
342
343 virtual void Read(std::string& content,
344 const std::string& uuid,
345 FileContentType type) const
346 {
347 if (type != FileContentType_Dicom)
348 {
349 storage_.Read(content, uuid, type);
350 }
351 else
352 {
353 throw OrthancException(ErrorCode_UnknownResource);
354 }
355 }
356
357 virtual void Remove(const std::string& uuid,
358 FileContentType type)
359 {
360 if (type != FileContentType_Dicom)
361 {
362 storage_.Remove(uuid, type);
363 }
364 }
365 };
366
367
318 static bool StartOrthanc() 368 static bool StartOrthanc()
319 { 369 {
320 std::string storageDirectoryStr = Configuration::GetGlobalStringParameter("StorageDirectory", "OrthancStorage"); 370 std::string storageDirectoryStr = Configuration::GetGlobalStringParameter("StorageDirectory", "OrthancStorage");
321 boost::filesystem::path storageDirectory = Configuration::InterpretStringParameterAsPath(storageDirectoryStr); 371 boost::filesystem::path storageDirectory = Configuration::InterpretStringParameterAsPath(storageDirectoryStr);
322 boost::filesystem::path indexDirectory = Configuration::InterpretStringParameterAsPath( 372 boost::filesystem::path indexDirectory = Configuration::InterpretStringParameterAsPath(
323 Configuration::GetGlobalStringParameter("IndexDirectory", storageDirectoryStr)); 373 Configuration::GetGlobalStringParameter("IndexDirectory", storageDirectoryStr));
324 374
375 // TODO HERE
325 FilesystemStorage storage(storageDirectory.string()); 376 FilesystemStorage storage(storageDirectory.string());
377 //FilesystemStorageWithoutDicom storage(storageDirectory.string());
378
326 ServerContext context(storage, indexDirectory); 379 ServerContext context(storage, indexDirectory);
327 380
328 LOG(WARNING) << "Storage directory: " << storageDirectory; 381 LOG(WARNING) << "Storage directory: " << storageDirectory;
329 LOG(WARNING) << "Index directory: " << indexDirectory; 382 LOG(WARNING) << "Index directory: " << indexDirectory;
330 383