├── AUTHORS ├── CMakeLists.txt ├── COPYING ├── Core ├── Cache │ ├── CacheIndex.h │ ├── ICachePageProvider.h │ ├── MemoryCache.cpp │ └── MemoryCache.h ├── ChunkedBuffer.cpp ├── ChunkedBuffer.h ├── Compression │ ├── BufferCompressor.cpp │ ├── BufferCompressor.h │ ├── HierarchicalZipWriter.cpp │ ├── HierarchicalZipWriter.h │ ├── ZipWriter.cpp │ ├── ZipWriter.h │ ├── ZlibCompressor.cpp │ └── ZlibCompressor.h ├── DicomFormat │ ├── DicomArray.cpp │ ├── DicomArray.h │ ├── DicomElement.h │ ├── DicomInstanceHasher.cpp │ ├── DicomInstanceHasher.h │ ├── DicomIntegerPixelAccessor.cpp │ ├── DicomIntegerPixelAccessor.h │ ├── DicomMap.cpp │ ├── DicomMap.h │ ├── DicomNullValue.h │ ├── DicomString.h │ ├── DicomTag.cpp │ ├── DicomTag.h │ └── DicomValue.h ├── EnumerationDictionary.h ├── Enumerations.cpp ├── Enumerations.h ├── FileFormats │ ├── PngReader.cpp │ ├── PngReader.h │ ├── PngWriter.cpp │ └── PngWriter.h ├── FileStorage │ ├── CompressedFileStorageAccessor.cpp │ ├── CompressedFileStorageAccessor.h │ ├── FileInfo.h │ ├── FileStorage.cpp │ ├── FileStorage.h │ ├── FileStorageAccessor.cpp │ ├── FileStorageAccessor.h │ ├── StorageAccessor.cpp │ └── StorageAccessor.h ├── HttpClient.cpp ├── HttpClient.h ├── HttpServer │ ├── BufferHttpSender.h │ ├── EmbeddedResourceHttpHandler.cpp │ ├── EmbeddedResourceHttpHandler.h │ ├── FilesystemHttpHandler.cpp │ ├── FilesystemHttpHandler.h │ ├── FilesystemHttpSender.cpp │ ├── FilesystemHttpSender.h │ ├── HttpFileSender.cpp │ ├── HttpFileSender.h │ ├── HttpHandler.cpp │ ├── HttpHandler.h │ ├── HttpOutput.cpp │ ├── HttpOutput.h │ ├── MongooseServer.cpp │ └── MongooseServer.h ├── ICommand.h ├── IDynamicObject.h ├── Lua │ ├── LuaContext.cpp │ ├── LuaContext.h │ ├── LuaException.h │ ├── LuaFunctionCall.cpp │ └── LuaFunctionCall.h ├── MultiThreading │ ├── ArrayFilledByThreads.cpp │ ├── ArrayFilledByThreads.h │ ├── BagOfRunnablesBySteps.cpp │ ├── BagOfRunnablesBySteps.h │ ├── IRunnableBySteps.h │ ├── SharedMessageQueue.cpp │ ├── SharedMessageQueue.h │ ├── ThreadedCommandProcessor.cpp │ └── ThreadedCommandProcessor.h ├── OrthancException.cpp ├── OrthancException.h ├── RestApi │ ├── RestApi.cpp │ ├── RestApi.h │ ├── RestApiOutput.cpp │ ├── RestApiOutput.h │ ├── RestApiPath.cpp │ └── RestApiPath.h ├── SQLite │ ├── Connection.cpp │ ├── Connection.h │ ├── FunctionContext.cpp │ ├── FunctionContext.h │ ├── IScalarFunction.h │ ├── README.txt │ ├── Statement.cpp │ ├── Statement.h │ ├── StatementId.cpp │ ├── StatementId.h │ ├── StatementReference.cpp │ ├── StatementReference.h │ ├── Transaction.cpp │ └── Transaction.h ├── Toolbox.cpp ├── Toolbox.h ├── Uuid.cpp └── Uuid.h ├── INSTALL ├── NEWS ├── OrthancCppClient ├── Instance.cpp ├── Instance.h ├── OrthancConnection.cpp ├── OrthancConnection.h ├── Patient.cpp ├── Patient.h ├── Series.cpp ├── Series.h ├── Study.cpp └── Study.h ├── OrthancExplorer ├── explorer.css ├── explorer.html ├── explorer.js ├── file-upload.js ├── images │ └── unsupported.png └── libs │ ├── date.js │ ├── images │ ├── ajax-loader.gif │ ├── ajax-loader.png │ ├── ajax-loader2.gif │ ├── icons-18-black.png │ ├── icons-18-white.png │ ├── icons-36-black.png │ └── icons-36-white.png │ ├── jqm.page.params.js │ ├── jqtree-icons.png │ ├── jqtree.css │ ├── jquery-1.7.2.min.js │ ├── jquery-file-upload │ ├── css │ │ ├── jquery.fileupload-ui.css │ │ └── style.css │ ├── img │ │ ├── loading.gif │ │ └── progressbar.gif │ └── js │ │ ├── cors │ │ ├── jquery.postmessage-transport.js │ │ └── jquery.xdr-transport.js │ │ ├── jquery.fileupload-fp.js │ │ ├── jquery.fileupload-ui.js │ │ ├── jquery.fileupload.js │ │ ├── jquery.iframe-transport.js │ │ ├── locale.js │ │ └── vendor │ │ └── jquery.ui.widget.js │ ├── jquery.blockui.js │ ├── jquery.mobile-1.1.0.min.css │ ├── jquery.mobile-1.1.0.min.js │ ├── jquery.mobile.simpledialog.min.css │ ├── jquery.mobile.simpledialog2.js │ ├── jquery.mobile.structure-1.1.0.min.css │ ├── jquery.mobile.theme-1.1.0.min.css │ ├── slimbox2.js │ ├── slimbox2 │ ├── closelabel.gif │ ├── loading.gif │ ├── nextlabel.gif │ ├── prevlabel.gif │ ├── slimbox2-rtl.css │ └── slimbox2.css │ └── tree.jquery.js ├── OrthancServer ├── DatabaseWrapper.cpp ├── DatabaseWrapper.h ├── DicomProtocol │ ├── DicomFindAnswers.cpp │ ├── DicomFindAnswers.h │ ├── DicomServer.cpp │ ├── DicomServer.h │ ├── DicomUserConnection.cpp │ ├── DicomUserConnection.h │ ├── IApplicationEntityFilter.h │ ├── IFindRequestHandler.h │ ├── IFindRequestHandlerFactory.h │ ├── IMoveRequestHandler.h │ ├── IMoveRequestHandlerFactory.h │ ├── IStoreRequestHandler.h │ └── IStoreRequestHandlerFactory.h ├── FromDcmtkBridge.cpp ├── FromDcmtkBridge.h ├── IServerIndexListener.h ├── Internals │ ├── CommandDispatcher.cpp │ ├── CommandDispatcher.h │ ├── FindScp.cpp │ ├── FindScp.h │ ├── MoveScp.cpp │ ├── MoveScp.h │ ├── StoreScp.cpp │ └── StoreScp.h ├── OrthancInitialization.cpp ├── OrthancInitialization.h ├── OrthancRestApi.cpp ├── OrthancRestApi.h ├── PrepareDatabase.sql ├── ServerContext.cpp ├── ServerContext.h ├── ServerEnumerations.cpp ├── ServerEnumerations.h ├── ServerIndex.cpp ├── ServerIndex.h ├── ServerToolbox.cpp ├── ServerToolbox.h ├── ToDcmtkBridge.cpp ├── ToDcmtkBridge.h └── main.cpp ├── README ├── Resources ├── Archives │ ├── MessageWithDestination.cpp │ └── PrepareDatabase-v1.sql ├── CMake │ ├── AutoGeneratedCode.cmake │ ├── BoostConfiguration.cmake │ ├── Compiler.cmake │ ├── DcmtkConfiguration.cmake │ ├── DownloadPackage.cmake │ ├── GoogleLogConfiguration.cmake │ ├── GoogleLogConfiguration.h │ ├── GoogleTestConfiguration.cmake │ ├── JsonCppConfiguration.cmake │ ├── LibCurlConfiguration.cmake │ ├── LibPngConfiguration.cmake │ ├── LuaConfiguration.cmake │ ├── MongooseConfiguration.cmake │ ├── OpenSslConfiguration.cmake │ ├── SQLiteConfiguration.cmake │ └── ZlibConfiguration.cmake ├── Configuration.json ├── EmbedResources.py ├── LinuxStandardBaseToolchain.cmake ├── MinGWToolchain.cmake ├── Orthanc.doxygen ├── Patches │ ├── glog-port-cc.diff │ ├── glog-port-h.diff │ ├── glog-utilities.diff │ ├── log4cplus-patch.diff │ └── mongoose-patch.diff ├── Samples │ ├── ImportDicomFiles │ │ └── ImportDicomFiles.py │ ├── OrthancCppClient │ │ ├── Basic │ │ │ ├── CMakeLists.txt │ │ │ └── main.cpp │ │ ├── OrthancCppClient.cmake │ │ └── Vtk │ │ │ ├── CMakeLists.txt │ │ │ └── main.cpp │ ├── Python │ │ ├── AnonymizeAllPatients.py │ │ ├── ChangesLoop.py │ │ ├── DownloadAnonymized.py │ │ ├── HighPerformanceAutoRouting.py │ │ └── RestToolbox.py │ ├── RestApi │ │ ├── CMakeLists.txt │ │ └── Sample.cpp │ └── RestApiLinuxDynamic │ │ ├── AutoGeneratedCode.cmake │ │ ├── CMakeLists.txt │ │ ├── README.txt │ │ └── Sample.cpp ├── Toolbox.lua ├── VisualStudio │ └── stdint.h ├── base64 │ ├── base64.cpp │ └── base64.h ├── md5 │ ├── md5.c │ └── md5.h ├── minizip │ ├── NOTES │ ├── crypt.h │ ├── ioapi.c │ ├── ioapi.h │ ├── zip.c │ └── zip.h └── sha1 │ ├── Makefile │ ├── Makefile.nt │ ├── license.txt │ ├── sha.cpp │ ├── sha1.cpp │ ├── sha1.h │ ├── shacmp.cpp │ └── shatest.cpp ├── THANKS └── UnitTests ├── FileStorage.cpp ├── Lua.cpp ├── MemoryCache.cpp ├── Png.cpp ├── RestApi.cpp ├── SQLite.cpp ├── SQLiteChromium.cpp ├── ServerIndex.cpp ├── Versions.cpp ├── Zip.cpp └── main.cpp /AUTHORS: -------------------------------------------------------------------------------- 1 | Orthanc - A Lightweight, RESTful DICOM Server 2 | ============================================= 3 | 4 | 5 | Authors of Orthanc 6 | ------------------ 7 | 8 | * Sebastien Jodogne 9 | Department of Medical Physics, CHU of Liege, Belgium 10 | 11 | Overall design and main developper. 12 | 13 | 14 | 15 | Contributors 16 | ------------ 17 | 18 | See the file "THANKS" for the occasional contributors. 19 | -------------------------------------------------------------------------------- /Core/Cache/ICachePageProvider.h: -------------------------------------------------------------------------------- 1 | /** 2 | * Orthanc - A Lightweight, RESTful DICOM Store 3 | * Copyright (C) 2012-2013 Medical Physics Department, CHU of Liege, 4 | * Belgium 5 | * 6 | * This program is free software: you can redistribute it and/or 7 | * modify it under the terms of the GNU General Public License as 8 | * published by the Free Software Foundation, either version 3 of the 9 | * License, or (at your option) any later version. 10 | * 11 | * In addition, as a special exception, the copyright holders of this 12 | * program give permission to link the code of its release with the 13 | * OpenSSL project's "OpenSSL" library (or with modified versions of it 14 | * that use the same license as the "OpenSSL" library), and distribute 15 | * the linked executables. You must obey the GNU General Public License 16 | * in all respects for all of the code used other than "OpenSSL". If you 17 | * modify file(s) with this exception, you may extend this exception to 18 | * your version of the file(s), but you are not obligated to do so. If 19 | * you do not wish to do so, delete this exception statement from your 20 | * version. If you delete this exception statement from all source files 21 | * in the program, then also delete it here. 22 | * 23 | * This program is distributed in the hope that it will be useful, but 24 | * WITHOUT ANY WARRANTY; without even the implied warranty of 25 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 26 | * General Public License for more details. 27 | * 28 | * You should have received a copy of the GNU General Public License 29 | * along with this program. If not, see . 30 | **/ 31 | 32 | 33 | #pragma once 34 | 35 | #include 36 | #include "../IDynamicObject.h" 37 | 38 | namespace Orthanc 39 | { 40 | class ICachePageProvider 41 | { 42 | public: 43 | virtual ~ICachePageProvider() 44 | { 45 | } 46 | 47 | virtual IDynamicObject* Provide(const std::string& id) = 0; 48 | }; 49 | } 50 | -------------------------------------------------------------------------------- /Core/Cache/MemoryCache.h: -------------------------------------------------------------------------------- 1 | /** 2 | * Orthanc - A Lightweight, RESTful DICOM Store 3 | * Copyright (C) 2012-2013 Medical Physics Department, CHU of Liege, 4 | * Belgium 5 | * 6 | * This program is free software: you can redistribute it and/or 7 | * modify it under the terms of the GNU General Public License as 8 | * published by the Free Software Foundation, either version 3 of the 9 | * License, or (at your option) any later version. 10 | * 11 | * In addition, as a special exception, the copyright holders of this 12 | * program give permission to link the code of its release with the 13 | * OpenSSL project's "OpenSSL" library (or with modified versions of it 14 | * that use the same license as the "OpenSSL" library), and distribute 15 | * the linked executables. You must obey the GNU General Public License 16 | * in all respects for all of the code used other than "OpenSSL". If you 17 | * modify file(s) with this exception, you may extend this exception to 18 | * your version of the file(s), but you are not obligated to do so. If 19 | * you do not wish to do so, delete this exception statement from your 20 | * version. If you delete this exception statement from all source files 21 | * in the program, then also delete it here. 22 | * 23 | * This program is distributed in the hope that it will be useful, but 24 | * WITHOUT ANY WARRANTY; without even the implied warranty of 25 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 26 | * General Public License for more details. 27 | * 28 | * You should have received a copy of the GNU General Public License 29 | * along with this program. If not, see . 30 | **/ 31 | 32 | 33 | #pragma once 34 | 35 | #include 36 | #include "CacheIndex.h" 37 | #include "ICachePageProvider.h" 38 | 39 | namespace Orthanc 40 | { 41 | /** 42 | * WARNING: This class is NOT thread-safe. 43 | **/ 44 | class MemoryCache 45 | { 46 | private: 47 | struct Page 48 | { 49 | std::string id_; 50 | std::auto_ptr content_; 51 | }; 52 | 53 | ICachePageProvider& provider_; 54 | size_t cacheSize_; 55 | CacheIndex index_; 56 | 57 | Page& Load(const std::string& id); 58 | 59 | public: 60 | MemoryCache(ICachePageProvider& provider, 61 | size_t cacheSize); 62 | 63 | ~MemoryCache(); 64 | 65 | IDynamicObject& Access(const std::string& id); 66 | }; 67 | } 68 | -------------------------------------------------------------------------------- /Core/ChunkedBuffer.cpp: -------------------------------------------------------------------------------- 1 | /** 2 | * Orthanc - A Lightweight, RESTful DICOM Store 3 | * Copyright (C) 2012-2013 Medical Physics Department, CHU of Liege, 4 | * Belgium 5 | * 6 | * This program is free software: you can redistribute it and/or 7 | * modify it under the terms of the GNU General Public License as 8 | * published by the Free Software Foundation, either version 3 of the 9 | * License, or (at your option) any later version. 10 | * 11 | * In addition, as a special exception, the copyright holders of this 12 | * program give permission to link the code of its release with the 13 | * OpenSSL project's "OpenSSL" library (or with modified versions of it 14 | * that use the same license as the "OpenSSL" library), and distribute 15 | * the linked executables. You must obey the GNU General Public License 16 | * in all respects for all of the code used other than "OpenSSL". If you 17 | * modify file(s) with this exception, you may extend this exception to 18 | * your version of the file(s), but you are not obligated to do so. If 19 | * you do not wish to do so, delete this exception statement from your 20 | * version. If you delete this exception statement from all source files 21 | * in the program, then also delete it here. 22 | * 23 | * This program is distributed in the hope that it will be useful, but 24 | * WITHOUT ANY WARRANTY; without even the implied warranty of 25 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 26 | * General Public License for more details. 27 | * 28 | * You should have received a copy of the GNU General Public License 29 | * along with this program. If not, see . 30 | **/ 31 | 32 | 33 | #include "ChunkedBuffer.h" 34 | 35 | #include 36 | #include 37 | 38 | 39 | namespace Orthanc 40 | { 41 | void ChunkedBuffer::Clear() 42 | { 43 | numBytes_ = 0; 44 | 45 | for (Chunks::iterator it = chunks_.begin(); 46 | it != chunks_.end(); it++) 47 | { 48 | delete *it; 49 | } 50 | } 51 | 52 | 53 | void ChunkedBuffer::AddChunk(const char* chunkData, 54 | size_t chunkSize) 55 | { 56 | if (chunkSize == 0) 57 | { 58 | return; 59 | } 60 | 61 | assert(chunkData != NULL); 62 | chunks_.push_back(new std::string(chunkData, chunkSize)); 63 | numBytes_ += chunkSize; 64 | } 65 | 66 | 67 | void ChunkedBuffer::Flatten(std::string& result) 68 | { 69 | result.resize(numBytes_); 70 | 71 | size_t pos = 0; 72 | for (Chunks::iterator it = chunks_.begin(); 73 | it != chunks_.end(); it++) 74 | { 75 | assert(*it != NULL); 76 | 77 | size_t s = (*it)->size(); 78 | if (s != 0) 79 | { 80 | memcpy(&result[pos], (*it)->c_str(), s); 81 | pos += s; 82 | } 83 | 84 | delete *it; 85 | } 86 | 87 | chunks_.clear(); 88 | } 89 | } 90 | -------------------------------------------------------------------------------- /Core/ChunkedBuffer.h: -------------------------------------------------------------------------------- 1 | /** 2 | * Orthanc - A Lightweight, RESTful DICOM Store 3 | * Copyright (C) 2012-2013 Medical Physics Department, CHU of Liege, 4 | * Belgium 5 | * 6 | * This program is free software: you can redistribute it and/or 7 | * modify it under the terms of the GNU General Public License as 8 | * published by the Free Software Foundation, either version 3 of the 9 | * License, or (at your option) any later version. 10 | * 11 | * In addition, as a special exception, the copyright holders of this 12 | * program give permission to link the code of its release with the 13 | * OpenSSL project's "OpenSSL" library (or with modified versions of it 14 | * that use the same license as the "OpenSSL" library), and distribute 15 | * the linked executables. You must obey the GNU General Public License 16 | * in all respects for all of the code used other than "OpenSSL". If you 17 | * modify file(s) with this exception, you may extend this exception to 18 | * your version of the file(s), but you are not obligated to do so. If 19 | * you do not wish to do so, delete this exception statement from your 20 | * version. If you delete this exception statement from all source files 21 | * in the program, then also delete it here. 22 | * 23 | * This program is distributed in the hope that it will be useful, but 24 | * WITHOUT ANY WARRANTY; without even the implied warranty of 25 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 26 | * General Public License for more details. 27 | * 28 | * You should have received a copy of the GNU General Public License 29 | * along with this program. If not, see . 30 | **/ 31 | 32 | 33 | #pragma once 34 | 35 | #include 36 | #include 37 | 38 | namespace Orthanc 39 | { 40 | class ChunkedBuffer 41 | { 42 | private: 43 | typedef std::list Chunks; 44 | size_t numBytes_; 45 | Chunks chunks_; 46 | 47 | void Clear(); 48 | 49 | public: 50 | ChunkedBuffer() : numBytes_(0) 51 | { 52 | } 53 | 54 | ~ChunkedBuffer() 55 | { 56 | Clear(); 57 | } 58 | 59 | size_t GetNumBytes() const 60 | { 61 | return numBytes_; 62 | } 63 | 64 | void AddChunk(const char* chunkData, 65 | size_t chunkSize); 66 | 67 | void Flatten(std::string& result); 68 | }; 69 | } 70 | -------------------------------------------------------------------------------- /Core/Compression/BufferCompressor.cpp: -------------------------------------------------------------------------------- 1 | /** 2 | * Orthanc - A Lightweight, RESTful DICOM Store 3 | * Copyright (C) 2012-2013 Medical Physics Department, CHU of Liege, 4 | * Belgium 5 | * 6 | * This program is free software: you can redistribute it and/or 7 | * modify it under the terms of the GNU General Public License as 8 | * published by the Free Software Foundation, either version 3 of the 9 | * License, or (at your option) any later version. 10 | * 11 | * In addition, as a special exception, the copyright holders of this 12 | * program give permission to link the code of its release with the 13 | * OpenSSL project's "OpenSSL" library (or with modified versions of it 14 | * that use the same license as the "OpenSSL" library), and distribute 15 | * the linked executables. You must obey the GNU General Public License 16 | * in all respects for all of the code used other than "OpenSSL". If you 17 | * modify file(s) with this exception, you may extend this exception to 18 | * your version of the file(s), but you are not obligated to do so. If 19 | * you do not wish to do so, delete this exception statement from your 20 | * version. If you delete this exception statement from all source files 21 | * in the program, then also delete it here. 22 | * 23 | * This program is distributed in the hope that it will be useful, but 24 | * WITHOUT ANY WARRANTY; without even the implied warranty of 25 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 26 | * General Public License for more details. 27 | * 28 | * You should have received a copy of the GNU General Public License 29 | * along with this program. If not, see . 30 | **/ 31 | 32 | 33 | #include "BufferCompressor.h" 34 | 35 | namespace Orthanc 36 | { 37 | void BufferCompressor::Compress(std::string& output, 38 | const std::vector& input) 39 | { 40 | if (input.size() > 0) 41 | Compress(output, &input[0], input.size()); 42 | else 43 | Compress(output, NULL, 0); 44 | } 45 | 46 | void BufferCompressor::Uncompress(std::string& output, 47 | const std::vector& input) 48 | { 49 | if (input.size() > 0) 50 | Uncompress(output, &input[0], input.size()); 51 | else 52 | Uncompress(output, NULL, 0); 53 | } 54 | 55 | void BufferCompressor::Compress(std::string& output, 56 | const std::string& input) 57 | { 58 | if (input.size() > 0) 59 | Compress(output, &input[0], input.size()); 60 | else 61 | Compress(output, NULL, 0); 62 | } 63 | 64 | void BufferCompressor::Uncompress(std::string& output, 65 | const std::string& input) 66 | { 67 | if (input.size() > 0) 68 | Uncompress(output, &input[0], input.size()); 69 | else 70 | Uncompress(output, NULL, 0); 71 | } 72 | } 73 | -------------------------------------------------------------------------------- /Core/Compression/BufferCompressor.h: -------------------------------------------------------------------------------- 1 | /** 2 | * Orthanc - A Lightweight, RESTful DICOM Store 3 | * Copyright (C) 2012-2013 Medical Physics Department, CHU of Liege, 4 | * Belgium 5 | * 6 | * This program is free software: you can redistribute it and/or 7 | * modify it under the terms of the GNU General Public License as 8 | * published by the Free Software Foundation, either version 3 of the 9 | * License, or (at your option) any later version. 10 | * 11 | * In addition, as a special exception, the copyright holders of this 12 | * program give permission to link the code of its release with the 13 | * OpenSSL project's "OpenSSL" library (or with modified versions of it 14 | * that use the same license as the "OpenSSL" library), and distribute 15 | * the linked executables. You must obey the GNU General Public License 16 | * in all respects for all of the code used other than "OpenSSL". If you 17 | * modify file(s) with this exception, you may extend this exception to 18 | * your version of the file(s), but you are not obligated to do so. If 19 | * you do not wish to do so, delete this exception statement from your 20 | * version. If you delete this exception statement from all source files 21 | * in the program, then also delete it here. 22 | * 23 | * This program is distributed in the hope that it will be useful, but 24 | * WITHOUT ANY WARRANTY; without even the implied warranty of 25 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 26 | * General Public License for more details. 27 | * 28 | * You should have received a copy of the GNU General Public License 29 | * along with this program. If not, see . 30 | **/ 31 | 32 | 33 | #pragma once 34 | 35 | #include 36 | #include 37 | #include 38 | #include 39 | 40 | namespace Orthanc 41 | { 42 | class BufferCompressor 43 | { 44 | public: 45 | virtual ~BufferCompressor() 46 | { 47 | } 48 | 49 | virtual void Compress(std::string& compressed, 50 | const void* uncompressed, 51 | size_t uncompressedSize) = 0; 52 | 53 | virtual void Uncompress(std::string& uncompressed, 54 | const void* compressed, 55 | size_t compressedSize) = 0; 56 | 57 | virtual void Compress(std::string& compressed, 58 | const std::vector& uncompressed); 59 | 60 | virtual void Uncompress(std::string& uncompressed, 61 | const std::vector& compressed); 62 | 63 | virtual void Compress(std::string& compressed, 64 | const std::string& uncompressed); 65 | 66 | virtual void Uncompress(std::string& uncompressed, 67 | const std::string& compressed); 68 | }; 69 | } 70 | -------------------------------------------------------------------------------- /Core/Compression/ZipWriter.h: -------------------------------------------------------------------------------- 1 | /** 2 | * Orthanc - A Lightweight, RESTful DICOM Store 3 | * Copyright (C) 2012-2013 Medical Physics Department, CHU of Liege, 4 | * Belgium 5 | * 6 | * This program is free software: you can redistribute it and/or 7 | * modify it under the terms of the GNU General Public License as 8 | * published by the Free Software Foundation, either version 3 of the 9 | * License, or (at your option) any later version. 10 | * 11 | * In addition, as a special exception, the copyright holders of this 12 | * program give permission to link the code of its release with the 13 | * OpenSSL project's "OpenSSL" library (or with modified versions of it 14 | * that use the same license as the "OpenSSL" library), and distribute 15 | * the linked executables. You must obey the GNU General Public License 16 | * in all respects for all of the code used other than "OpenSSL". If you 17 | * modify file(s) with this exception, you may extend this exception to 18 | * your version of the file(s), but you are not obligated to do so. If 19 | * you do not wish to do so, delete this exception statement from your 20 | * version. If you delete this exception statement from all source files 21 | * in the program, then also delete it here. 22 | * 23 | * This program is distributed in the hope that it will be useful, but 24 | * WITHOUT ANY WARRANTY; without even the implied warranty of 25 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 26 | * General Public License for more details. 27 | * 28 | * You should have received a copy of the GNU General Public License 29 | * along with this program. If not, see . 30 | **/ 31 | 32 | 33 | #pragma once 34 | 35 | #include 36 | #include 37 | #include 38 | 39 | #if ORTHANC_BUILD_UNIT_TESTS == 1 40 | #include 41 | #endif 42 | 43 | namespace Orthanc 44 | { 45 | class ZipWriter 46 | { 47 | private: 48 | struct PImpl; 49 | boost::shared_ptr pimpl_; 50 | 51 | bool hasFileInZip_; 52 | uint8_t compressionLevel_; 53 | std::string path_; 54 | 55 | public: 56 | ZipWriter(); 57 | 58 | ~ZipWriter(); 59 | 60 | void SetCompressionLevel(uint8_t level); 61 | 62 | uint8_t GetCompressionLevel() const 63 | { 64 | return compressionLevel_; 65 | } 66 | 67 | void Open(); 68 | 69 | void Close(); 70 | 71 | bool IsOpen() const; 72 | 73 | void SetOutputPath(const char* path); 74 | 75 | const std::string& GetOutputPath() const 76 | { 77 | return path_; 78 | } 79 | 80 | void OpenFile(const char* path); 81 | 82 | void Write(const char* data, size_t length); 83 | 84 | void Write(const std::string& data); 85 | }; 86 | } 87 | -------------------------------------------------------------------------------- /Core/Compression/ZlibCompressor.h: -------------------------------------------------------------------------------- 1 | /** 2 | * Orthanc - A Lightweight, RESTful DICOM Store 3 | * Copyright (C) 2012-2013 Medical Physics Department, CHU of Liege, 4 | * Belgium 5 | * 6 | * This program is free software: you can redistribute it and/or 7 | * modify it under the terms of the GNU General Public License as 8 | * published by the Free Software Foundation, either version 3 of the 9 | * License, or (at your option) any later version. 10 | * 11 | * In addition, as a special exception, the copyright holders of this 12 | * program give permission to link the code of its release with the 13 | * OpenSSL project's "OpenSSL" library (or with modified versions of it 14 | * that use the same license as the "OpenSSL" library), and distribute 15 | * the linked executables. You must obey the GNU General Public License 16 | * in all respects for all of the code used other than "OpenSSL". If you 17 | * modify file(s) with this exception, you may extend this exception to 18 | * your version of the file(s), but you are not obligated to do so. If 19 | * you do not wish to do so, delete this exception statement from your 20 | * version. If you delete this exception statement from all source files 21 | * in the program, then also delete it here. 22 | * 23 | * This program is distributed in the hope that it will be useful, but 24 | * WITHOUT ANY WARRANTY; without even the implied warranty of 25 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 26 | * General Public License for more details. 27 | * 28 | * You should have received a copy of the GNU General Public License 29 | * along with this program. If not, see . 30 | **/ 31 | 32 | 33 | #pragma once 34 | 35 | #include "BufferCompressor.h" 36 | 37 | namespace Orthanc 38 | { 39 | class ZlibCompressor : public BufferCompressor 40 | { 41 | private: 42 | uint8_t compressionLevel_; 43 | 44 | public: 45 | using BufferCompressor::Compress; 46 | using BufferCompressor::Uncompress; 47 | 48 | ZlibCompressor() 49 | { 50 | compressionLevel_ = 6; 51 | } 52 | 53 | void SetCompressionLevel(uint8_t level); 54 | 55 | uint8_t GetCompressionLevel() const 56 | { 57 | return compressionLevel_; 58 | } 59 | 60 | virtual void Compress(std::string& compressed, 61 | const void* uncompressed, 62 | size_t uncompressedSize); 63 | 64 | virtual void Uncompress(std::string& uncompressed, 65 | const void* compressed, 66 | size_t compressedSize); 67 | }; 68 | } 69 | -------------------------------------------------------------------------------- /Core/DicomFormat/DicomArray.cpp: -------------------------------------------------------------------------------- 1 | /** 2 | * Orthanc - A Lightweight, RESTful DICOM Store 3 | * Copyright (C) 2012-2013 Medical Physics Department, CHU of Liege, 4 | * Belgium 5 | * 6 | * This program is free software: you can redistribute it and/or 7 | * modify it under the terms of the GNU General Public License as 8 | * published by the Free Software Foundation, either version 3 of the 9 | * License, or (at your option) any later version. 10 | * 11 | * In addition, as a special exception, the copyright holders of this 12 | * program give permission to link the code of its release with the 13 | * OpenSSL project's "OpenSSL" library (or with modified versions of it 14 | * that use the same license as the "OpenSSL" library), and distribute 15 | * the linked executables. You must obey the GNU General Public License 16 | * in all respects for all of the code used other than "OpenSSL". If you 17 | * modify file(s) with this exception, you may extend this exception to 18 | * your version of the file(s), but you are not obligated to do so. If 19 | * you do not wish to do so, delete this exception statement from your 20 | * version. If you delete this exception statement from all source files 21 | * in the program, then also delete it here. 22 | * 23 | * This program is distributed in the hope that it will be useful, but 24 | * WITHOUT ANY WARRANTY; without even the implied warranty of 25 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 26 | * General Public License for more details. 27 | * 28 | * You should have received a copy of the GNU General Public License 29 | * along with this program. If not, see . 30 | **/ 31 | 32 | 33 | #include "DicomArray.h" 34 | 35 | #include 36 | 37 | namespace Orthanc 38 | { 39 | DicomArray::DicomArray(const DicomMap& map) 40 | { 41 | elements_.reserve(map.map_.size()); 42 | 43 | for (DicomMap::Map::const_iterator it = 44 | map.map_.begin(); it != map.map_.end(); it++) 45 | { 46 | elements_.push_back(new DicomElement(it->first, *it->second)); 47 | } 48 | } 49 | 50 | 51 | DicomArray::~DicomArray() 52 | { 53 | for (size_t i = 0; i < elements_.size(); i++) 54 | { 55 | delete elements_[i]; 56 | } 57 | } 58 | 59 | 60 | void DicomArray::Print(FILE* fp) const 61 | { 62 | for (size_t i = 0; i < elements_.size(); i++) 63 | { 64 | DicomTag t = elements_[i]->GetTag(); 65 | std::string s = elements_[i]->GetValue().AsString(); 66 | printf("0x%04x 0x%04x [%s]\n", t.GetGroup(), t.GetElement(), s.c_str()); 67 | } 68 | } 69 | } 70 | -------------------------------------------------------------------------------- /Core/DicomFormat/DicomArray.h: -------------------------------------------------------------------------------- 1 | /** 2 | * Orthanc - A Lightweight, RESTful DICOM Store 3 | * Copyright (C) 2012-2013 Medical Physics Department, CHU of Liege, 4 | * Belgium 5 | * 6 | * This program is free software: you can redistribute it and/or 7 | * modify it under the terms of the GNU General Public License as 8 | * published by the Free Software Foundation, either version 3 of the 9 | * License, or (at your option) any later version. 10 | * 11 | * In addition, as a special exception, the copyright holders of this 12 | * program give permission to link the code of its release with the 13 | * OpenSSL project's "OpenSSL" library (or with modified versions of it 14 | * that use the same license as the "OpenSSL" library), and distribute 15 | * the linked executables. You must obey the GNU General Public License 16 | * in all respects for all of the code used other than "OpenSSL". If you 17 | * modify file(s) with this exception, you may extend this exception to 18 | * your version of the file(s), but you are not obligated to do so. If 19 | * you do not wish to do so, delete this exception statement from your 20 | * version. If you delete this exception statement from all source files 21 | * in the program, then also delete it here. 22 | * 23 | * This program is distributed in the hope that it will be useful, but 24 | * WITHOUT ANY WARRANTY; without even the implied warranty of 25 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 26 | * General Public License for more details. 27 | * 28 | * You should have received a copy of the GNU General Public License 29 | * along with this program. If not, see . 30 | **/ 31 | 32 | 33 | #pragma once 34 | 35 | #include "DicomElement.h" 36 | #include "DicomMap.h" 37 | 38 | #include 39 | 40 | namespace Orthanc 41 | { 42 | class DicomArray : public boost::noncopyable 43 | { 44 | private: 45 | typedef std::vector Elements; 46 | 47 | Elements elements_; 48 | 49 | public: 50 | DicomArray(const DicomMap& map); 51 | 52 | ~DicomArray(); 53 | 54 | size_t GetSize() const 55 | { 56 | return elements_.size(); 57 | } 58 | 59 | const DicomElement& GetElement(size_t i) const 60 | { 61 | return *elements_[i]; 62 | } 63 | 64 | void Print(FILE* fp) const; 65 | }; 66 | } 67 | -------------------------------------------------------------------------------- /Core/DicomFormat/DicomElement.h: -------------------------------------------------------------------------------- 1 | /** 2 | * Orthanc - A Lightweight, RESTful DICOM Store 3 | * Copyright (C) 2012-2013 Medical Physics Department, CHU of Liege, 4 | * Belgium 5 | * 6 | * This program is free software: you can redistribute it and/or 7 | * modify it under the terms of the GNU General Public License as 8 | * published by the Free Software Foundation, either version 3 of the 9 | * License, or (at your option) any later version. 10 | * 11 | * In addition, as a special exception, the copyright holders of this 12 | * program give permission to link the code of its release with the 13 | * OpenSSL project's "OpenSSL" library (or with modified versions of it 14 | * that use the same license as the "OpenSSL" library), and distribute 15 | * the linked executables. You must obey the GNU General Public License 16 | * in all respects for all of the code used other than "OpenSSL". If you 17 | * modify file(s) with this exception, you may extend this exception to 18 | * your version of the file(s), but you are not obligated to do so. If 19 | * you do not wish to do so, delete this exception statement from your 20 | * version. If you delete this exception statement from all source files 21 | * in the program, then also delete it here. 22 | * 23 | * This program is distributed in the hope that it will be useful, but 24 | * WITHOUT ANY WARRANTY; without even the implied warranty of 25 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 26 | * General Public License for more details. 27 | * 28 | * You should have received a copy of the GNU General Public License 29 | * along with this program. If not, see . 30 | **/ 31 | 32 | 33 | #pragma once 34 | 35 | #include "DicomValue.h" 36 | #include "DicomTag.h" 37 | 38 | namespace Orthanc 39 | { 40 | class DicomElement : public boost::noncopyable 41 | { 42 | private: 43 | DicomTag tag_; 44 | DicomValue* value_; 45 | 46 | public: 47 | DicomElement(uint16_t group, 48 | uint16_t element, 49 | const DicomValue& value) : 50 | tag_(group, element), 51 | value_(value.Clone()) 52 | { 53 | } 54 | 55 | DicomElement(const DicomTag& tag, 56 | const DicomValue& value) : 57 | tag_(tag), 58 | value_(value.Clone()) 59 | { 60 | } 61 | 62 | ~DicomElement() 63 | { 64 | delete value_; 65 | } 66 | 67 | const DicomTag& GetTag() const 68 | { 69 | return tag_; 70 | } 71 | 72 | const DicomValue& GetValue() const 73 | { 74 | return *value_; 75 | } 76 | 77 | uint16_t GetTagGroup() const 78 | { 79 | return tag_.GetGroup(); 80 | } 81 | 82 | uint16_t GetTagElement() const 83 | { 84 | return tag_.GetElement(); 85 | } 86 | 87 | bool operator< (const DicomElement& other) const 88 | { 89 | return GetTag() < other.GetTag(); 90 | } 91 | }; 92 | } 93 | -------------------------------------------------------------------------------- /Core/DicomFormat/DicomNullValue.h: -------------------------------------------------------------------------------- 1 | /** 2 | * Orthanc - A Lightweight, RESTful DICOM Store 3 | * Copyright (C) 2012-2013 Medical Physics Department, CHU of Liege, 4 | * Belgium 5 | * 6 | * This program is free software: you can redistribute it and/or 7 | * modify it under the terms of the GNU General Public License as 8 | * published by the Free Software Foundation, either version 3 of the 9 | * License, or (at your option) any later version. 10 | * 11 | * In addition, as a special exception, the copyright holders of this 12 | * program give permission to link the code of its release with the 13 | * OpenSSL project's "OpenSSL" library (or with modified versions of it 14 | * that use the same license as the "OpenSSL" library), and distribute 15 | * the linked executables. You must obey the GNU General Public License 16 | * in all respects for all of the code used other than "OpenSSL". If you 17 | * modify file(s) with this exception, you may extend this exception to 18 | * your version of the file(s), but you are not obligated to do so. If 19 | * you do not wish to do so, delete this exception statement from your 20 | * version. If you delete this exception statement from all source files 21 | * in the program, then also delete it here. 22 | * 23 | * This program is distributed in the hope that it will be useful, but 24 | * WITHOUT ANY WARRANTY; without even the implied warranty of 25 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 26 | * General Public License for more details. 27 | * 28 | * You should have received a copy of the GNU General Public License 29 | * along with this program. If not, see . 30 | **/ 31 | 32 | 33 | #pragma once 34 | 35 | #include "DicomValue.h" 36 | 37 | namespace Orthanc 38 | { 39 | class DicomNullValue : public DicomValue 40 | { 41 | public: 42 | DicomNullValue() 43 | { 44 | } 45 | 46 | virtual DicomValue* Clone() const 47 | { 48 | return new DicomNullValue(); 49 | } 50 | 51 | virtual std::string AsString() const 52 | { 53 | return "(null)"; 54 | } 55 | 56 | virtual bool IsNull() const 57 | { 58 | return true; 59 | } 60 | }; 61 | } 62 | -------------------------------------------------------------------------------- /Core/DicomFormat/DicomString.h: -------------------------------------------------------------------------------- 1 | /** 2 | * Orthanc - A Lightweight, RESTful DICOM Store 3 | * Copyright (C) 2012-2013 Medical Physics Department, CHU of Liege, 4 | * Belgium 5 | * 6 | * This program is free software: you can redistribute it and/or 7 | * modify it under the terms of the GNU General Public License as 8 | * published by the Free Software Foundation, either version 3 of the 9 | * License, or (at your option) any later version. 10 | * 11 | * In addition, as a special exception, the copyright holders of this 12 | * program give permission to link the code of its release with the 13 | * OpenSSL project's "OpenSSL" library (or with modified versions of it 14 | * that use the same license as the "OpenSSL" library), and distribute 15 | * the linked executables. You must obey the GNU General Public License 16 | * in all respects for all of the code used other than "OpenSSL". If you 17 | * modify file(s) with this exception, you may extend this exception to 18 | * your version of the file(s), but you are not obligated to do so. If 19 | * you do not wish to do so, delete this exception statement from your 20 | * version. If you delete this exception statement from all source files 21 | * in the program, then also delete it here. 22 | * 23 | * This program is distributed in the hope that it will be useful, but 24 | * WITHOUT ANY WARRANTY; without even the implied warranty of 25 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 26 | * General Public License for more details. 27 | * 28 | * You should have received a copy of the GNU General Public License 29 | * along with this program. If not, see . 30 | **/ 31 | 32 | 33 | #pragma once 34 | 35 | #include "DicomValue.h" 36 | 37 | namespace Orthanc 38 | { 39 | class DicomString : public DicomValue 40 | { 41 | private: 42 | std::string value_; 43 | 44 | public: 45 | DicomString(const std::string& v) : value_(v) 46 | { 47 | } 48 | 49 | DicomString(const char* v) 50 | { 51 | if (v) 52 | value_ = v; 53 | else 54 | value_ = ""; 55 | } 56 | 57 | virtual DicomValue* Clone() const 58 | { 59 | return new DicomString(value_); 60 | } 61 | 62 | virtual std::string AsString() const 63 | { 64 | return value_; 65 | } 66 | }; 67 | } 68 | -------------------------------------------------------------------------------- /Core/DicomFormat/DicomValue.h: -------------------------------------------------------------------------------- 1 | /** 2 | * Orthanc - A Lightweight, RESTful DICOM Store 3 | * Copyright (C) 2012-2013 Medical Physics Department, CHU of Liege, 4 | * Belgium 5 | * 6 | * This program is free software: you can redistribute it and/or 7 | * modify it under the terms of the GNU General Public License as 8 | * published by the Free Software Foundation, either version 3 of the 9 | * License, or (at your option) any later version. 10 | * 11 | * In addition, as a special exception, the copyright holders of this 12 | * program give permission to link the code of its release with the 13 | * OpenSSL project's "OpenSSL" library (or with modified versions of it 14 | * that use the same license as the "OpenSSL" library), and distribute 15 | * the linked executables. You must obey the GNU General Public License 16 | * in all respects for all of the code used other than "OpenSSL". If you 17 | * modify file(s) with this exception, you may extend this exception to 18 | * your version of the file(s), but you are not obligated to do so. If 19 | * you do not wish to do so, delete this exception statement from your 20 | * version. If you delete this exception statement from all source files 21 | * in the program, then also delete it here. 22 | * 23 | * This program is distributed in the hope that it will be useful, but 24 | * WITHOUT ANY WARRANTY; without even the implied warranty of 25 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 26 | * General Public License for more details. 27 | * 28 | * You should have received a copy of the GNU General Public License 29 | * along with this program. If not, see . 30 | **/ 31 | 32 | 33 | #pragma once 34 | 35 | #include "../IDynamicObject.h" 36 | 37 | #include 38 | 39 | namespace Orthanc 40 | { 41 | class DicomValue : public IDynamicObject 42 | { 43 | public: 44 | virtual DicomValue* Clone() const = 0; 45 | 46 | virtual std::string AsString() const = 0; 47 | 48 | virtual bool IsNull() const 49 | { 50 | return false; 51 | } 52 | }; 53 | } 54 | -------------------------------------------------------------------------------- /Core/FileStorage/CompressedFileStorageAccessor.h: -------------------------------------------------------------------------------- 1 | /** 2 | * Orthanc - A Lightweight, RESTful DICOM Store 3 | * Copyright (C) 2012-2013 Medical Physics Department, CHU of Liege, 4 | * Belgium 5 | * 6 | * This program is free software: you can redistribute it and/or 7 | * modify it under the terms of the GNU General Public License as 8 | * published by the Free Software Foundation, either version 3 of the 9 | * License, or (at your option) any later version. 10 | * 11 | * In addition, as a special exception, the copyright holders of this 12 | * program give permission to link the code of its release with the 13 | * OpenSSL project's "OpenSSL" library (or with modified versions of it 14 | * that use the same license as the "OpenSSL" library), and distribute 15 | * the linked executables. You must obey the GNU General Public License 16 | * in all respects for all of the code used other than "OpenSSL". If you 17 | * modify file(s) with this exception, you may extend this exception to 18 | * your version of the file(s), but you are not obligated to do so. If 19 | * you do not wish to do so, delete this exception statement from your 20 | * version. If you delete this exception statement from all source files 21 | * in the program, then also delete it here. 22 | * 23 | * This program is distributed in the hope that it will be useful, but 24 | * WITHOUT ANY WARRANTY; without even the implied warranty of 25 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 26 | * General Public License for more details. 27 | * 28 | * You should have received a copy of the GNU General Public License 29 | * along with this program. If not, see . 30 | **/ 31 | 32 | 33 | #pragma once 34 | 35 | #include "StorageAccessor.h" 36 | #include "FileStorage.h" 37 | #include "../Compression/ZlibCompressor.h" 38 | 39 | namespace Orthanc 40 | { 41 | class CompressedFileStorageAccessor : public StorageAccessor 42 | { 43 | private: 44 | FileStorage& storage_; 45 | ZlibCompressor zlib_; 46 | CompressionType compressionType_; 47 | 48 | protected: 49 | virtual FileInfo WriteInternal(const void* data, 50 | size_t size, 51 | FileContentType type); 52 | 53 | public: 54 | CompressedFileStorageAccessor(FileStorage& storage); 55 | 56 | void SetCompressionForNextOperations(CompressionType compression) 57 | { 58 | compressionType_ = compression; 59 | } 60 | 61 | CompressionType GetCompressionForNextOperations() 62 | { 63 | return compressionType_; 64 | } 65 | 66 | virtual void Read(std::string& content, 67 | const std::string& uuid); 68 | 69 | virtual HttpFileSender* ConstructHttpFileSender(const std::string& uuid); 70 | }; 71 | } 72 | -------------------------------------------------------------------------------- /Core/FileStorage/FileStorageAccessor.cpp: -------------------------------------------------------------------------------- 1 | /** 2 | * Orthanc - A Lightweight, RESTful DICOM Store 3 | * Copyright (C) 2012-2013 Medical Physics Department, CHU of Liege, 4 | * Belgium 5 | * 6 | * This program is free software: you can redistribute it and/or 7 | * modify it under the terms of the GNU General Public License as 8 | * published by the Free Software Foundation, either version 3 of the 9 | * License, or (at your option) any later version. 10 | * 11 | * In addition, as a special exception, the copyright holders of this 12 | * program give permission to link the code of its release with the 13 | * OpenSSL project's "OpenSSL" library (or with modified versions of it 14 | * that use the same license as the "OpenSSL" library), and distribute 15 | * the linked executables. You must obey the GNU General Public License 16 | * in all respects for all of the code used other than "OpenSSL". If you 17 | * modify file(s) with this exception, you may extend this exception to 18 | * your version of the file(s), but you are not obligated to do so. If 19 | * you do not wish to do so, delete this exception statement from your 20 | * version. If you delete this exception statement from all source files 21 | * in the program, then also delete it here. 22 | * 23 | * This program is distributed in the hope that it will be useful, but 24 | * WITHOUT ANY WARRANTY; without even the implied warranty of 25 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 26 | * General Public License for more details. 27 | * 28 | * You should have received a copy of the GNU General Public License 29 | * along with this program. If not, see . 30 | **/ 31 | 32 | 33 | #include "FileStorageAccessor.h" 34 | 35 | namespace Orthanc 36 | { 37 | FileInfo FileStorageAccessor::WriteInternal(const void* data, 38 | size_t size, 39 | FileContentType type) 40 | { 41 | return FileInfo(storage_.Create(data, size), type, size); 42 | } 43 | } 44 | -------------------------------------------------------------------------------- /Core/FileStorage/FileStorageAccessor.h: -------------------------------------------------------------------------------- 1 | /** 2 | * Orthanc - A Lightweight, RESTful DICOM Store 3 | * Copyright (C) 2012-2013 Medical Physics Department, CHU of Liege, 4 | * Belgium 5 | * 6 | * This program is free software: you can redistribute it and/or 7 | * modify it under the terms of the GNU General Public License as 8 | * published by the Free Software Foundation, either version 3 of the 9 | * License, or (at your option) any later version. 10 | * 11 | * In addition, as a special exception, the copyright holders of this 12 | * program give permission to link the code of its release with the 13 | * OpenSSL project's "OpenSSL" library (or with modified versions of it 14 | * that use the same license as the "OpenSSL" library), and distribute 15 | * the linked executables. You must obey the GNU General Public License 16 | * in all respects for all of the code used other than "OpenSSL". If you 17 | * modify file(s) with this exception, you may extend this exception to 18 | * your version of the file(s), but you are not obligated to do so. If 19 | * you do not wish to do so, delete this exception statement from your 20 | * version. If you delete this exception statement from all source files 21 | * in the program, then also delete it here. 22 | * 23 | * This program is distributed in the hope that it will be useful, but 24 | * WITHOUT ANY WARRANTY; without even the implied warranty of 25 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 26 | * General Public License for more details. 27 | * 28 | * You should have received a copy of the GNU General Public License 29 | * along with this program. If not, see . 30 | **/ 31 | 32 | 33 | #pragma once 34 | 35 | #include "StorageAccessor.h" 36 | #include "FileStorage.h" 37 | #include "../HttpServer/FilesystemHttpSender.h" 38 | 39 | namespace Orthanc 40 | { 41 | class FileStorageAccessor : public StorageAccessor 42 | { 43 | private: 44 | FileStorage& storage_; 45 | 46 | protected: 47 | virtual FileInfo WriteInternal(const void* data, 48 | size_t size, 49 | FileContentType type); 50 | 51 | public: 52 | FileStorageAccessor(FileStorage& storage) : storage_(storage) 53 | { 54 | } 55 | 56 | virtual void Read(std::string& content, 57 | const std::string& uuid) 58 | { 59 | storage_.ReadFile(content, uuid); 60 | } 61 | 62 | virtual HttpFileSender* ConstructHttpFileSender(const std::string& uuid) 63 | { 64 | return new FilesystemHttpSender(storage_.GetPath(uuid)); 65 | } 66 | }; 67 | } 68 | -------------------------------------------------------------------------------- /Core/FileStorage/StorageAccessor.cpp: -------------------------------------------------------------------------------- 1 | /** 2 | * Orthanc - A Lightweight, RESTful DICOM Store 3 | * Copyright (C) 2012-2013 Medical Physics Department, CHU of Liege, 4 | * Belgium 5 | * 6 | * This program is free software: you can redistribute it and/or 7 | * modify it under the terms of the GNU General Public License as 8 | * published by the Free Software Foundation, either version 3 of the 9 | * License, or (at your option) any later version. 10 | * 11 | * In addition, as a special exception, the copyright holders of this 12 | * program give permission to link the code of its release with the 13 | * OpenSSL project's "OpenSSL" library (or with modified versions of it 14 | * that use the same license as the "OpenSSL" library), and distribute 15 | * the linked executables. You must obey the GNU General Public License 16 | * in all respects for all of the code used other than "OpenSSL". If you 17 | * modify file(s) with this exception, you may extend this exception to 18 | * your version of the file(s), but you are not obligated to do so. If 19 | * you do not wish to do so, delete this exception statement from your 20 | * version. If you delete this exception statement from all source files 21 | * in the program, then also delete it here. 22 | * 23 | * This program is distributed in the hope that it will be useful, but 24 | * WITHOUT ANY WARRANTY; without even the implied warranty of 25 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 26 | * General Public License for more details. 27 | * 28 | * You should have received a copy of the GNU General Public License 29 | * along with this program. If not, see . 30 | **/ 31 | 32 | 33 | #include "StorageAccessor.h" 34 | 35 | namespace Orthanc 36 | { 37 | FileInfo StorageAccessor::Write(const std::vector& content, 38 | FileContentType type) 39 | { 40 | if (content.size() == 0) 41 | { 42 | return WriteInternal(NULL, 0, type); 43 | } 44 | else 45 | { 46 | return WriteInternal(&content[0], content.size(), type); 47 | } 48 | } 49 | 50 | FileInfo StorageAccessor::Write(const std::string& content, 51 | FileContentType type) 52 | { 53 | if (content.size() == 0) 54 | { 55 | return WriteInternal(NULL, 0, type); 56 | } 57 | else 58 | { 59 | return WriteInternal(&content[0], content.size(), type); 60 | } 61 | } 62 | } 63 | -------------------------------------------------------------------------------- /Core/FileStorage/StorageAccessor.h: -------------------------------------------------------------------------------- 1 | /** 2 | * Orthanc - A Lightweight, RESTful DICOM Store 3 | * Copyright (C) 2012-2013 Medical Physics Department, CHU of Liege, 4 | * Belgium 5 | * 6 | * This program is free software: you can redistribute it and/or 7 | * modify it under the terms of the GNU General Public License as 8 | * published by the Free Software Foundation, either version 3 of the 9 | * License, or (at your option) any later version. 10 | * 11 | * In addition, as a special exception, the copyright holders of this 12 | * program give permission to link the code of its release with the 13 | * OpenSSL project's "OpenSSL" library (or with modified versions of it 14 | * that use the same license as the "OpenSSL" library), and distribute 15 | * the linked executables. You must obey the GNU General Public License 16 | * in all respects for all of the code used other than "OpenSSL". If you 17 | * modify file(s) with this exception, you may extend this exception to 18 | * your version of the file(s), but you are not obligated to do so. If 19 | * you do not wish to do so, delete this exception statement from your 20 | * version. If you delete this exception statement from all source files 21 | * in the program, then also delete it here. 22 | * 23 | * This program is distributed in the hope that it will be useful, but 24 | * WITHOUT ANY WARRANTY; without even the implied warranty of 25 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 26 | * General Public License for more details. 27 | * 28 | * You should have received a copy of the GNU General Public License 29 | * along with this program. If not, see . 30 | **/ 31 | 32 | 33 | #pragma once 34 | 35 | #include "FileInfo.h" 36 | #include "../HttpServer/HttpFileSender.h" 37 | 38 | #include 39 | #include 40 | #include 41 | #include 42 | 43 | namespace Orthanc 44 | { 45 | class StorageAccessor : boost::noncopyable 46 | { 47 | protected: 48 | virtual FileInfo WriteInternal(const void* data, 49 | size_t size, 50 | FileContentType type) = 0; 51 | 52 | public: 53 | virtual ~StorageAccessor() 54 | { 55 | } 56 | 57 | FileInfo Write(const void* data, 58 | size_t size, 59 | FileContentType type) 60 | { 61 | return WriteInternal(data, size, type); 62 | } 63 | 64 | FileInfo Write(const std::vector& content, 65 | FileContentType type); 66 | 67 | FileInfo Write(const std::string& content, 68 | FileContentType type); 69 | 70 | virtual void Read(std::string& content, 71 | const std::string& uuid) = 0; 72 | 73 | virtual HttpFileSender* ConstructHttpFileSender(const std::string& uuid) = 0; 74 | }; 75 | } 76 | -------------------------------------------------------------------------------- /Core/HttpServer/BufferHttpSender.h: -------------------------------------------------------------------------------- 1 | /** 2 | * Orthanc - A Lightweight, RESTful DICOM Store 3 | * Copyright (C) 2012-2013 Medical Physics Department, CHU of Liege, 4 | * Belgium 5 | * 6 | * This program is free software: you can redistribute it and/or 7 | * modify it under the terms of the GNU General Public License as 8 | * published by the Free Software Foundation, either version 3 of the 9 | * License, or (at your option) any later version. 10 | * 11 | * In addition, as a special exception, the copyright holders of this 12 | * program give permission to link the code of its release with the 13 | * OpenSSL project's "OpenSSL" library (or with modified versions of it 14 | * that use the same license as the "OpenSSL" library), and distribute 15 | * the linked executables. You must obey the GNU General Public License 16 | * in all respects for all of the code used other than "OpenSSL". If you 17 | * modify file(s) with this exception, you may extend this exception to 18 | * your version of the file(s), but you are not obligated to do so. If 19 | * you do not wish to do so, delete this exception statement from your 20 | * version. If you delete this exception statement from all source files 21 | * in the program, then also delete it here. 22 | * 23 | * This program is distributed in the hope that it will be useful, but 24 | * WITHOUT ANY WARRANTY; without even the implied warranty of 25 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 26 | * General Public License for more details. 27 | * 28 | * You should have received a copy of the GNU General Public License 29 | * along with this program. If not, see . 30 | **/ 31 | 32 | #pragma once 33 | 34 | #include "HttpFileSender.h" 35 | 36 | namespace Orthanc 37 | { 38 | class BufferHttpSender : public HttpFileSender 39 | { 40 | private: 41 | std::string buffer_; 42 | 43 | protected: 44 | virtual uint64_t GetFileSize() 45 | { 46 | return buffer_.size(); 47 | } 48 | 49 | virtual bool SendData(HttpOutput& output) 50 | { 51 | if (buffer_.size()) 52 | output.Send(&buffer_[0], buffer_.size()); 53 | 54 | return true; 55 | } 56 | 57 | public: 58 | std::string& GetBuffer() 59 | { 60 | return buffer_; 61 | } 62 | 63 | const std::string& GetBuffer() const 64 | { 65 | return buffer_; 66 | } 67 | }; 68 | } 69 | -------------------------------------------------------------------------------- /Core/HttpServer/EmbeddedResourceHttpHandler.h: -------------------------------------------------------------------------------- 1 | /** 2 | * Orthanc - A Lightweight, RESTful DICOM Store 3 | * Copyright (C) 2012-2013 Medical Physics Department, CHU of Liege, 4 | * Belgium 5 | * 6 | * This program is free software: you can redistribute it and/or 7 | * modify it under the terms of the GNU General Public License as 8 | * published by the Free Software Foundation, either version 3 of the 9 | * License, or (at your option) any later version. 10 | * 11 | * In addition, as a special exception, the copyright holders of this 12 | * program give permission to link the code of its release with the 13 | * OpenSSL project's "OpenSSL" library (or with modified versions of it 14 | * that use the same license as the "OpenSSL" library), and distribute 15 | * the linked executables. You must obey the GNU General Public License 16 | * in all respects for all of the code used other than "OpenSSL". If you 17 | * modify file(s) with this exception, you may extend this exception to 18 | * your version of the file(s), but you are not obligated to do so. If 19 | * you do not wish to do so, delete this exception statement from your 20 | * version. If you delete this exception statement from all source files 21 | * in the program, then also delete it here. 22 | * 23 | * This program is distributed in the hope that it will be useful, but 24 | * WITHOUT ANY WARRANTY; without even the implied warranty of 25 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 26 | * General Public License for more details. 27 | * 28 | * You should have received a copy of the GNU General Public License 29 | * along with this program. If not, see . 30 | **/ 31 | 32 | 33 | #pragma once 34 | 35 | #include "HttpHandler.h" 36 | 37 | #include // Autogenerated file 38 | #include 39 | 40 | namespace Orthanc 41 | { 42 | class EmbeddedResourceHttpHandler : public HttpHandler 43 | { 44 | private: 45 | UriComponents baseUri_; 46 | EmbeddedResources::DirectoryResourceId resourceId_; 47 | 48 | public: 49 | EmbeddedResourceHttpHandler( 50 | const std::string& baseUri, 51 | EmbeddedResources::DirectoryResourceId resourceId); 52 | 53 | virtual bool IsServedUri(const UriComponents& uri); 54 | 55 | virtual void Handle( 56 | HttpOutput& output, 57 | HttpMethod method, 58 | const UriComponents& uri, 59 | const Arguments& headers, 60 | const Arguments& arguments, 61 | const std::string&); 62 | }; 63 | } 64 | -------------------------------------------------------------------------------- /Core/HttpServer/FilesystemHttpHandler.h: -------------------------------------------------------------------------------- 1 | /** 2 | * Orthanc - A Lightweight, RESTful DICOM Store 3 | * Copyright (C) 2012-2013 Medical Physics Department, CHU of Liege, 4 | * Belgium 5 | * 6 | * This program is free software: you can redistribute it and/or 7 | * modify it under the terms of the GNU General Public License as 8 | * published by the Free Software Foundation, either version 3 of the 9 | * License, or (at your option) any later version. 10 | * 11 | * In addition, as a special exception, the copyright holders of this 12 | * program give permission to link the code of its release with the 13 | * OpenSSL project's "OpenSSL" library (or with modified versions of it 14 | * that use the same license as the "OpenSSL" library), and distribute 15 | * the linked executables. You must obey the GNU General Public License 16 | * in all respects for all of the code used other than "OpenSSL". If you 17 | * modify file(s) with this exception, you may extend this exception to 18 | * your version of the file(s), but you are not obligated to do so. If 19 | * you do not wish to do so, delete this exception statement from your 20 | * version. If you delete this exception statement from all source files 21 | * in the program, then also delete it here. 22 | * 23 | * This program is distributed in the hope that it will be useful, but 24 | * WITHOUT ANY WARRANTY; without even the implied warranty of 25 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 26 | * General Public License for more details. 27 | * 28 | * You should have received a copy of the GNU General Public License 29 | * along with this program. If not, see . 30 | **/ 31 | 32 | 33 | #pragma once 34 | 35 | #include "HttpHandler.h" 36 | 37 | #include 38 | 39 | namespace Orthanc 40 | { 41 | class FilesystemHttpHandler : public HttpHandler 42 | { 43 | private: 44 | // PImpl idiom to avoid the inclusion of boost::filesystem 45 | // throughout the software 46 | struct PImpl; 47 | boost::shared_ptr pimpl_; 48 | 49 | bool listDirectoryContent_; 50 | 51 | public: 52 | FilesystemHttpHandler(const std::string& baseUri, 53 | const std::string& root); 54 | 55 | virtual bool IsServedUri(const UriComponents& uri); 56 | 57 | virtual void Handle( 58 | HttpOutput& output, 59 | HttpMethod method, 60 | const UriComponents& uri, 61 | const Arguments& headers, 62 | const Arguments& arguments, 63 | const std::string&); 64 | 65 | bool IsListDirectoryContent() const 66 | { 67 | return listDirectoryContent_; 68 | } 69 | 70 | void SetListDirectoryContent(bool enabled) 71 | { 72 | listDirectoryContent_ = enabled; 73 | } 74 | }; 75 | } 76 | -------------------------------------------------------------------------------- /Core/HttpServer/FilesystemHttpSender.h: -------------------------------------------------------------------------------- 1 | /** 2 | * Orthanc - A Lightweight, RESTful DICOM Store 3 | * Copyright (C) 2012-2013 Medical Physics Department, CHU of Liege, 4 | * Belgium 5 | * 6 | * This program is free software: you can redistribute it and/or 7 | * modify it under the terms of the GNU General Public License as 8 | * published by the Free Software Foundation, either version 3 of the 9 | * License, or (at your option) any later version. 10 | * 11 | * In addition, as a special exception, the copyright holders of this 12 | * program give permission to link the code of its release with the 13 | * OpenSSL project's "OpenSSL" library (or with modified versions of it 14 | * that use the same license as the "OpenSSL" library), and distribute 15 | * the linked executables. You must obey the GNU General Public License 16 | * in all respects for all of the code used other than "OpenSSL". If you 17 | * modify file(s) with this exception, you may extend this exception to 18 | * your version of the file(s), but you are not obligated to do so. If 19 | * you do not wish to do so, delete this exception statement from your 20 | * version. If you delete this exception statement from all source files 21 | * in the program, then also delete it here. 22 | * 23 | * This program is distributed in the hope that it will be useful, but 24 | * WITHOUT ANY WARRANTY; without even the implied warranty of 25 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 26 | * General Public License for more details. 27 | * 28 | * You should have received a copy of the GNU General Public License 29 | * along with this program. If not, see . 30 | **/ 31 | 32 | #pragma once 33 | 34 | #include "HttpFileSender.h" 35 | #include "../FileStorage/FileStorage.h" 36 | 37 | namespace Orthanc 38 | { 39 | class FilesystemHttpSender : public HttpFileSender 40 | { 41 | private: 42 | boost::filesystem::path path_; 43 | 44 | void Setup(); 45 | 46 | protected: 47 | virtual uint64_t GetFileSize(); 48 | 49 | virtual bool SendData(HttpOutput& output); 50 | 51 | public: 52 | FilesystemHttpSender(const char* path); 53 | 54 | FilesystemHttpSender(const boost::filesystem::path& path); 55 | 56 | FilesystemHttpSender(const FileStorage& storage, 57 | const std::string& uuid); 58 | }; 59 | } 60 | -------------------------------------------------------------------------------- /Core/HttpServer/HttpFileSender.cpp: -------------------------------------------------------------------------------- 1 | /** 2 | * Orthanc - A Lightweight, RESTful DICOM Store 3 | * Copyright (C) 2012-2013 Medical Physics Department, CHU of Liege, 4 | * Belgium 5 | * 6 | * This program is free software: you can redistribute it and/or 7 | * modify it under the terms of the GNU General Public License as 8 | * published by the Free Software Foundation, either version 3 of the 9 | * License, or (at your option) any later version. 10 | * 11 | * In addition, as a special exception, the copyright holders of this 12 | * program give permission to link the code of its release with the 13 | * OpenSSL project's "OpenSSL" library (or with modified versions of it 14 | * that use the same license as the "OpenSSL" library), and distribute 15 | * the linked executables. You must obey the GNU General Public License 16 | * in all respects for all of the code used other than "OpenSSL". If you 17 | * modify file(s) with this exception, you may extend this exception to 18 | * your version of the file(s), but you are not obligated to do so. If 19 | * you do not wish to do so, delete this exception statement from your 20 | * version. If you delete this exception statement from all source files 21 | * in the program, then also delete it here. 22 | * 23 | * This program is distributed in the hope that it will be useful, but 24 | * WITHOUT ANY WARRANTY; without even the implied warranty of 25 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 26 | * General Public License for more details. 27 | * 28 | * You should have received a copy of the GNU General Public License 29 | * along with this program. If not, see . 30 | **/ 31 | 32 | 33 | #include "HttpFileSender.h" 34 | 35 | #include 36 | 37 | namespace Orthanc 38 | { 39 | void HttpFileSender::SendHeader(HttpOutput& output) 40 | { 41 | output.SendOkHeader(contentType_.c_str(), true, GetFileSize(), downloadFilename_.c_str()); 42 | } 43 | 44 | void HttpFileSender::Send(HttpOutput& output) 45 | { 46 | SendHeader(output); 47 | 48 | if (!SendData(output)) 49 | { 50 | output.SendHeader(HttpStatus_500_InternalServerError); 51 | } 52 | } 53 | } 54 | -------------------------------------------------------------------------------- /Core/HttpServer/HttpFileSender.h: -------------------------------------------------------------------------------- 1 | /** 2 | * Orthanc - A Lightweight, RESTful DICOM Store 3 | * Copyright (C) 2012-2013 Medical Physics Department, CHU of Liege, 4 | * Belgium 5 | * 6 | * This program is free software: you can redistribute it and/or 7 | * modify it under the terms of the GNU General Public License as 8 | * published by the Free Software Foundation, either version 3 of the 9 | * License, or (at your option) any later version. 10 | * 11 | * In addition, as a special exception, the copyright holders of this 12 | * program give permission to link the code of its release with the 13 | * OpenSSL project's "OpenSSL" library (or with modified versions of it 14 | * that use the same license as the "OpenSSL" library), and distribute 15 | * the linked executables. You must obey the GNU General Public License 16 | * in all respects for all of the code used other than "OpenSSL". If you 17 | * modify file(s) with this exception, you may extend this exception to 18 | * your version of the file(s), but you are not obligated to do so. If 19 | * you do not wish to do so, delete this exception statement from your 20 | * version. If you delete this exception statement from all source files 21 | * in the program, then also delete it here. 22 | * 23 | * This program is distributed in the hope that it will be useful, but 24 | * WITHOUT ANY WARRANTY; without even the implied warranty of 25 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 26 | * General Public License for more details. 27 | * 28 | * You should have received a copy of the GNU General Public License 29 | * along with this program. If not, see . 30 | **/ 31 | 32 | 33 | #pragma once 34 | 35 | #include "HttpOutput.h" 36 | 37 | namespace Orthanc 38 | { 39 | class HttpFileSender 40 | { 41 | private: 42 | std::string contentType_; 43 | std::string downloadFilename_; 44 | 45 | void SendHeader(HttpOutput& output); 46 | 47 | protected: 48 | virtual uint64_t GetFileSize() = 0; 49 | 50 | virtual bool SendData(HttpOutput& output) = 0; 51 | 52 | public: 53 | virtual ~HttpFileSender() 54 | { 55 | } 56 | 57 | void ResetContentType() 58 | { 59 | contentType_.clear(); 60 | } 61 | 62 | void SetContentType(const std::string& contentType) 63 | { 64 | contentType_ = contentType; 65 | } 66 | 67 | const std::string& GetContentType() const 68 | { 69 | return contentType_; 70 | } 71 | 72 | void ResetDownloadFilename() 73 | { 74 | downloadFilename_.clear(); 75 | } 76 | 77 | void SetDownloadFilename(const std::string& filename) 78 | { 79 | downloadFilename_ = filename; 80 | } 81 | 82 | const std::string& GetDownloadFilename() const 83 | { 84 | return downloadFilename_; 85 | } 86 | 87 | void Send(HttpOutput& output); 88 | }; 89 | } 90 | -------------------------------------------------------------------------------- /Core/HttpServer/HttpHandler.h: -------------------------------------------------------------------------------- 1 | /** 2 | * Orthanc - A Lightweight, RESTful DICOM Store 3 | * Copyright (C) 2012-2013 Medical Physics Department, CHU of Liege, 4 | * Belgium 5 | * 6 | * This program is free software: you can redistribute it and/or 7 | * modify it under the terms of the GNU General Public License as 8 | * published by the Free Software Foundation, either version 3 of the 9 | * License, or (at your option) any later version. 10 | * 11 | * In addition, as a special exception, the copyright holders of this 12 | * program give permission to link the code of its release with the 13 | * OpenSSL project's "OpenSSL" library (or with modified versions of it 14 | * that use the same license as the "OpenSSL" library), and distribute 15 | * the linked executables. You must obey the GNU General Public License 16 | * in all respects for all of the code used other than "OpenSSL". If you 17 | * modify file(s) with this exception, you may extend this exception to 18 | * your version of the file(s), but you are not obligated to do so. If 19 | * you do not wish to do so, delete this exception statement from your 20 | * version. If you delete this exception statement from all source files 21 | * in the program, then also delete it here. 22 | * 23 | * This program is distributed in the hope that it will be useful, but 24 | * WITHOUT ANY WARRANTY; without even the implied warranty of 25 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 26 | * General Public License for more details. 27 | * 28 | * You should have received a copy of the GNU General Public License 29 | * along with this program. If not, see . 30 | **/ 31 | 32 | 33 | #pragma once 34 | 35 | #include 36 | #include 37 | #include 38 | #include "../Toolbox.h" 39 | 40 | namespace Orthanc 41 | { 42 | class HttpOutput; 43 | 44 | class HttpHandler 45 | { 46 | public: 47 | typedef std::map Arguments; 48 | 49 | virtual ~HttpHandler() 50 | { 51 | } 52 | 53 | virtual bool IsServedUri(const UriComponents& uri) = 0; 54 | 55 | virtual void Handle(HttpOutput& output, 56 | HttpMethod method, 57 | const UriComponents& uri, 58 | const Arguments& headers, 59 | const Arguments& getArguments, 60 | const std::string& postData) = 0; 61 | 62 | static void ParseGetQuery(HttpHandler::Arguments& result, 63 | const char* query); 64 | 65 | static std::string GetArgument(const Arguments& getArguments, 66 | const std::string& name, 67 | const std::string& defaultValue); 68 | 69 | static void ParseCookies(HttpHandler::Arguments& result, 70 | const HttpHandler::Arguments& httpHeaders); 71 | }; 72 | } 73 | -------------------------------------------------------------------------------- /Core/ICommand.h: -------------------------------------------------------------------------------- 1 | /** 2 | * Orthanc - A Lightweight, RESTful DICOM Store 3 | * Copyright (C) 2012-2013 Medical Physics Department, CHU of Liege, 4 | * Belgium 5 | * 6 | * This program is free software: you can redistribute it and/or 7 | * modify it under the terms of the GNU General Public License as 8 | * published by the Free Software Foundation, either version 3 of the 9 | * License, or (at your option) any later version. 10 | * 11 | * In addition, as a special exception, the copyright holders of this 12 | * program give permission to link the code of its release with the 13 | * OpenSSL project's "OpenSSL" library (or with modified versions of it 14 | * that use the same license as the "OpenSSL" library), and distribute 15 | * the linked executables. You must obey the GNU General Public License 16 | * in all respects for all of the code used other than "OpenSSL". If you 17 | * modify file(s) with this exception, you may extend this exception to 18 | * your version of the file(s), but you are not obligated to do so. If 19 | * you do not wish to do so, delete this exception statement from your 20 | * version. If you delete this exception statement from all source files 21 | * in the program, then also delete it here. 22 | * 23 | * This program is distributed in the hope that it will be useful, but 24 | * WITHOUT ANY WARRANTY; without even the implied warranty of 25 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 26 | * General Public License for more details. 27 | * 28 | * You should have received a copy of the GNU General Public License 29 | * along with this program. If not, see . 30 | **/ 31 | 32 | 33 | #pragma once 34 | 35 | #include "IDynamicObject.h" 36 | 37 | namespace Orthanc 38 | { 39 | /** 40 | * This class is the base class for the "Command" design pattern. 41 | * http://en.wikipedia.org/wiki/Command_pattern 42 | **/ 43 | class ICommand : public IDynamicObject 44 | { 45 | public: 46 | virtual bool Execute() = 0; 47 | }; 48 | } 49 | -------------------------------------------------------------------------------- /Core/IDynamicObject.h: -------------------------------------------------------------------------------- 1 | /** 2 | * Orthanc - A Lightweight, RESTful DICOM Store 3 | * Copyright (C) 2012-2013 Medical Physics Department, CHU of Liege, 4 | * Belgium 5 | * 6 | * This program is free software: you can redistribute it and/or 7 | * modify it under the terms of the GNU General Public License as 8 | * published by the Free Software Foundation, either version 3 of the 9 | * License, or (at your option) any later version. 10 | * 11 | * In addition, as a special exception, the copyright holders of this 12 | * program give permission to link the code of its release with the 13 | * OpenSSL project's "OpenSSL" library (or with modified versions of it 14 | * that use the same license as the "OpenSSL" library), and distribute 15 | * the linked executables. You must obey the GNU General Public License 16 | * in all respects for all of the code used other than "OpenSSL". If you 17 | * modify file(s) with this exception, you may extend this exception to 18 | * your version of the file(s), but you are not obligated to do so. If 19 | * you do not wish to do so, delete this exception statement from your 20 | * version. If you delete this exception statement from all source files 21 | * in the program, then also delete it here. 22 | * 23 | * This program is distributed in the hope that it will be useful, but 24 | * WITHOUT ANY WARRANTY; without even the implied warranty of 25 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 26 | * General Public License for more details. 27 | * 28 | * You should have received a copy of the GNU General Public License 29 | * along with this program. If not, see . 30 | **/ 31 | 32 | 33 | #pragma once 34 | 35 | #include 36 | 37 | namespace Orthanc 38 | { 39 | /** 40 | * This class should be the ancestor to any class whose type is 41 | * determined at the runtime, and that can be dynamically allocated. 42 | * Being a child of IDynamicObject only implies the existence of a 43 | * virtual destructor. 44 | **/ 45 | class IDynamicObject : public boost::noncopyable 46 | { 47 | public: 48 | virtual ~IDynamicObject() 49 | { 50 | } 51 | }; 52 | } 53 | -------------------------------------------------------------------------------- /Core/Lua/LuaContext.h: -------------------------------------------------------------------------------- 1 | /** 2 | * Orthanc - A Lightweight, RESTful DICOM Store 3 | * Copyright (C) 2012-2013 Medical Physics Department, CHU of Liege, 4 | * Belgium 5 | * 6 | * This program is free software: you can redistribute it and/or 7 | * modify it under the terms of the GNU General Public License as 8 | * published by the Free Software Foundation, either version 3 of the 9 | * License, or (at your option) any later version. 10 | * 11 | * In addition, as a special exception, the copyright holders of this 12 | * program give permission to link the code of its release with the 13 | * OpenSSL project's "OpenSSL" library (or with modified versions of it 14 | * that use the same license as the "OpenSSL" library), and distribute 15 | * the linked executables. You must obey the GNU General Public License 16 | * in all respects for all of the code used other than "OpenSSL". If you 17 | * modify file(s) with this exception, you may extend this exception to 18 | * your version of the file(s), but you are not obligated to do so. If 19 | * you do not wish to do so, delete this exception statement from your 20 | * version. If you delete this exception statement from all source files 21 | * in the program, then also delete it here. 22 | * 23 | * This program is distributed in the hope that it will be useful, but 24 | * WITHOUT ANY WARRANTY; without even the implied warranty of 25 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 26 | * General Public License for more details. 27 | * 28 | * You should have received a copy of the GNU General Public License 29 | * along with this program. If not, see . 30 | **/ 31 | 32 | 33 | #pragma once 34 | 35 | #include "LuaException.h" 36 | 37 | #include 38 | 39 | extern "C" 40 | { 41 | #include 42 | } 43 | 44 | #include 45 | 46 | 47 | namespace Orthanc 48 | { 49 | class LuaContext : public boost::noncopyable 50 | { 51 | private: 52 | friend class LuaFunctionCall; 53 | 54 | lua_State *lua_; 55 | boost::mutex mutex_; 56 | std::string log_; 57 | 58 | static int PrintToLog(lua_State *L); 59 | 60 | void Execute(std::string* output, 61 | const std::string& command); 62 | 63 | public: 64 | LuaContext(); 65 | 66 | ~LuaContext(); 67 | 68 | void Execute(const std::string& command) 69 | { 70 | Execute(NULL, command); 71 | } 72 | 73 | void Execute(std::string& output, 74 | const std::string& command) 75 | { 76 | Execute(&output, command); 77 | } 78 | 79 | void Execute(EmbeddedResources::FileResourceId resource); 80 | 81 | bool IsExistingFunction(const char* name); 82 | }; 83 | } 84 | -------------------------------------------------------------------------------- /Core/Lua/LuaException.h: -------------------------------------------------------------------------------- 1 | /** 2 | * Orthanc - A Lightweight, RESTful DICOM Store 3 | * Copyright (C) 2012-2013 Medical Physics Department, CHU of Liege, 4 | * Belgium 5 | * 6 | * This program is free software: you can redistribute it and/or 7 | * modify it under the terms of the GNU General Public License as 8 | * published by the Free Software Foundation, either version 3 of the 9 | * License, or (at your option) any later version. 10 | * 11 | * In addition, as a special exception, the copyright holders of this 12 | * program give permission to link the code of its release with the 13 | * OpenSSL project's "OpenSSL" library (or with modified versions of it 14 | * that use the same license as the "OpenSSL" library), and distribute 15 | * the linked executables. You must obey the GNU General Public License 16 | * in all respects for all of the code used other than "OpenSSL". If you 17 | * modify file(s) with this exception, you may extend this exception to 18 | * your version of the file(s), but you are not obligated to do so. If 19 | * you do not wish to do so, delete this exception statement from your 20 | * version. If you delete this exception statement from all source files 21 | * in the program, then also delete it here. 22 | * 23 | * This program is distributed in the hope that it will be useful, but 24 | * WITHOUT ANY WARRANTY; without even the implied warranty of 25 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 26 | * General Public License for more details. 27 | * 28 | * You should have received a copy of the GNU General Public License 29 | * along with this program. If not, see . 30 | **/ 31 | 32 | 33 | #pragma once 34 | 35 | #include "../OrthancException.h" 36 | 37 | namespace Orthanc 38 | { 39 | class LuaException : public OrthancException 40 | { 41 | public: 42 | LuaException(const char* explanation) : 43 | OrthancException(explanation) 44 | { 45 | } 46 | 47 | LuaException(const std::string& explanation) : 48 | OrthancException(explanation) 49 | { 50 | } 51 | }; 52 | } 53 | -------------------------------------------------------------------------------- /Core/Lua/LuaFunctionCall.h: -------------------------------------------------------------------------------- 1 | /** 2 | * Orthanc - A Lightweight, RESTful DICOM Store 3 | * Copyright (C) 2012-2013 Medical Physics Department, CHU of Liege, 4 | * Belgium 5 | * 6 | * This program is free software: you can redistribute it and/or 7 | * modify it under the terms of the GNU General Public License as 8 | * published by the Free Software Foundation, either version 3 of the 9 | * License, or (at your option) any later version. 10 | * 11 | * In addition, as a special exception, the copyright holders of this 12 | * program give permission to link the code of its release with the 13 | * OpenSSL project's "OpenSSL" library (or with modified versions of it 14 | * that use the same license as the "OpenSSL" library), and distribute 15 | * the linked executables. You must obey the GNU General Public License 16 | * in all respects for all of the code used other than "OpenSSL". If you 17 | * modify file(s) with this exception, you may extend this exception to 18 | * your version of the file(s), but you are not obligated to do so. If 19 | * you do not wish to do so, delete this exception statement from your 20 | * version. If you delete this exception statement from all source files 21 | * in the program, then also delete it here. 22 | * 23 | * This program is distributed in the hope that it will be useful, but 24 | * WITHOUT ANY WARRANTY; without even the implied warranty of 25 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 26 | * General Public License for more details. 27 | * 28 | * You should have received a copy of the GNU General Public License 29 | * along with this program. If not, see . 30 | **/ 31 | 32 | 33 | #pragma once 34 | 35 | #include "LuaContext.h" 36 | 37 | #include 38 | 39 | 40 | namespace Orthanc 41 | { 42 | class LuaFunctionCall : public boost::noncopyable 43 | { 44 | private: 45 | LuaContext& context_; 46 | boost::mutex::scoped_lock lock_; 47 | bool isExecuted_; 48 | 49 | void CheckAlreadyExecuted(); 50 | 51 | public: 52 | LuaFunctionCall(LuaContext& context, 53 | const char* functionName); 54 | 55 | void PushString(const std::string& value); 56 | 57 | void PushBoolean(bool value); 58 | 59 | void PushInteger(int value); 60 | 61 | void PushDouble(double value); 62 | 63 | void PushJSON(const Json::Value& value); 64 | 65 | void Execute(int numOutputs = 0); 66 | 67 | bool ExecutePredicate(); 68 | }; 69 | } 70 | -------------------------------------------------------------------------------- /Core/MultiThreading/ArrayFilledByThreads.cpp: -------------------------------------------------------------------------------- 1 | #include "ArrayFilledByThreads.h" 2 | 3 | #include "../MultiThreading/ThreadedCommandProcessor.h" 4 | #include "../OrthancException.h" 5 | 6 | namespace Orthanc 7 | { 8 | class ArrayFilledByThreads::Command : public ICommand 9 | { 10 | private: 11 | ArrayFilledByThreads& that_; 12 | size_t index_; 13 | 14 | public: 15 | Command(ArrayFilledByThreads& that, 16 | size_t index) : 17 | that_(that), 18 | index_(index) 19 | { 20 | } 21 | 22 | virtual bool Execute() 23 | { 24 | std::auto_ptr obj(that_.filler_.GetFillerItem(index_)); 25 | if (obj.get() == NULL) 26 | { 27 | return false; 28 | } 29 | else 30 | { 31 | boost::mutex::scoped_lock lock(that_.mutex_); 32 | that_.array_[index_] = obj.release(); 33 | return true; 34 | } 35 | } 36 | }; 37 | 38 | void ArrayFilledByThreads::Clear() 39 | { 40 | for (size_t i = 0; i < array_.size(); i++) 41 | { 42 | if (array_[i]) 43 | delete array_[i]; 44 | } 45 | 46 | array_.clear(); 47 | filled_ = false; 48 | } 49 | 50 | void ArrayFilledByThreads::Update() 51 | { 52 | if (!filled_) 53 | { 54 | array_.resize(filler_.GetFillerSize()); 55 | 56 | Orthanc::ThreadedCommandProcessor processor(threadCount_); 57 | for (size_t i = 0; i < array_.size(); i++) 58 | { 59 | processor.Post(new Command(*this, i)); 60 | } 61 | 62 | processor.Join(); 63 | filled_ = true; 64 | } 65 | } 66 | 67 | 68 | ArrayFilledByThreads::ArrayFilledByThreads(IFiller& filler) : filler_(filler) 69 | { 70 | filled_ = false; 71 | threadCount_ = 4; 72 | } 73 | 74 | 75 | ArrayFilledByThreads::~ArrayFilledByThreads() 76 | { 77 | Clear(); 78 | } 79 | 80 | 81 | void ArrayFilledByThreads::Reload() 82 | { 83 | Clear(); 84 | Update(); 85 | } 86 | 87 | 88 | void ArrayFilledByThreads::Invalidate() 89 | { 90 | Clear(); 91 | } 92 | 93 | 94 | void ArrayFilledByThreads::SetThreadCount(unsigned int t) 95 | { 96 | if (t < 1) 97 | { 98 | throw OrthancException(ErrorCode_ParameterOutOfRange); 99 | } 100 | 101 | threadCount_ = t; 102 | } 103 | 104 | 105 | size_t ArrayFilledByThreads::GetSize() 106 | { 107 | Update(); 108 | return array_.size(); 109 | } 110 | 111 | 112 | IDynamicObject& ArrayFilledByThreads::GetItem(size_t index) 113 | { 114 | if (index >= GetSize()) 115 | { 116 | throw Orthanc::OrthancException(Orthanc::ErrorCode_ParameterOutOfRange); 117 | } 118 | 119 | return *array_[index]; 120 | } 121 | } 122 | -------------------------------------------------------------------------------- /Core/MultiThreading/ArrayFilledByThreads.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | 5 | #include "../ICommand.h" 6 | 7 | namespace Orthanc 8 | { 9 | class ArrayFilledByThreads 10 | { 11 | public: 12 | class IFiller 13 | { 14 | public: 15 | virtual size_t GetFillerSize() = 0; 16 | 17 | virtual IDynamicObject* GetFillerItem(size_t index) = 0; 18 | }; 19 | 20 | private: 21 | IFiller& filler_; 22 | boost::mutex mutex_; 23 | std::vector array_; 24 | bool filled_; 25 | unsigned int threadCount_; 26 | 27 | class Command; 28 | 29 | void Clear(); 30 | 31 | void Update(); 32 | 33 | public: 34 | ArrayFilledByThreads(IFiller& filler); 35 | 36 | ~ArrayFilledByThreads(); 37 | 38 | void Reload(); 39 | 40 | void Invalidate(); 41 | 42 | void SetThreadCount(unsigned int t); 43 | 44 | unsigned int GetThreadCount() const 45 | { 46 | return threadCount_; 47 | } 48 | 49 | size_t GetSize(); 50 | 51 | IDynamicObject& GetItem(size_t index); 52 | }; 53 | } 54 | 55 | -------------------------------------------------------------------------------- /Core/MultiThreading/BagOfRunnablesBySteps.h: -------------------------------------------------------------------------------- 1 | /** 2 | * Orthanc - A Lightweight, RESTful DICOM Store 3 | * Copyright (C) 2012-2013 Medical Physics Department, CHU of Liege, 4 | * Belgium 5 | * 6 | * This program is free software: you can redistribute it and/or 7 | * modify it under the terms of the GNU General Public License as 8 | * published by the Free Software Foundation, either version 3 of the 9 | * License, or (at your option) any later version. 10 | * 11 | * In addition, as a special exception, the copyright holders of this 12 | * program give permission to link the code of its release with the 13 | * OpenSSL project's "OpenSSL" library (or with modified versions of it 14 | * that use the same license as the "OpenSSL" library), and distribute 15 | * the linked executables. You must obey the GNU General Public License 16 | * in all respects for all of the code used other than "OpenSSL". If you 17 | * modify file(s) with this exception, you may extend this exception to 18 | * your version of the file(s), but you are not obligated to do so. If 19 | * you do not wish to do so, delete this exception statement from your 20 | * version. If you delete this exception statement from all source files 21 | * in the program, then also delete it here. 22 | * 23 | * This program is distributed in the hope that it will be useful, but 24 | * WITHOUT ANY WARRANTY; without even the implied warranty of 25 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 26 | * General Public License for more details. 27 | * 28 | * You should have received a copy of the GNU General Public License 29 | * along with this program. If not, see . 30 | **/ 31 | 32 | 33 | #pragma once 34 | 35 | #include "IRunnableBySteps.h" 36 | 37 | #include 38 | #include 39 | 40 | namespace Orthanc 41 | { 42 | class BagOfRunnablesBySteps : public boost::noncopyable 43 | { 44 | private: 45 | struct PImpl; 46 | boost::shared_ptr pimpl_; 47 | 48 | static void RunnableThread(BagOfRunnablesBySteps* bag, 49 | IRunnableBySteps* runnable); 50 | 51 | static void FinishListener(BagOfRunnablesBySteps* bag); 52 | 53 | public: 54 | BagOfRunnablesBySteps(); 55 | 56 | ~BagOfRunnablesBySteps(); 57 | 58 | void Add(IRunnableBySteps* runnable); 59 | 60 | void StopAll(); 61 | }; 62 | } 63 | -------------------------------------------------------------------------------- /Core/MultiThreading/IRunnableBySteps.h: -------------------------------------------------------------------------------- 1 | /** 2 | * Orthanc - A Lightweight, RESTful DICOM Store 3 | * Copyright (C) 2012-2013 Medical Physics Department, CHU of Liege, 4 | * Belgium 5 | * 6 | * This program is free software: you can redistribute it and/or 7 | * modify it under the terms of the GNU General Public License as 8 | * published by the Free Software Foundation, either version 3 of the 9 | * License, or (at your option) any later version. 10 | * 11 | * In addition, as a special exception, the copyright holders of this 12 | * program give permission to link the code of its release with the 13 | * OpenSSL project's "OpenSSL" library (or with modified versions of it 14 | * that use the same license as the "OpenSSL" library), and distribute 15 | * the linked executables. You must obey the GNU General Public License 16 | * in all respects for all of the code used other than "OpenSSL". If you 17 | * modify file(s) with this exception, you may extend this exception to 18 | * your version of the file(s), but you are not obligated to do so. If 19 | * you do not wish to do so, delete this exception statement from your 20 | * version. If you delete this exception statement from all source files 21 | * in the program, then also delete it here. 22 | * 23 | * This program is distributed in the hope that it will be useful, but 24 | * WITHOUT ANY WARRANTY; without even the implied warranty of 25 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 26 | * General Public License for more details. 27 | * 28 | * You should have received a copy of the GNU General Public License 29 | * along with this program. If not, see . 30 | **/ 31 | 32 | 33 | #pragma once 34 | 35 | namespace Orthanc 36 | { 37 | class IRunnableBySteps 38 | { 39 | public: 40 | virtual ~IRunnableBySteps() 41 | { 42 | } 43 | 44 | // Must return "true" if the runnable wishes to continue. Must 45 | // return "false" if the runnable has not finished its job. 46 | virtual bool Step() = 0; 47 | 48 | static void RunUntilDone(IRunnableBySteps& runnable) 49 | { 50 | while (runnable.Step()); 51 | } 52 | }; 53 | } 54 | -------------------------------------------------------------------------------- /Core/MultiThreading/SharedMessageQueue.h: -------------------------------------------------------------------------------- 1 | /** 2 | * Orthanc - A Lightweight, RESTful DICOM Store 3 | * Copyright (C) 2012-2013 Medical Physics Department, CHU of Liege, 4 | * Belgium 5 | * 6 | * This program is free software: you can redistribute it and/or 7 | * modify it under the terms of the GNU General Public License as 8 | * published by the Free Software Foundation, either version 3 of the 9 | * License, or (at your option) any later version. 10 | * 11 | * In addition, as a special exception, the copyright holders of this 12 | * program give permission to link the code of its release with the 13 | * OpenSSL project's "OpenSSL" library (or with modified versions of it 14 | * that use the same license as the "OpenSSL" library), and distribute 15 | * the linked executables. You must obey the GNU General Public License 16 | * in all respects for all of the code used other than "OpenSSL". If you 17 | * modify file(s) with this exception, you may extend this exception to 18 | * your version of the file(s), but you are not obligated to do so. If 19 | * you do not wish to do so, delete this exception statement from your 20 | * version. If you delete this exception statement from all source files 21 | * in the program, then also delete it here. 22 | * 23 | * This program is distributed in the hope that it will be useful, but 24 | * WITHOUT ANY WARRANTY; without even the implied warranty of 25 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 26 | * General Public License for more details. 27 | * 28 | * You should have received a copy of the GNU General Public License 29 | * along with this program. If not, see . 30 | **/ 31 | 32 | 33 | #pragma once 34 | 35 | #include "../IDynamicObject.h" 36 | 37 | #include 38 | #include 39 | #include 40 | 41 | namespace Orthanc 42 | { 43 | class SharedMessageQueue 44 | { 45 | private: 46 | typedef std::list Queue; 47 | 48 | unsigned int maxSize_; 49 | Queue queue_; 50 | boost::mutex mutex_; 51 | boost::condition_variable elementAvailable_; 52 | boost::condition_variable emptied_; 53 | 54 | public: 55 | SharedMessageQueue(unsigned int maxSize = 0); 56 | 57 | ~SharedMessageQueue(); 58 | 59 | // This transfers the ownership of the message 60 | void Enqueue(IDynamicObject* message); 61 | 62 | // The caller is responsible to delete the dequeud message! 63 | IDynamicObject* Dequeue(int32_t millisecondsTimeout); 64 | 65 | bool WaitEmpty(int32_t millisecondsTimeout); 66 | }; 67 | } 68 | -------------------------------------------------------------------------------- /Core/OrthancException.h: -------------------------------------------------------------------------------- 1 | /** 2 | * Orthanc - A Lightweight, RESTful DICOM Store 3 | * Copyright (C) 2012-2013 Medical Physics Department, CHU of Liege, 4 | * Belgium 5 | * 6 | * This program is free software: you can redistribute it and/or 7 | * modify it under the terms of the GNU General Public License as 8 | * published by the Free Software Foundation, either version 3 of the 9 | * License, or (at your option) any later version. 10 | * 11 | * In addition, as a special exception, the copyright holders of this 12 | * program give permission to link the code of its release with the 13 | * OpenSSL project's "OpenSSL" library (or with modified versions of it 14 | * that use the same license as the "OpenSSL" library), and distribute 15 | * the linked executables. You must obey the GNU General Public License 16 | * in all respects for all of the code used other than "OpenSSL". If you 17 | * modify file(s) with this exception, you may extend this exception to 18 | * your version of the file(s), but you are not obligated to do so. If 19 | * you do not wish to do so, delete this exception statement from your 20 | * version. If you delete this exception statement from all source files 21 | * in the program, then also delete it here. 22 | * 23 | * This program is distributed in the hope that it will be useful, but 24 | * WITHOUT ANY WARRANTY; without even the implied warranty of 25 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 26 | * General Public License for more details. 27 | * 28 | * You should have received a copy of the GNU General Public License 29 | * along with this program. If not, see . 30 | **/ 31 | 32 | 33 | #pragma once 34 | 35 | #include 36 | #include "Enumerations.h" 37 | 38 | namespace Orthanc 39 | { 40 | class OrthancException 41 | { 42 | protected: 43 | ErrorCode error_; 44 | std::string custom_; 45 | 46 | public: 47 | static const char* GetDescription(ErrorCode error); 48 | 49 | OrthancException(const char* custom) 50 | { 51 | error_ = ErrorCode_Custom; 52 | custom_ = custom; 53 | } 54 | 55 | OrthancException(const std::string& custom) 56 | { 57 | error_ = ErrorCode_Custom; 58 | custom_ = custom; 59 | } 60 | 61 | OrthancException(ErrorCode error) 62 | { 63 | error_ = error; 64 | } 65 | 66 | ErrorCode GetErrorCode() const 67 | { 68 | return error_; 69 | } 70 | 71 | const char* What() const; 72 | }; 73 | } 74 | -------------------------------------------------------------------------------- /Core/RestApi/RestApiPath.h: -------------------------------------------------------------------------------- 1 | /** 2 | * Orthanc - A Lightweight, RESTful DICOM Store 3 | * Copyright (C) 2012-2013 Medical Physics Department, CHU of Liege, 4 | * Belgium 5 | * 6 | * This program is free software: you can redistribute it and/or 7 | * modify it under the terms of the GNU General Public License as 8 | * published by the Free Software Foundation, either version 3 of the 9 | * License, or (at your option) any later version. 10 | * 11 | * In addition, as a special exception, the copyright holders of this 12 | * program give permission to link the code of its release with the 13 | * OpenSSL project's "OpenSSL" library (or with modified versions of it 14 | * that use the same license as the "OpenSSL" library), and distribute 15 | * the linked executables. You must obey the GNU General Public License 16 | * in all respects for all of the code used other than "OpenSSL". If you 17 | * modify file(s) with this exception, you may extend this exception to 18 | * your version of the file(s), but you are not obligated to do so. If 19 | * you do not wish to do so, delete this exception statement from your 20 | * version. If you delete this exception statement from all source files 21 | * in the program, then also delete it here. 22 | * 23 | * This program is distributed in the hope that it will be useful, but 24 | * WITHOUT ANY WARRANTY; without even the implied warranty of 25 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 26 | * General Public License for more details. 27 | * 28 | * You should have received a copy of the GNU General Public License 29 | * along with this program. If not, see . 30 | **/ 31 | 32 | 33 | #pragma once 34 | 35 | #include "../Toolbox.h" 36 | #include 37 | 38 | namespace Orthanc 39 | { 40 | class RestApiPath 41 | { 42 | private: 43 | UriComponents uri_; 44 | bool hasTrailing_; 45 | std::vector components_; 46 | 47 | public: 48 | typedef std::map Components; 49 | 50 | RestApiPath(const std::string& uri); 51 | 52 | // This version is slower 53 | bool Match(Components& components, 54 | UriComponents& trailing, 55 | const std::string& uriRaw) const; 56 | 57 | bool Match(Components& components, 58 | UriComponents& trailing, 59 | const UriComponents& uri) const; 60 | 61 | bool Match(const UriComponents& uri) const; 62 | }; 63 | } 64 | -------------------------------------------------------------------------------- /Core/SQLite/IScalarFunction.h: -------------------------------------------------------------------------------- 1 | /** 2 | * Orthanc - A Lightweight, RESTful DICOM Store 3 | * Copyright (C) 2012-2013 Medical Physics Department, CHU of Liege, 4 | * Belgium 5 | * 6 | * Redistribution and use in source and binary forms, with or without 7 | * modification, are permitted provided that the following conditions are 8 | * met: 9 | * 10 | * * Redistributions of source code must retain the above copyright 11 | * notice, this list of conditions and the following disclaimer. 12 | * * Redistributions in binary form must reproduce the above 13 | * copyright notice, this list of conditions and the following disclaimer 14 | * in the documentation and/or other materials provided with the 15 | * distribution. 16 | * * Neither the name of the CHU of Liege, nor the names of its 17 | * contributors may be used to endorse or promote products derived 18 | * from this software without specific prior written permission. 19 | * 20 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 21 | * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 22 | * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 23 | * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 24 | * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 25 | * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 26 | * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 27 | * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 28 | * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 29 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 30 | * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 31 | **/ 32 | 33 | 34 | #pragma once 35 | 36 | #include "FunctionContext.h" 37 | 38 | namespace Orthanc 39 | { 40 | namespace SQLite 41 | { 42 | class IScalarFunction : public boost::noncopyable 43 | { 44 | public: 45 | virtual ~IScalarFunction() 46 | { 47 | } 48 | 49 | virtual const char* GetName() const = 0; 50 | 51 | virtual unsigned int GetCardinality() const = 0; 52 | 53 | virtual void Compute(FunctionContext& context) = 0; 54 | }; 55 | } 56 | } 57 | -------------------------------------------------------------------------------- /Core/SQLite/README.txt: -------------------------------------------------------------------------------- 1 | Introduction 2 | ============ 3 | 4 | The code in this folder is a standalone object-oriented wrapper around 5 | SQLite3. It is derived from the code of Chromium: 6 | 7 | http://src.chromium.org/viewvc/chrome/trunk/src/sql/ 8 | http://maxradi.us/documents/sqlite/ 9 | 10 | 11 | Main differences with Chromium 12 | ============================== 13 | 14 | * The reference counting mechanism has been reimplemented to make it 15 | simpler. 16 | * The OrthancException class is used for the exception mechanisms. 17 | * A statement is always valid (is_valid() always return true). 18 | * The classes and the methods have been renamed to meet Orthanc's 19 | coding conventions. 20 | 21 | 22 | Licensing 23 | ========= 24 | 25 | The code in this folder is licensed under the 3-clause BSD license, in 26 | order to respect the original license of the code. 27 | 28 | It is pretty straightforward to extract the code from this folder and 29 | to include it in another project. 30 | -------------------------------------------------------------------------------- /Core/SQLite/StatementId.cpp: -------------------------------------------------------------------------------- 1 | /** 2 | * Orthanc - A Lightweight, RESTful DICOM Store 3 | * Copyright (C) 2012-2013 Medical Physics Department, CHU of Liege, 4 | * Belgium 5 | * 6 | * Copyright (c) 2012 The Chromium Authors. All rights reserved. 7 | * 8 | * Redistribution and use in source and binary forms, with or without 9 | * modification, are permitted provided that the following conditions are 10 | * met: 11 | * 12 | * * Redistributions of source code must retain the above copyright 13 | * notice, this list of conditions and the following disclaimer. 14 | * * Redistributions in binary form must reproduce the above 15 | * copyright notice, this list of conditions and the following disclaimer 16 | * in the documentation and/or other materials provided with the 17 | * distribution. 18 | * * Neither the name of Google Inc., the name of the CHU of Liege, 19 | * nor the names of its contributors may be used to endorse or promote 20 | * products derived from this software without specific prior written 21 | * permission. 22 | * 23 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 24 | * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 25 | * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 26 | * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 27 | * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 28 | * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 29 | * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 30 | * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 31 | * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 32 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 33 | * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 34 | **/ 35 | 36 | 37 | #include "StatementId.h" 38 | 39 | #include 40 | 41 | namespace Orthanc 42 | { 43 | namespace SQLite 44 | { 45 | bool StatementId::operator< (const StatementId& other) const 46 | { 47 | if (line_ != other.line_) 48 | return line_ < other.line_; 49 | 50 | return strcmp(file_, other.file_) < 0; 51 | } 52 | } 53 | } 54 | -------------------------------------------------------------------------------- /Core/SQLite/StatementId.h: -------------------------------------------------------------------------------- 1 | /** 2 | * Orthanc - A Lightweight, RESTful DICOM Store 3 | * Copyright (C) 2012-2013 Medical Physics Department, CHU of Liege, 4 | * Belgium 5 | * 6 | * Copyright (c) 2012 The Chromium Authors. All rights reserved. 7 | * 8 | * Redistribution and use in source and binary forms, with or without 9 | * modification, are permitted provided that the following conditions are 10 | * met: 11 | * 12 | * * Redistributions of source code must retain the above copyright 13 | * notice, this list of conditions and the following disclaimer. 14 | * * Redistributions in binary form must reproduce the above 15 | * copyright notice, this list of conditions and the following disclaimer 16 | * in the documentation and/or other materials provided with the 17 | * distribution. 18 | * * Neither the name of Google Inc., the name of the CHU of Liege, 19 | * nor the names of its contributors may be used to endorse or promote 20 | * products derived from this software without specific prior written 21 | * permission. 22 | * 23 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 24 | * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 25 | * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 26 | * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 27 | * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 28 | * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 29 | * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 30 | * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 31 | * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 32 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 33 | * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 34 | **/ 35 | 36 | 37 | #pragma once 38 | 39 | namespace Orthanc 40 | { 41 | namespace SQLite 42 | { 43 | class StatementId 44 | { 45 | private: 46 | const char* file_; 47 | int line_; 48 | 49 | StatementId(); // Forbidden 50 | 51 | public: 52 | StatementId(const char* file, int line) : file_(file), line_(line) 53 | { 54 | } 55 | 56 | bool operator< (const StatementId& other) const; 57 | }; 58 | } 59 | } 60 | -------------------------------------------------------------------------------- /Core/SQLite/StatementReference.h: -------------------------------------------------------------------------------- 1 | /** 2 | * Orthanc - A Lightweight, RESTful DICOM Store 3 | * Copyright (C) 2012-2013 Medical Physics Department, CHU of Liege, 4 | * Belgium 5 | * 6 | * Copyright (c) 2012 The Chromium Authors. All rights reserved. 7 | * 8 | * Redistribution and use in source and binary forms, with or without 9 | * modification, are permitted provided that the following conditions are 10 | * met: 11 | * 12 | * * Redistributions of source code must retain the above copyright 13 | * notice, this list of conditions and the following disclaimer. 14 | * * Redistributions in binary form must reproduce the above 15 | * copyright notice, this list of conditions and the following disclaimer 16 | * in the documentation and/or other materials provided with the 17 | * distribution. 18 | * * Neither the name of Google Inc., the name of the CHU of Liege, 19 | * nor the names of its contributors may be used to endorse or promote 20 | * products derived from this software without specific prior written 21 | * permission. 22 | * 23 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 24 | * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 25 | * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 26 | * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 27 | * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 28 | * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 29 | * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 30 | * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 31 | * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 32 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 33 | * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 34 | **/ 35 | 36 | 37 | #pragma once 38 | 39 | #include 40 | #include 41 | #include 42 | #include 43 | 44 | struct sqlite3; 45 | struct sqlite3_stmt; 46 | 47 | namespace Orthanc 48 | { 49 | namespace SQLite 50 | { 51 | class StatementReference : boost::noncopyable 52 | { 53 | private: 54 | StatementReference* root_; // Only used for non-root nodes 55 | uint32_t refCount_; // Only used for root node 56 | struct sqlite3_stmt* statement_; 57 | 58 | bool IsRoot() const; 59 | 60 | public: 61 | StatementReference(); 62 | 63 | StatementReference(sqlite3* database, 64 | const char* sql); 65 | 66 | StatementReference(StatementReference& other); 67 | 68 | ~StatementReference(); 69 | 70 | uint32_t GetReferenceCount() const; 71 | 72 | struct sqlite3_stmt* GetWrappedObject() const 73 | { 74 | assert(statement_ != NULL); 75 | return statement_; 76 | } 77 | }; 78 | } 79 | } 80 | -------------------------------------------------------------------------------- /Core/Uuid.h: -------------------------------------------------------------------------------- 1 | /** 2 | * Orthanc - A Lightweight, RESTful DICOM Store 3 | * Copyright (C) 2012-2013 Medical Physics Department, CHU of Liege, 4 | * Belgium 5 | * 6 | * This program is free software: you can redistribute it and/or 7 | * modify it under the terms of the GNU General Public License as 8 | * published by the Free Software Foundation, either version 3 of the 9 | * License, or (at your option) any later version. 10 | * 11 | * In addition, as a special exception, the copyright holders of this 12 | * program give permission to link the code of its release with the 13 | * OpenSSL project's "OpenSSL" library (or with modified versions of it 14 | * that use the same license as the "OpenSSL" library), and distribute 15 | * the linked executables. You must obey the GNU General Public License 16 | * in all respects for all of the code used other than "OpenSSL". If you 17 | * modify file(s) with this exception, you may extend this exception to 18 | * your version of the file(s), but you are not obligated to do so. If 19 | * you do not wish to do so, delete this exception statement from your 20 | * version. If you delete this exception statement from all source files 21 | * in the program, then also delete it here. 22 | * 23 | * This program is distributed in the hope that it will be useful, but 24 | * WITHOUT ANY WARRANTY; without even the implied warranty of 25 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 26 | * General Public License for more details. 27 | * 28 | * You should have received a copy of the GNU General Public License 29 | * along with this program. If not, see . 30 | **/ 31 | 32 | 33 | #pragma once 34 | 35 | #include 36 | 37 | /** 38 | * GUID vs. UUID 39 | * The simple answer is: no difference, they are the same thing. Treat 40 | * them as a 16 byte (128 bits) value that is used as a unique 41 | * value. In Microsoft-speak they are called GUIDs, but call them 42 | * UUIDs when not using Microsoft-speak. 43 | * http://stackoverflow.com/questions/246930/is-there-any-difference-between-a-guid-and-a-uuid 44 | **/ 45 | 46 | namespace Orthanc 47 | { 48 | namespace Toolbox 49 | { 50 | std::string GenerateUuid(); 51 | 52 | bool IsUuid(const std::string& str); 53 | 54 | bool StartsWithUuid(const std::string& str); 55 | 56 | class TemporaryFile 57 | { 58 | private: 59 | std::string path_; 60 | 61 | public: 62 | TemporaryFile(); 63 | 64 | TemporaryFile(const char* extension); 65 | 66 | ~TemporaryFile(); 67 | 68 | const std::string& GetPath() const 69 | { 70 | return path_; 71 | } 72 | }; 73 | } 74 | } 75 | -------------------------------------------------------------------------------- /OrthancCppClient/Study.cpp: -------------------------------------------------------------------------------- 1 | /** 2 | * Orthanc - A Lightweight, RESTful DICOM Store 3 | * Copyright (C) 2012-2013 Medical Physics Department, CHU of Liege, 4 | * Belgium 5 | * 6 | * This program is free software: you can redistribute it and/or 7 | * modify it under the terms of the GNU General Public License as 8 | * published by the Free Software Foundation, either version 3 of the 9 | * License, or (at your option) any later version. 10 | * 11 | * In addition, as a special exception, the copyright holders of this 12 | * program give permission to link the code of its release with the 13 | * OpenSSL project's "OpenSSL" library (or with modified versions of it 14 | * that use the same license as the "OpenSSL" library), and distribute 15 | * the linked executables. You must obey the GNU General Public License 16 | * in all respects for all of the code used other than "OpenSSL". If you 17 | * modify file(s) with this exception, you may extend this exception to 18 | * your version of the file(s), but you are not obligated to do so. If 19 | * you do not wish to do so, delete this exception statement from your 20 | * version. If you delete this exception statement from all source files 21 | * in the program, then also delete it here. 22 | * 23 | * This program is distributed in the hope that it will be useful, but 24 | * WITHOUT ANY WARRANTY; without even the implied warranty of 25 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 26 | * General Public License for more details. 27 | * 28 | * You should have received a copy of the GNU General Public License 29 | * along with this program. If not, see . 30 | **/ 31 | 32 | 33 | #include "Study.h" 34 | 35 | #include "OrthancConnection.h" 36 | #include "../Core/OrthancException.h" 37 | 38 | namespace OrthancClient 39 | { 40 | void Study::ReadStudy() 41 | { 42 | Orthanc::HttpClient client(connection_.GetHttpClient()); 43 | client.SetUrl(connection_.GetOrthancUrl() + "/studies/" + id_); 44 | Json::Value v; 45 | if (!client.Apply(study_)) 46 | { 47 | throw Orthanc::OrthancException(Orthanc::ErrorCode_NetworkProtocol); 48 | } 49 | } 50 | 51 | Orthanc::IDynamicObject* Study::GetFillerItem(size_t index) 52 | { 53 | return new Series(connection_, study_["Series"][index].asString()); 54 | } 55 | 56 | Study::Study(const OrthancConnection& connection, 57 | const std::string& id) : 58 | connection_(connection), 59 | id_(id), 60 | series_(*this) 61 | { 62 | series_.SetThreadCount(connection.GetThreadCount()); 63 | ReadStudy(); 64 | } 65 | 66 | std::string Study::GetMainDicomTag(const char* tag, const char* defaultValue) const 67 | { 68 | if (study_["MainDicomTags"].isMember(tag)) 69 | { 70 | return study_["MainDicomTags"][tag].asString(); 71 | } 72 | else 73 | { 74 | return defaultValue; 75 | } 76 | } 77 | } 78 | -------------------------------------------------------------------------------- /OrthancCppClient/Study.h: -------------------------------------------------------------------------------- 1 | /** 2 | * Orthanc - A Lightweight, RESTful DICOM Store 3 | * Copyright (C) 2012-2013 Medical Physics Department, CHU of Liege, 4 | * Belgium 5 | * 6 | * This program is free software: you can redistribute it and/or 7 | * modify it under the terms of the GNU General Public License as 8 | * published by the Free Software Foundation, either version 3 of the 9 | * License, or (at your option) any later version. 10 | * 11 | * In addition, as a special exception, the copyright holders of this 12 | * program give permission to link the code of its release with the 13 | * OpenSSL project's "OpenSSL" library (or with modified versions of it 14 | * that use the same license as the "OpenSSL" library), and distribute 15 | * the linked executables. You must obey the GNU General Public License 16 | * in all respects for all of the code used other than "OpenSSL". If you 17 | * modify file(s) with this exception, you may extend this exception to 18 | * your version of the file(s), but you are not obligated to do so. If 19 | * you do not wish to do so, delete this exception statement from your 20 | * version. If you delete this exception statement from all source files 21 | * in the program, then also delete it here. 22 | * 23 | * This program is distributed in the hope that it will be useful, but 24 | * WITHOUT ANY WARRANTY; without even the implied warranty of 25 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 26 | * General Public License for more details. 27 | * 28 | * You should have received a copy of the GNU General Public License 29 | * along with this program. If not, see . 30 | **/ 31 | 32 | 33 | #pragma once 34 | 35 | #include "Series.h" 36 | 37 | namespace OrthancClient 38 | { 39 | class Study : 40 | public Orthanc::IDynamicObject, 41 | private Orthanc::ArrayFilledByThreads::IFiller 42 | { 43 | private: 44 | const OrthancConnection& connection_; 45 | std::string id_; 46 | Json::Value study_; 47 | Orthanc::ArrayFilledByThreads series_; 48 | 49 | void ReadStudy(); 50 | 51 | virtual size_t GetFillerSize() 52 | { 53 | return study_["Series"].size(); 54 | } 55 | 56 | virtual Orthanc::IDynamicObject* GetFillerItem(size_t index); 57 | 58 | public: 59 | Study(const OrthancConnection& connection, 60 | const std::string& id); 61 | 62 | void Reload() 63 | { 64 | series_.Reload(); 65 | } 66 | 67 | unsigned int GetSeriesCount() 68 | { 69 | return series_.GetSize(); 70 | } 71 | 72 | Series& GetSeries(unsigned int index) 73 | { 74 | return dynamic_cast(series_.GetItem(index)); 75 | } 76 | 77 | const std::string& GetId() const 78 | { 79 | return id_; 80 | } 81 | 82 | std::string GetMainDicomTag(const char* tag, 83 | const char* defaultValue) const; 84 | }; 85 | } 86 | -------------------------------------------------------------------------------- /OrthancExplorer/explorer.css: -------------------------------------------------------------------------------- 1 | ul.tree ul { 2 | margin-left: 36px; 3 | } 4 | 5 | #progress { 6 | position: relative; 7 | /*height: 2em; */ 8 | width: 100%; 9 | background-color: grey; 10 | height: 2.5em; 11 | } 12 | 13 | #progress .label { 14 | z-index: 10; 15 | position: absolute; 16 | left:0; 17 | top: 0; 18 | width: 100%; 19 | font-weight: bold; 20 | text-align: center; 21 | text-shadow: none; 22 | padding: .5em; 23 | color: white; 24 | } 25 | 26 | #progress .bar { 27 | z-index: 0; 28 | position: absolute; 29 | left:0; 30 | top: 0; 31 | height: 100%; 32 | width: 0%; 33 | background-color: green; 34 | } 35 | 36 | .ui-title a { 37 | text-decoration: none; 38 | color: white !important; 39 | } 40 | 41 | .switch-container .ui-slider-switch { 42 | width: 100%; 43 | } -------------------------------------------------------------------------------- /OrthancExplorer/file-upload.js: -------------------------------------------------------------------------------- 1 | var pendingUploads = []; 2 | var currentUpload = 0; 3 | var totalUpload = 0; 4 | 5 | $(document).ready(function() { 6 | // Initialize the jQuery File Upload widget: 7 | $('#fileupload').fileupload({ 8 | //dataType: 'json', 9 | //maxChunkSize: 500, 10 | //sequentialUploads: true, 11 | limitConcurrentUploads: 3, 12 | add: function (e, data) { 13 | pendingUploads.push(data); 14 | } 15 | }) 16 | .bind('fileuploadstop', function(e, data) { 17 | $('#upload-button').removeClass('ui-disabled'); 18 | //$('#upload-abort').addClass('ui-disabled'); 19 | $('#progress .bar').css('width', '100%'); 20 | if ($('#progress .label').text() != 'Failure') 21 | $('#progress .label').text('Done'); 22 | }) 23 | .bind('fileuploadfail', function(e, data) { 24 | $('#progress .bar') 25 | .css('width', '100%') 26 | .css('background-color', 'red'); 27 | $('#progress .label').text('Failure'); 28 | }) 29 | .bind('fileuploaddrop', function (e, data) { 30 | var target = $('#upload-list'); 31 | $.each(data.files, function (index, file) { 32 | target.append('
  • ' + file.name + '
  • '); 33 | }); 34 | target.listview('refresh'); 35 | }) 36 | .bind('fileuploadsend', function (e, data) { 37 | // Update the progress bar. Note: for some weird reason, the 38 | // "fileuploadprogressall" does not work under Firefox. 39 | var progress = parseInt(currentUpload / totalUploads * 100, 10); 40 | currentUpload += 1; 41 | $('#progress .label').text('Uploading: ' + progress + '%'); 42 | $('#progress .bar') 43 | .css('width', progress + '%') 44 | .css('background-color', 'green'); 45 | }); 46 | }); 47 | 48 | 49 | 50 | $('#upload').live('pageshow', function() { 51 | $('#fileupload').fileupload('enable'); 52 | }); 53 | 54 | $('#upload').live('pagehide', function() { 55 | $('#fileupload').fileupload('disable'); 56 | }); 57 | 58 | 59 | $('#upload-button').live('click', function() { 60 | var pu = pendingUploads; 61 | pendingUploads = []; 62 | 63 | $('.pending-file').remove(); 64 | $('#upload-list').listview('refresh'); 65 | $('#progress .bar').css('width', '0%'); 66 | $('#progress .label').text(''); 67 | 68 | currentUpload = 1; 69 | totalUploads = pu.length + 1; 70 | if (pu.length > 0) { 71 | $('#upload-button').addClass('ui-disabled'); 72 | //$('#upload-abort').removeClass('ui-disabled'); 73 | } 74 | 75 | for (var i = 0; i < pu.length; i++) { 76 | pu[i].submit(); 77 | } 78 | }); 79 | 80 | $('#upload-clear').live('click', function() { 81 | pendingUploads = []; 82 | $('.pending-file').remove(); 83 | $('#upload-list').listview('refresh'); 84 | }); 85 | 86 | /*$('#upload-abort').live('click', function() { 87 | $('#fileupload').fileupload().abort(); 88 | });*/ 89 | -------------------------------------------------------------------------------- /OrthancExplorer/images/unsupported.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/amirkogithub/orthanc/a49a40f82813a2330390712318cf0610b9777b42/OrthancExplorer/images/unsupported.png -------------------------------------------------------------------------------- /OrthancExplorer/libs/images/ajax-loader.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/amirkogithub/orthanc/a49a40f82813a2330390712318cf0610b9777b42/OrthancExplorer/libs/images/ajax-loader.gif -------------------------------------------------------------------------------- /OrthancExplorer/libs/images/ajax-loader.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/amirkogithub/orthanc/a49a40f82813a2330390712318cf0610b9777b42/OrthancExplorer/libs/images/ajax-loader.png -------------------------------------------------------------------------------- /OrthancExplorer/libs/images/ajax-loader2.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/amirkogithub/orthanc/a49a40f82813a2330390712318cf0610b9777b42/OrthancExplorer/libs/images/ajax-loader2.gif -------------------------------------------------------------------------------- /OrthancExplorer/libs/images/icons-18-black.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/amirkogithub/orthanc/a49a40f82813a2330390712318cf0610b9777b42/OrthancExplorer/libs/images/icons-18-black.png -------------------------------------------------------------------------------- /OrthancExplorer/libs/images/icons-18-white.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/amirkogithub/orthanc/a49a40f82813a2330390712318cf0610b9777b42/OrthancExplorer/libs/images/icons-18-white.png -------------------------------------------------------------------------------- /OrthancExplorer/libs/images/icons-36-black.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/amirkogithub/orthanc/a49a40f82813a2330390712318cf0610b9777b42/OrthancExplorer/libs/images/icons-36-black.png -------------------------------------------------------------------------------- /OrthancExplorer/libs/images/icons-36-white.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/amirkogithub/orthanc/a49a40f82813a2330390712318cf0610b9777b42/OrthancExplorer/libs/images/icons-36-white.png -------------------------------------------------------------------------------- /OrthancExplorer/libs/jqtree-icons.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/amirkogithub/orthanc/a49a40f82813a2330390712318cf0610b9777b42/OrthancExplorer/libs/jqtree-icons.png -------------------------------------------------------------------------------- /OrthancExplorer/libs/jquery-file-upload/css/jquery.fileupload-ui.css: -------------------------------------------------------------------------------- 1 | @charset 'UTF-8'; 2 | /* 3 | * jQuery File Upload UI Plugin CSS 6.3 4 | * https://github.com/blueimp/jQuery-File-Upload 5 | * 6 | * Copyright 2010, Sebastian Tschan 7 | * https://blueimp.net 8 | * 9 | * Licensed under the MIT license: 10 | * http://www.opensource.org/licenses/MIT 11 | */ 12 | 13 | .fileinput-button { 14 | position: relative; 15 | overflow: hidden; 16 | float: left; 17 | margin-right: 4px; 18 | } 19 | .fileinput-button input { 20 | position: absolute; 21 | top: 0; 22 | right: 0; 23 | margin: 0; 24 | border: solid transparent; 25 | border-width: 0 0 100px 200px; 26 | opacity: 0; 27 | filter: alpha(opacity=0); 28 | -moz-transform: translate(-300px, 0) scale(4); 29 | direction: ltr; 30 | cursor: pointer; 31 | } 32 | .fileupload-buttonbar .btn, 33 | .fileupload-buttonbar .toggle { 34 | margin-bottom: 5px; 35 | } 36 | .files .progress { 37 | width: 200px; 38 | } 39 | .progress-animated .bar { 40 | background: url(../img/progressbar.gif) !important; 41 | filter: none; 42 | } 43 | .fileupload-loading { 44 | position: absolute; 45 | left: 50%; 46 | width: 128px; 47 | height: 128px; 48 | background: url(../img/loading.gif) center no-repeat; 49 | display: none; 50 | } 51 | .fileupload-processing .fileupload-loading { 52 | display: block; 53 | } 54 | 55 | /* Fix for IE 6: */ 56 | *html .fileinput-button { 57 | line-height: 22px; 58 | margin: 1px -3px 0 0; 59 | } 60 | 61 | /* Fix for IE 7: */ 62 | *+html .fileinput-button { 63 | margin: 1px 0 0 0; 64 | } 65 | 66 | @media (max-width: 480px) { 67 | .files .btn span { 68 | display: none; 69 | } 70 | .files .preview * { 71 | width: 40px; 72 | } 73 | .files .name * { 74 | width: 80px; 75 | display: inline-block; 76 | word-wrap: break-word; 77 | } 78 | .files .progress { 79 | width: 20px; 80 | } 81 | .files .delete { 82 | width: 60px; 83 | } 84 | } 85 | -------------------------------------------------------------------------------- /OrthancExplorer/libs/jquery-file-upload/css/style.css: -------------------------------------------------------------------------------- 1 | @charset 'UTF-8'; 2 | /* 3 | * jQuery File Upload Plugin CSS Example 1.0 4 | * https://github.com/blueimp/jQuery-File-Upload 5 | * 6 | * Copyright 2012, Sebastian Tschan 7 | * https://blueimp.net 8 | * 9 | * Licensed under the MIT license: 10 | * http://www.opensource.org/licenses/MIT 11 | */ 12 | 13 | body{ 14 | padding-top: 60px; 15 | } 16 | -------------------------------------------------------------------------------- /OrthancExplorer/libs/jquery-file-upload/img/loading.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/amirkogithub/orthanc/a49a40f82813a2330390712318cf0610b9777b42/OrthancExplorer/libs/jquery-file-upload/img/loading.gif -------------------------------------------------------------------------------- /OrthancExplorer/libs/jquery-file-upload/img/progressbar.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/amirkogithub/orthanc/a49a40f82813a2330390712318cf0610b9777b42/OrthancExplorer/libs/jquery-file-upload/img/progressbar.gif -------------------------------------------------------------------------------- /OrthancExplorer/libs/jquery-file-upload/js/locale.js: -------------------------------------------------------------------------------- 1 | /* 2 | * jQuery File Upload Plugin Localization Example 6.5.1 3 | * https://github.com/blueimp/jQuery-File-Upload 4 | * 5 | * Copyright 2012, Sebastian Tschan 6 | * https://blueimp.net 7 | * 8 | * Licensed under the MIT license: 9 | * http://www.opensource.org/licenses/MIT 10 | */ 11 | 12 | /*global window */ 13 | 14 | window.locale = { 15 | "fileupload": { 16 | "errors": { 17 | "maxFileSize": "File is too big", 18 | "minFileSize": "File is too small", 19 | "acceptFileTypes": "Filetype not allowed", 20 | "maxNumberOfFiles": "Max number of files exceeded", 21 | "uploadedBytes": "Uploaded bytes exceed file size", 22 | "emptyResult": "Empty file upload result" 23 | }, 24 | "error": "Error", 25 | "start": "Start", 26 | "cancel": "Cancel", 27 | "destroy": "Delete" 28 | } 29 | }; 30 | -------------------------------------------------------------------------------- /OrthancExplorer/libs/jquery.mobile.simpledialog.min.css: -------------------------------------------------------------------------------- 1 | /* 2 | * jQuery Mobile Framework : plugin to provide a simple Dialog widget. 3 | * Copyright (c) JTSage 4 | * CC 3.0 Attribution. May be relicensed without permission/notifcation. 5 | * https://github.com/jtsage/jquery-mobile-simpledialog 6 | */ 7 | 8 | .ui-simpledialog-header h4{margin-top:5px;margin-bottom:5px;text-align:center}.ui-simpledialog-container{border:5px solid #111!important;width:85%;max-width:500px}.ui-simpledialog-screen{position:absolute;top:0;left:0;width:100%;height:100%}.ui-simpledialog-hidden{display:none}.ui-simpledialog-input{width:85%!important;display:block!important;margin-left:auto;margin-right:auto}.ui-simpledialog-screen-modal{background-color:black;-moz-opacity:.8;opacity:.80;filter:alpha(opacity=80)}.ui-simpledialog-subtitle{text-align:center}.ui-simpledialog-controls .buttons-separator{min-height:.6em}.ui-simpledialog-controls .button-hidden{display:none}.ui-dialog .ui-simpledialog-container{border:none!important}.ui-dialog-simpledialog .ui-content{padding:5px!important} -------------------------------------------------------------------------------- /OrthancExplorer/libs/slimbox2/closelabel.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/amirkogithub/orthanc/a49a40f82813a2330390712318cf0610b9777b42/OrthancExplorer/libs/slimbox2/closelabel.gif -------------------------------------------------------------------------------- /OrthancExplorer/libs/slimbox2/loading.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/amirkogithub/orthanc/a49a40f82813a2330390712318cf0610b9777b42/OrthancExplorer/libs/slimbox2/loading.gif -------------------------------------------------------------------------------- /OrthancExplorer/libs/slimbox2/nextlabel.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/amirkogithub/orthanc/a49a40f82813a2330390712318cf0610b9777b42/OrthancExplorer/libs/slimbox2/nextlabel.gif -------------------------------------------------------------------------------- /OrthancExplorer/libs/slimbox2/prevlabel.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/amirkogithub/orthanc/a49a40f82813a2330390712318cf0610b9777b42/OrthancExplorer/libs/slimbox2/prevlabel.gif -------------------------------------------------------------------------------- /OrthancExplorer/libs/slimbox2/slimbox2-rtl.css: -------------------------------------------------------------------------------- 1 | /* SLIMBOX */ 2 | 3 | #lbOverlay { 4 | position: fixed; 5 | z-index: 9999; 6 | left: 0; 7 | top: 0; 8 | width: 100%; 9 | height: 100%; 10 | background-color: #000; 11 | cursor: pointer; 12 | } 13 | 14 | #lbCenter, #lbBottomContainer { 15 | position: absolute; 16 | z-index: 9999; 17 | overflow: hidden; 18 | background-color: #fff; 19 | } 20 | 21 | .lbLoading { 22 | background: #fff url(loading.gif) no-repeat center; 23 | } 24 | 25 | #lbImage { 26 | position: absolute; 27 | left: 0; 28 | top: 0; 29 | border: 10px solid #fff; 30 | background-repeat: no-repeat; 31 | } 32 | 33 | #lbPrevLink, #lbNextLink { 34 | display: block; 35 | position: absolute; 36 | top: 0; 37 | width: 50%; 38 | outline: none; 39 | } 40 | 41 | #lbPrevLink { 42 | right: 0; 43 | } 44 | 45 | #lbPrevLink:hover { 46 | background: transparent url(prevlabel.gif) no-repeat 100% 15%; 47 | } 48 | 49 | #lbNextLink { 50 | left: 0; 51 | } 52 | 53 | #lbNextLink:hover { 54 | background: transparent url(nextlabel.gif) no-repeat 0 15%; 55 | } 56 | 57 | #lbBottom { 58 | font-family: Verdana, Arial, Geneva, Helvetica, sans-serif; 59 | font-size: 10px; 60 | color: #666; 61 | line-height: 1.4em; 62 | text-align: right; 63 | border: 10px solid #fff; 64 | border-top-style: none; 65 | direction: rtl; 66 | } 67 | 68 | #lbCloseLink { 69 | display: block; 70 | float: left; 71 | width: 66px; 72 | height: 22px; 73 | background: transparent url(closelabel.gif) no-repeat center; 74 | margin: 5px 0; 75 | outline: none; 76 | } 77 | 78 | #lbCaption, #lbNumber { 79 | margin-left: 71px; 80 | } 81 | 82 | #lbCaption { 83 | font-weight: bold; 84 | } 85 | -------------------------------------------------------------------------------- /OrthancExplorer/libs/slimbox2/slimbox2.css: -------------------------------------------------------------------------------- 1 | /* SLIMBOX */ 2 | 3 | #lbOverlay { 4 | position: fixed; 5 | z-index: 9999; 6 | left: 0; 7 | top: 0; 8 | width: 100%; 9 | height: 100%; 10 | background-color: #000; 11 | cursor: pointer; 12 | } 13 | 14 | #lbCenter, #lbBottomContainer { 15 | position: absolute; 16 | z-index: 9999; 17 | overflow: hidden; 18 | background-color: #fff; 19 | } 20 | 21 | .lbLoading { 22 | background: #fff url(loading.gif) no-repeat center; 23 | } 24 | 25 | #lbImage { 26 | position: absolute; 27 | left: 0; 28 | top: 0; 29 | border: 10px solid #fff; 30 | background-repeat: no-repeat; 31 | } 32 | 33 | #lbPrevLink, #lbNextLink { 34 | display: block; 35 | position: absolute; 36 | top: 0; 37 | width: 50%; 38 | outline: none; 39 | } 40 | 41 | #lbPrevLink { 42 | left: 0; 43 | } 44 | 45 | #lbPrevLink:hover { 46 | background: transparent url(prevlabel.gif) no-repeat 0 15%; 47 | } 48 | 49 | #lbNextLink { 50 | right: 0; 51 | } 52 | 53 | #lbNextLink:hover { 54 | background: transparent url(nextlabel.gif) no-repeat 100% 15%; 55 | } 56 | 57 | #lbBottom { 58 | font-family: Verdana, Arial, Geneva, Helvetica, sans-serif; 59 | font-size: 10px; 60 | color: #666; 61 | line-height: 1.4em; 62 | text-align: left; 63 | border: 10px solid #fff; 64 | border-top-style: none; 65 | } 66 | 67 | #lbCloseLink { 68 | display: block; 69 | float: right; 70 | width: 66px; 71 | height: 22px; 72 | background: transparent url(closelabel.gif) no-repeat center; 73 | margin: 5px 0; 74 | outline: none; 75 | } 76 | 77 | #lbCaption, #lbNumber { 78 | margin-right: 71px; 79 | } 80 | 81 | #lbCaption { 82 | font-weight: bold; 83 | } 84 | -------------------------------------------------------------------------------- /OrthancServer/DicomProtocol/DicomFindAnswers.cpp: -------------------------------------------------------------------------------- 1 | /** 2 | * Orthanc - A Lightweight, RESTful DICOM Store 3 | * Copyright (C) 2012-2013 Medical Physics Department, CHU of Liege, 4 | * Belgium 5 | * 6 | * This program is free software: you can redistribute it and/or 7 | * modify it under the terms of the GNU General Public License as 8 | * published by the Free Software Foundation, either version 3 of the 9 | * License, or (at your option) any later version. 10 | * 11 | * In addition, as a special exception, the copyright holders of this 12 | * program give permission to link the code of its release with the 13 | * OpenSSL project's "OpenSSL" library (or with modified versions of it 14 | * that use the same license as the "OpenSSL" library), and distribute 15 | * the linked executables. You must obey the GNU General Public License 16 | * in all respects for all of the code used other than "OpenSSL". If you 17 | * modify file(s) with this exception, you may extend this exception to 18 | * your version of the file(s), but you are not obligated to do so. If 19 | * you do not wish to do so, delete this exception statement from your 20 | * version. If you delete this exception statement from all source files 21 | * in the program, then also delete it here. 22 | * 23 | * This program is distributed in the hope that it will be useful, but 24 | * WITHOUT ANY WARRANTY; without even the implied warranty of 25 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 26 | * General Public License for more details. 27 | * 28 | * You should have received a copy of the GNU General Public License 29 | * along with this program. If not, see . 30 | **/ 31 | 32 | 33 | #include "DicomFindAnswers.h" 34 | 35 | #include "../FromDcmtkBridge.h" 36 | 37 | namespace Orthanc 38 | { 39 | void DicomFindAnswers::Clear() 40 | { 41 | for (size_t i = 0; i < items_.size(); i++) 42 | { 43 | delete items_[i]; 44 | } 45 | } 46 | 47 | void DicomFindAnswers::Reserve(size_t size) 48 | { 49 | if (size > items_.size()) 50 | { 51 | items_.reserve(size); 52 | } 53 | } 54 | 55 | void DicomFindAnswers::ToJson(Json::Value& target) const 56 | { 57 | target = Json::arrayValue; 58 | 59 | for (size_t i = 0; i < GetSize(); i++) 60 | { 61 | Json::Value answer(Json::objectValue); 62 | FromDcmtkBridge::ToJson(answer, GetAnswer(i)); 63 | target.append(answer); 64 | } 65 | } 66 | } 67 | -------------------------------------------------------------------------------- /OrthancServer/DicomProtocol/DicomFindAnswers.h: -------------------------------------------------------------------------------- 1 | /** 2 | * Orthanc - A Lightweight, RESTful DICOM Store 3 | * Copyright (C) 2012-2013 Medical Physics Department, CHU of Liege, 4 | * Belgium 5 | * 6 | * This program is free software: you can redistribute it and/or 7 | * modify it under the terms of the GNU General Public License as 8 | * published by the Free Software Foundation, either version 3 of the 9 | * License, or (at your option) any later version. 10 | * 11 | * In addition, as a special exception, the copyright holders of this 12 | * program give permission to link the code of its release with the 13 | * OpenSSL project's "OpenSSL" library (or with modified versions of it 14 | * that use the same license as the "OpenSSL" library), and distribute 15 | * the linked executables. You must obey the GNU General Public License 16 | * in all respects for all of the code used other than "OpenSSL". If you 17 | * modify file(s) with this exception, you may extend this exception to 18 | * your version of the file(s), but you are not obligated to do so. If 19 | * you do not wish to do so, delete this exception statement from your 20 | * version. If you delete this exception statement from all source files 21 | * in the program, then also delete it here. 22 | * 23 | * This program is distributed in the hope that it will be useful, but 24 | * WITHOUT ANY WARRANTY; without even the implied warranty of 25 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 26 | * General Public License for more details. 27 | * 28 | * You should have received a copy of the GNU General Public License 29 | * along with this program. If not, see . 30 | **/ 31 | 32 | 33 | #pragma once 34 | 35 | #include "../../Core/DicomFormat/DicomMap.h" 36 | 37 | #include 38 | #include 39 | 40 | namespace Orthanc 41 | { 42 | class DicomFindAnswers 43 | { 44 | private: 45 | std::vector items_; 46 | 47 | public: 48 | ~DicomFindAnswers() 49 | { 50 | Clear(); 51 | } 52 | 53 | void Clear(); 54 | 55 | void Reserve(size_t index); 56 | 57 | void Add(const DicomMap& map) 58 | { 59 | items_.push_back(map.Clone()); 60 | } 61 | 62 | size_t GetSize() const 63 | { 64 | return items_.size(); 65 | } 66 | 67 | const DicomMap& GetAnswer(size_t index) const 68 | { 69 | return *items_.at(index); 70 | } 71 | 72 | void ToJson(Json::Value& target) const; 73 | }; 74 | } 75 | -------------------------------------------------------------------------------- /OrthancServer/DicomProtocol/IApplicationEntityFilter.h: -------------------------------------------------------------------------------- 1 | /** 2 | * Orthanc - A Lightweight, RESTful DICOM Store 3 | * Copyright (C) 2012-2013 Medical Physics Department, CHU of Liege, 4 | * Belgium 5 | * 6 | * This program is free software: you can redistribute it and/or 7 | * modify it under the terms of the GNU General Public License as 8 | * published by the Free Software Foundation, either version 3 of the 9 | * License, or (at your option) any later version. 10 | * 11 | * In addition, as a special exception, the copyright holders of this 12 | * program give permission to link the code of its release with the 13 | * OpenSSL project's "OpenSSL" library (or with modified versions of it 14 | * that use the same license as the "OpenSSL" library), and distribute 15 | * the linked executables. You must obey the GNU General Public License 16 | * in all respects for all of the code used other than "OpenSSL". If you 17 | * modify file(s) with this exception, you may extend this exception to 18 | * your version of the file(s), but you are not obligated to do so. If 19 | * you do not wish to do so, delete this exception statement from your 20 | * version. If you delete this exception statement from all source files 21 | * in the program, then also delete it here. 22 | * 23 | * This program is distributed in the hope that it will be useful, but 24 | * WITHOUT ANY WARRANTY; without even the implied warranty of 25 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 26 | * General Public License for more details. 27 | * 28 | * You should have received a copy of the GNU General Public License 29 | * along with this program. If not, see . 30 | **/ 31 | 32 | 33 | #pragma once 34 | 35 | #include 36 | 37 | namespace Orthanc 38 | { 39 | class IApplicationEntityFilter 40 | { 41 | public: 42 | virtual ~IApplicationEntityFilter() 43 | { 44 | } 45 | 46 | virtual bool IsAllowed(const std::string& callingIp, 47 | const std::string& callingAet) = 0; 48 | }; 49 | } 50 | -------------------------------------------------------------------------------- /OrthancServer/DicomProtocol/IFindRequestHandler.h: -------------------------------------------------------------------------------- 1 | /** 2 | * Orthanc - A Lightweight, RESTful DICOM Store 3 | * Copyright (C) 2012-2013 Medical Physics Department, CHU of Liege, 4 | * Belgium 5 | * 6 | * This program is free software: you can redistribute it and/or 7 | * modify it under the terms of the GNU General Public License as 8 | * published by the Free Software Foundation, either version 3 of the 9 | * License, or (at your option) any later version. 10 | * 11 | * In addition, as a special exception, the copyright holders of this 12 | * program give permission to link the code of its release with the 13 | * OpenSSL project's "OpenSSL" library (or with modified versions of it 14 | * that use the same license as the "OpenSSL" library), and distribute 15 | * the linked executables. You must obey the GNU General Public License 16 | * in all respects for all of the code used other than "OpenSSL". If you 17 | * modify file(s) with this exception, you may extend this exception to 18 | * your version of the file(s), but you are not obligated to do so. If 19 | * you do not wish to do so, delete this exception statement from your 20 | * version. If you delete this exception statement from all source files 21 | * in the program, then also delete it here. 22 | * 23 | * This program is distributed in the hope that it will be useful, but 24 | * WITHOUT ANY WARRANTY; without even the implied warranty of 25 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 26 | * General Public License for more details. 27 | * 28 | * You should have received a copy of the GNU General Public License 29 | * along with this program. If not, see . 30 | **/ 31 | 32 | 33 | #pragma once 34 | 35 | #include "DicomFindAnswers.h" 36 | 37 | #include 38 | #include 39 | 40 | 41 | namespace Orthanc 42 | { 43 | class IFindRequestHandler 44 | { 45 | public: 46 | virtual ~IFindRequestHandler() 47 | { 48 | } 49 | 50 | virtual void Handle(const DicomMap& input, 51 | DicomFindAnswers& answers) = 0; 52 | }; 53 | } 54 | -------------------------------------------------------------------------------- /OrthancServer/DicomProtocol/IFindRequestHandlerFactory.h: -------------------------------------------------------------------------------- 1 | /** 2 | * Orthanc - A Lightweight, RESTful DICOM Store 3 | * Copyright (C) 2012-2013 Medical Physics Department, CHU of Liege, 4 | * Belgium 5 | * 6 | * This program is free software: you can redistribute it and/or 7 | * modify it under the terms of the GNU General Public License as 8 | * published by the Free Software Foundation, either version 3 of the 9 | * License, or (at your option) any later version. 10 | * 11 | * In addition, as a special exception, the copyright holders of this 12 | * program give permission to link the code of its release with the 13 | * OpenSSL project's "OpenSSL" library (or with modified versions of it 14 | * that use the same license as the "OpenSSL" library), and distribute 15 | * the linked executables. You must obey the GNU General Public License 16 | * in all respects for all of the code used other than "OpenSSL". If you 17 | * modify file(s) with this exception, you may extend this exception to 18 | * your version of the file(s), but you are not obligated to do so. If 19 | * you do not wish to do so, delete this exception statement from your 20 | * version. If you delete this exception statement from all source files 21 | * in the program, then also delete it here. 22 | * 23 | * This program is distributed in the hope that it will be useful, but 24 | * WITHOUT ANY WARRANTY; without even the implied warranty of 25 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 26 | * General Public License for more details. 27 | * 28 | * You should have received a copy of the GNU General Public License 29 | * along with this program. If not, see . 30 | **/ 31 | 32 | 33 | #pragma once 34 | 35 | #include "IFindRequestHandler.h" 36 | 37 | namespace Orthanc 38 | { 39 | class IFindRequestHandlerFactory 40 | { 41 | public: 42 | virtual ~IFindRequestHandlerFactory() 43 | { 44 | } 45 | 46 | virtual IFindRequestHandler* ConstructFindRequestHandler() = 0; 47 | }; 48 | } 49 | -------------------------------------------------------------------------------- /OrthancServer/DicomProtocol/IMoveRequestHandler.h: -------------------------------------------------------------------------------- 1 | /** 2 | * Orthanc - A Lightweight, RESTful DICOM Store 3 | * Copyright (C) 2012-2013 Medical Physics Department, CHU of Liege, 4 | * Belgium 5 | * 6 | * This program is free software: you can redistribute it and/or 7 | * modify it under the terms of the GNU General Public License as 8 | * published by the Free Software Foundation, either version 3 of the 9 | * License, or (at your option) any later version. 10 | * 11 | * In addition, as a special exception, the copyright holders of this 12 | * program give permission to link the code of its release with the 13 | * OpenSSL project's "OpenSSL" library (or with modified versions of it 14 | * that use the same license as the "OpenSSL" library), and distribute 15 | * the linked executables. You must obey the GNU General Public License 16 | * in all respects for all of the code used other than "OpenSSL". If you 17 | * modify file(s) with this exception, you may extend this exception to 18 | * your version of the file(s), but you are not obligated to do so. If 19 | * you do not wish to do so, delete this exception statement from your 20 | * version. If you delete this exception statement from all source files 21 | * in the program, then also delete it here. 22 | * 23 | * This program is distributed in the hope that it will be useful, but 24 | * WITHOUT ANY WARRANTY; without even the implied warranty of 25 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 26 | * General Public License for more details. 27 | * 28 | * You should have received a copy of the GNU General Public License 29 | * along with this program. If not, see . 30 | **/ 31 | 32 | 33 | #pragma once 34 | 35 | #include "../../Core/DicomFormat/DicomMap.h" 36 | 37 | #include 38 | #include 39 | 40 | 41 | namespace Orthanc 42 | { 43 | class IMoveRequestIterator 44 | { 45 | public: 46 | enum Status 47 | { 48 | Status_Success, 49 | Status_Failure, 50 | Status_Warning 51 | }; 52 | 53 | virtual ~IMoveRequestIterator() 54 | { 55 | } 56 | 57 | virtual unsigned int GetSubOperationCount() const = 0; 58 | 59 | virtual Status DoNext() = 0; 60 | }; 61 | 62 | 63 | class IMoveRequestHandler 64 | { 65 | public: 66 | virtual ~IMoveRequestHandler() 67 | { 68 | } 69 | 70 | virtual IMoveRequestIterator* Handle(const std::string& target, 71 | const DicomMap& input) = 0; 72 | }; 73 | 74 | } 75 | -------------------------------------------------------------------------------- /OrthancServer/DicomProtocol/IMoveRequestHandlerFactory.h: -------------------------------------------------------------------------------- 1 | /** 2 | * Orthanc - A Lightweight, RESTful DICOM Store 3 | * Copyright (C) 2012-2013 Medical Physics Department, CHU of Liege, 4 | * Belgium 5 | * 6 | * This program is free software: you can redistribute it and/or 7 | * modify it under the terms of the GNU General Public License as 8 | * published by the Free Software Foundation, either version 3 of the 9 | * License, or (at your option) any later version. 10 | * 11 | * In addition, as a special exception, the copyright holders of this 12 | * program give permission to link the code of its release with the 13 | * OpenSSL project's "OpenSSL" library (or with modified versions of it 14 | * that use the same license as the "OpenSSL" library), and distribute 15 | * the linked executables. You must obey the GNU General Public License 16 | * in all respects for all of the code used other than "OpenSSL". If you 17 | * modify file(s) with this exception, you may extend this exception to 18 | * your version of the file(s), but you are not obligated to do so. If 19 | * you do not wish to do so, delete this exception statement from your 20 | * version. If you delete this exception statement from all source files 21 | * in the program, then also delete it here. 22 | * 23 | * This program is distributed in the hope that it will be useful, but 24 | * WITHOUT ANY WARRANTY; without even the implied warranty of 25 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 26 | * General Public License for more details. 27 | * 28 | * You should have received a copy of the GNU General Public License 29 | * along with this program. If not, see . 30 | **/ 31 | 32 | 33 | #pragma once 34 | 35 | #include "IMoveRequestHandler.h" 36 | 37 | namespace Orthanc 38 | { 39 | class IMoveRequestHandlerFactory 40 | { 41 | public: 42 | virtual ~IMoveRequestHandlerFactory() 43 | { 44 | } 45 | 46 | virtual IMoveRequestHandler* ConstructMoveRequestHandler() = 0; 47 | }; 48 | } 49 | -------------------------------------------------------------------------------- /OrthancServer/DicomProtocol/IStoreRequestHandler.h: -------------------------------------------------------------------------------- 1 | /** 2 | * Orthanc - A Lightweight, RESTful DICOM Store 3 | * Copyright (C) 2012-2013 Medical Physics Department, CHU of Liege, 4 | * Belgium 5 | * 6 | * This program is free software: you can redistribute it and/or 7 | * modify it under the terms of the GNU General Public License as 8 | * published by the Free Software Foundation, either version 3 of the 9 | * License, or (at your option) any later version. 10 | * 11 | * In addition, as a special exception, the copyright holders of this 12 | * program give permission to link the code of its release with the 13 | * OpenSSL project's "OpenSSL" library (or with modified versions of it 14 | * that use the same license as the "OpenSSL" library), and distribute 15 | * the linked executables. You must obey the GNU General Public License 16 | * in all respects for all of the code used other than "OpenSSL". If you 17 | * modify file(s) with this exception, you may extend this exception to 18 | * your version of the file(s), but you are not obligated to do so. If 19 | * you do not wish to do so, delete this exception statement from your 20 | * version. If you delete this exception statement from all source files 21 | * in the program, then also delete it here. 22 | * 23 | * This program is distributed in the hope that it will be useful, but 24 | * WITHOUT ANY WARRANTY; without even the implied warranty of 25 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 26 | * General Public License for more details. 27 | * 28 | * You should have received a copy of the GNU General Public License 29 | * along with this program. If not, see . 30 | **/ 31 | 32 | 33 | #pragma once 34 | 35 | #include "../../Core/DicomFormat/DicomMap.h" 36 | 37 | #include 38 | #include 39 | #include 40 | 41 | namespace Orthanc 42 | { 43 | class IStoreRequestHandler 44 | { 45 | public: 46 | virtual ~IStoreRequestHandler() 47 | { 48 | } 49 | 50 | virtual void Handle(const std::string& dicomFile, 51 | const DicomMap& dicomSummary, 52 | const Json::Value& dicomJson, 53 | const std::string& distantAet) = 0; 54 | }; 55 | } 56 | -------------------------------------------------------------------------------- /OrthancServer/DicomProtocol/IStoreRequestHandlerFactory.h: -------------------------------------------------------------------------------- 1 | /** 2 | * Orthanc - A Lightweight, RESTful DICOM Store 3 | * Copyright (C) 2012-2013 Medical Physics Department, CHU of Liege, 4 | * Belgium 5 | * 6 | * This program is free software: you can redistribute it and/or 7 | * modify it under the terms of the GNU General Public License as 8 | * published by the Free Software Foundation, either version 3 of the 9 | * License, or (at your option) any later version. 10 | * 11 | * In addition, as a special exception, the copyright holders of this 12 | * program give permission to link the code of its release with the 13 | * OpenSSL project's "OpenSSL" library (or with modified versions of it 14 | * that use the same license as the "OpenSSL" library), and distribute 15 | * the linked executables. You must obey the GNU General Public License 16 | * in all respects for all of the code used other than "OpenSSL". If you 17 | * modify file(s) with this exception, you may extend this exception to 18 | * your version of the file(s), but you are not obligated to do so. If 19 | * you do not wish to do so, delete this exception statement from your 20 | * version. If you delete this exception statement from all source files 21 | * in the program, then also delete it here. 22 | * 23 | * This program is distributed in the hope that it will be useful, but 24 | * WITHOUT ANY WARRANTY; without even the implied warranty of 25 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 26 | * General Public License for more details. 27 | * 28 | * You should have received a copy of the GNU General Public License 29 | * along with this program. If not, see . 30 | **/ 31 | 32 | 33 | #pragma once 34 | 35 | #include "IStoreRequestHandler.h" 36 | 37 | namespace Orthanc 38 | { 39 | class IStoreRequestHandlerFactory 40 | { 41 | public: 42 | virtual ~IStoreRequestHandlerFactory() 43 | { 44 | } 45 | 46 | virtual IStoreRequestHandler* ConstructStoreRequestHandler() = 0; 47 | }; 48 | } 49 | -------------------------------------------------------------------------------- /OrthancServer/IServerIndexListener.h: -------------------------------------------------------------------------------- 1 | /** 2 | * Orthanc - A Lightweight, RESTful DICOM Store 3 | * Copyright (C) 2012-2013 Medical Physics Department, CHU of Liege, 4 | * Belgium 5 | * 6 | * This program is free software: you can redistribute it and/or 7 | * modify it under the terms of the GNU General Public License as 8 | * published by the Free Software Foundation, either version 3 of the 9 | * License, or (at your option) any later version. 10 | * 11 | * In addition, as a special exception, the copyright holders of this 12 | * program give permission to link the code of its release with the 13 | * OpenSSL project's "OpenSSL" library (or with modified versions of it 14 | * that use the same license as the "OpenSSL" library), and distribute 15 | * the linked executables. You must obey the GNU General Public License 16 | * in all respects for all of the code used other than "OpenSSL". If you 17 | * modify file(s) with this exception, you may extend this exception to 18 | * your version of the file(s), but you are not obligated to do so. If 19 | * you do not wish to do so, delete this exception statement from your 20 | * version. If you delete this exception statement from all source files 21 | * in the program, then also delete it here. 22 | * 23 | * This program is distributed in the hope that it will be useful, but 24 | * WITHOUT ANY WARRANTY; without even the implied warranty of 25 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 26 | * General Public License for more details. 27 | * 28 | * You should have received a copy of the GNU General Public License 29 | * along with this program. If not, see . 30 | **/ 31 | 32 | 33 | #pragma once 34 | 35 | #include 36 | #include "ServerEnumerations.h" 37 | 38 | namespace Orthanc 39 | { 40 | class IServerIndexListener 41 | { 42 | public: 43 | virtual ~IServerIndexListener() 44 | { 45 | } 46 | 47 | virtual void SignalRemainingAncestor(ResourceType parentType, 48 | const std::string& publicId) = 0; 49 | 50 | virtual void SignalFileDeleted(const FileInfo& info) = 0; 51 | }; 52 | } 53 | -------------------------------------------------------------------------------- /OrthancServer/Internals/FindScp.h: -------------------------------------------------------------------------------- 1 | /** 2 | * Orthanc - A Lightweight, RESTful DICOM Store 3 | * Copyright (C) 2012-2013 Medical Physics Department, CHU of Liege, 4 | * Belgium 5 | * 6 | * This program is free software: you can redistribute it and/or 7 | * modify it under the terms of the GNU General Public License as 8 | * published by the Free Software Foundation, either version 3 of the 9 | * License, or (at your option) any later version. 10 | * 11 | * In addition, as a special exception, the copyright holders of this 12 | * program give permission to link the code of its release with the 13 | * OpenSSL project's "OpenSSL" library (or with modified versions of it 14 | * that use the same license as the "OpenSSL" library), and distribute 15 | * the linked executables. You must obey the GNU General Public License 16 | * in all respects for all of the code used other than "OpenSSL". If you 17 | * modify file(s) with this exception, you may extend this exception to 18 | * your version of the file(s), but you are not obligated to do so. If 19 | * you do not wish to do so, delete this exception statement from your 20 | * version. If you delete this exception statement from all source files 21 | * in the program, then also delete it here. 22 | * 23 | * This program is distributed in the hope that it will be useful, but 24 | * WITHOUT ANY WARRANTY; without even the implied warranty of 25 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 26 | * General Public License for more details. 27 | * 28 | * You should have received a copy of the GNU General Public License 29 | * along with this program. If not, see . 30 | **/ 31 | 32 | 33 | #pragma once 34 | 35 | #include "../DicomProtocol/IFindRequestHandler.h" 36 | 37 | #include 38 | 39 | namespace Orthanc 40 | { 41 | namespace Internals 42 | { 43 | OFCondition findScp(T_ASC_Association * assoc, 44 | T_DIMSE_Message * msg, 45 | T_ASC_PresentationContextID presID, 46 | IFindRequestHandler& handler); 47 | } 48 | } 49 | -------------------------------------------------------------------------------- /OrthancServer/Internals/MoveScp.h: -------------------------------------------------------------------------------- 1 | /** 2 | * Orthanc - A Lightweight, RESTful DICOM Store 3 | * Copyright (C) 2012-2013 Medical Physics Department, CHU of Liege, 4 | * Belgium 5 | * 6 | * This program is free software: you can redistribute it and/or 7 | * modify it under the terms of the GNU General Public License as 8 | * published by the Free Software Foundation, either version 3 of the 9 | * License, or (at your option) any later version. 10 | * 11 | * In addition, as a special exception, the copyright holders of this 12 | * program give permission to link the code of its release with the 13 | * OpenSSL project's "OpenSSL" library (or with modified versions of it 14 | * that use the same license as the "OpenSSL" library), and distribute 15 | * the linked executables. You must obey the GNU General Public License 16 | * in all respects for all of the code used other than "OpenSSL". If you 17 | * modify file(s) with this exception, you may extend this exception to 18 | * your version of the file(s), but you are not obligated to do so. If 19 | * you do not wish to do so, delete this exception statement from your 20 | * version. If you delete this exception statement from all source files 21 | * in the program, then also delete it here. 22 | * 23 | * This program is distributed in the hope that it will be useful, but 24 | * WITHOUT ANY WARRANTY; without even the implied warranty of 25 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 26 | * General Public License for more details. 27 | * 28 | * You should have received a copy of the GNU General Public License 29 | * along with this program. If not, see . 30 | **/ 31 | 32 | 33 | #pragma once 34 | 35 | #include "../DicomProtocol/IMoveRequestHandler.h" 36 | 37 | #include 38 | 39 | namespace Orthanc 40 | { 41 | namespace Internals 42 | { 43 | OFCondition moveScp(T_ASC_Association * assoc, 44 | T_DIMSE_Message * msg, 45 | T_ASC_PresentationContextID presID, 46 | IMoveRequestHandler& handler); 47 | } 48 | } 49 | -------------------------------------------------------------------------------- /OrthancServer/Internals/StoreScp.h: -------------------------------------------------------------------------------- 1 | /** 2 | * Orthanc - A Lightweight, RESTful DICOM Store 3 | * Copyright (C) 2012-2013 Medical Physics Department, CHU of Liege, 4 | * Belgium 5 | * 6 | * This program is free software: you can redistribute it and/or 7 | * modify it under the terms of the GNU General Public License as 8 | * published by the Free Software Foundation, either version 3 of the 9 | * License, or (at your option) any later version. 10 | * 11 | * In addition, as a special exception, the copyright holders of this 12 | * program give permission to link the code of its release with the 13 | * OpenSSL project's "OpenSSL" library (or with modified versions of it 14 | * that use the same license as the "OpenSSL" library), and distribute 15 | * the linked executables. You must obey the GNU General Public License 16 | * in all respects for all of the code used other than "OpenSSL". If you 17 | * modify file(s) with this exception, you may extend this exception to 18 | * your version of the file(s), but you are not obligated to do so. If 19 | * you do not wish to do so, delete this exception statement from your 20 | * version. If you delete this exception statement from all source files 21 | * in the program, then also delete it here. 22 | * 23 | * This program is distributed in the hope that it will be useful, but 24 | * WITHOUT ANY WARRANTY; without even the implied warranty of 25 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 26 | * General Public License for more details. 27 | * 28 | * You should have received a copy of the GNU General Public License 29 | * along with this program. If not, see . 30 | **/ 31 | 32 | 33 | #pragma once 34 | 35 | #include "../DicomProtocol/IStoreRequestHandler.h" 36 | 37 | #include 38 | 39 | namespace Orthanc 40 | { 41 | namespace Internals 42 | { 43 | OFCondition storeScp(T_ASC_Association * assoc, 44 | T_DIMSE_Message * msg, 45 | T_ASC_PresentationContextID presID, 46 | IStoreRequestHandler& handler); 47 | } 48 | } 49 | -------------------------------------------------------------------------------- /OrthancServer/OrthancRestApi.h: -------------------------------------------------------------------------------- 1 | /** 2 | * Orthanc - A Lightweight, RESTful DICOM Store 3 | * Copyright (C) 2012-2013 Medical Physics Department, CHU of Liege, 4 | * Belgium 5 | * 6 | * This program is free software: you can redistribute it and/or 7 | * modify it under the terms of the GNU General Public License as 8 | * published by the Free Software Foundation, either version 3 of the 9 | * License, or (at your option) any later version. 10 | * 11 | * In addition, as a special exception, the copyright holders of this 12 | * program give permission to link the code of its release with the 13 | * OpenSSL project's "OpenSSL" library (or with modified versions of it 14 | * that use the same license as the "OpenSSL" library), and distribute 15 | * the linked executables. You must obey the GNU General Public License 16 | * in all respects for all of the code used other than "OpenSSL". If you 17 | * modify file(s) with this exception, you may extend this exception to 18 | * your version of the file(s), but you are not obligated to do so. If 19 | * you do not wish to do so, delete this exception statement from your 20 | * version. If you delete this exception statement from all source files 21 | * in the program, then also delete it here. 22 | * 23 | * This program is distributed in the hope that it will be useful, but 24 | * WITHOUT ANY WARRANTY; without even the implied warranty of 25 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 26 | * General Public License for more details. 27 | * 28 | * You should have received a copy of the GNU General Public License 29 | * along with this program. If not, see . 30 | **/ 31 | 32 | 33 | #pragma once 34 | 35 | #include "ServerContext.h" 36 | #include "../Core/RestApi/RestApi.h" 37 | 38 | #include 39 | 40 | namespace Orthanc 41 | { 42 | class OrthancRestApi : public RestApi 43 | { 44 | public: 45 | typedef std::set SetOfStrings; 46 | 47 | private: 48 | ServerContext& context_; 49 | SetOfStrings modalities_; 50 | SetOfStrings peers_; 51 | 52 | public: 53 | OrthancRestApi(ServerContext& context); 54 | 55 | ServerContext& GetContext() 56 | { 57 | return context_; 58 | } 59 | 60 | SetOfStrings& GetModalities() 61 | { 62 | return modalities_; 63 | } 64 | 65 | SetOfStrings& GetPeers() 66 | { 67 | return peers_; 68 | } 69 | }; 70 | } 71 | -------------------------------------------------------------------------------- /OrthancServer/ServerToolbox.h: -------------------------------------------------------------------------------- 1 | /** 2 | * Orthanc - A Lightweight, RESTful DICOM Store 3 | * Copyright (C) 2012-2013 Medical Physics Department, CHU of Liege, 4 | * Belgium 5 | * 6 | * This program is free software: you can redistribute it and/or 7 | * modify it under the terms of the GNU General Public License as 8 | * published by the Free Software Foundation, either version 3 of the 9 | * License, or (at your option) any later version. 10 | * 11 | * In addition, as a special exception, the copyright holders of this 12 | * program give permission to link the code of its release with the 13 | * OpenSSL project's "OpenSSL" library (or with modified versions of it 14 | * that use the same license as the "OpenSSL" library), and distribute 15 | * the linked executables. You must obey the GNU General Public License 16 | * in all respects for all of the code used other than "OpenSSL". If you 17 | * modify file(s) with this exception, you may extend this exception to 18 | * your version of the file(s), but you are not obligated to do so. If 19 | * you do not wish to do so, delete this exception statement from your 20 | * version. If you delete this exception statement from all source files 21 | * in the program, then also delete it here. 22 | * 23 | * This program is distributed in the hope that it will be useful, but 24 | * WITHOUT ANY WARRANTY; without even the implied warranty of 25 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 26 | * General Public License for more details. 27 | * 28 | * You should have received a copy of the GNU General Public License 29 | * along with this program. If not, see . 30 | **/ 31 | 32 | 33 | #pragma once 34 | 35 | #include 36 | 37 | namespace Orthanc 38 | { 39 | void SimplifyTags(Json::Value& target, 40 | const Json::Value& source); 41 | } 42 | -------------------------------------------------------------------------------- /OrthancServer/ToDcmtkBridge.cpp: -------------------------------------------------------------------------------- 1 | /** 2 | * Orthanc - A Lightweight, RESTful DICOM Store 3 | * Copyright (C) 2012-2013 Medical Physics Department, CHU of Liege, 4 | * Belgium 5 | * 6 | * This program is free software: you can redistribute it and/or 7 | * modify it under the terms of the GNU General Public License as 8 | * published by the Free Software Foundation, either version 3 of the 9 | * License, or (at your option) any later version. 10 | * 11 | * In addition, as a special exception, the copyright holders of this 12 | * program give permission to link the code of its release with the 13 | * OpenSSL project's "OpenSSL" library (or with modified versions of it 14 | * that use the same license as the "OpenSSL" library), and distribute 15 | * the linked executables. You must obey the GNU General Public License 16 | * in all respects for all of the code used other than "OpenSSL". If you 17 | * modify file(s) with this exception, you may extend this exception to 18 | * your version of the file(s), but you are not obligated to do so. If 19 | * you do not wish to do so, delete this exception statement from your 20 | * version. If you delete this exception statement from all source files 21 | * in the program, then also delete it here. 22 | * 23 | * This program is distributed in the hope that it will be useful, but 24 | * WITHOUT ANY WARRANTY; without even the implied warranty of 25 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 26 | * General Public License for more details. 27 | * 28 | * You should have received a copy of the GNU General Public License 29 | * along with this program. If not, see . 30 | **/ 31 | 32 | 33 | #include "ToDcmtkBridge.h" 34 | 35 | #include 36 | #include 37 | 38 | 39 | namespace Orthanc 40 | { 41 | DcmTagKey ToDcmtkBridge::Convert(const DicomTag& tag) 42 | { 43 | return DcmTagKey(tag.GetGroup(), tag.GetElement()); 44 | } 45 | 46 | 47 | DcmDataset* ToDcmtkBridge::Convert(const DicomMap& map) 48 | { 49 | std::auto_ptr result(new DcmDataset); 50 | 51 | for (DicomMap::Map::const_iterator 52 | it = map.map_.begin(); it != map.map_.end(); it++) 53 | { 54 | std::string s = it->second->AsString(); 55 | DU_putStringDOElement(result.get(), Convert(it->first), s.c_str()); 56 | } 57 | 58 | return result.release(); 59 | } 60 | } 61 | -------------------------------------------------------------------------------- /OrthancServer/ToDcmtkBridge.h: -------------------------------------------------------------------------------- 1 | /** 2 | * Orthanc - A Lightweight, RESTful DICOM Store 3 | * Copyright (C) 2012-2013 Medical Physics Department, CHU of Liege, 4 | * Belgium 5 | * 6 | * This program is free software: you can redistribute it and/or 7 | * modify it under the terms of the GNU General Public License as 8 | * published by the Free Software Foundation, either version 3 of the 9 | * License, or (at your option) any later version. 10 | * 11 | * In addition, as a special exception, the copyright holders of this 12 | * program give permission to link the code of its release with the 13 | * OpenSSL project's "OpenSSL" library (or with modified versions of it 14 | * that use the same license as the "OpenSSL" library), and distribute 15 | * the linked executables. You must obey the GNU General Public License 16 | * in all respects for all of the code used other than "OpenSSL". If you 17 | * modify file(s) with this exception, you may extend this exception to 18 | * your version of the file(s), but you are not obligated to do so. If 19 | * you do not wish to do so, delete this exception statement from your 20 | * version. If you delete this exception statement from all source files 21 | * in the program, then also delete it here. 22 | * 23 | * This program is distributed in the hope that it will be useful, but 24 | * WITHOUT ANY WARRANTY; without even the implied warranty of 25 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 26 | * General Public License for more details. 27 | * 28 | * You should have received a copy of the GNU General Public License 29 | * along with this program. If not, see . 30 | **/ 31 | 32 | 33 | #pragma once 34 | 35 | #include "../Core/DicomFormat/DicomMap.h" 36 | #include 37 | 38 | namespace Orthanc 39 | { 40 | class ToDcmtkBridge 41 | { 42 | public: 43 | static DcmTagKey Convert(const DicomTag& tag); 44 | 45 | static DcmDataset* Convert(const DicomMap& map); 46 | }; 47 | } 48 | -------------------------------------------------------------------------------- /Resources/CMake/AutoGeneratedCode.cmake: -------------------------------------------------------------------------------- 1 | set(AUTOGENERATED_DIR "${CMAKE_CURRENT_BINARY_DIR}/AUTOGENERATED") 2 | set(AUTOGENERATED_SOURCES) 3 | 4 | file(MAKE_DIRECTORY ${AUTOGENERATED_DIR}) 5 | include_directories(${AUTOGENERATED_DIR}) 6 | 7 | macro(EmbedResources) 8 | # Convert a semicolon separated list to a whitespace separated string 9 | set(SCRIPT_ARGUMENTS) 10 | set(DEPENDENCIES) 11 | set(IS_PATH_NAME false) 12 | foreach(arg ${ARGN}) 13 | if (${IS_PATH_NAME}) 14 | list(APPEND SCRIPT_ARGUMENTS "${arg}") 15 | list(APPEND DEPENDENCIES "${arg}") 16 | set(IS_PATH_NAME false) 17 | else() 18 | list(APPEND SCRIPT_ARGUMENTS "${arg}") 19 | set(IS_PATH_NAME true) 20 | endif() 21 | endforeach() 22 | 23 | set(TARGET_BASE "${AUTOGENERATED_DIR}/EmbeddedResources") 24 | add_custom_command( 25 | OUTPUT 26 | "${TARGET_BASE}.h" 27 | "${TARGET_BASE}.cpp" 28 | COMMAND 29 | python 30 | "${CMAKE_CURRENT_SOURCE_DIR}/Resources/EmbedResources.py" 31 | "${AUTOGENERATED_DIR}/EmbeddedResources" 32 | ${SCRIPT_ARGUMENTS} 33 | DEPENDS 34 | "${CMAKE_CURRENT_SOURCE_DIR}/Resources/EmbedResources.py" 35 | ${DEPENDENCIES} 36 | ) 37 | 38 | list(APPEND AUTOGENERATED_SOURCES 39 | "${AUTOGENERATED_DIR}/EmbeddedResources.cpp" 40 | ) 41 | endmacro() 42 | -------------------------------------------------------------------------------- /Resources/CMake/GoogleTestConfiguration.cmake: -------------------------------------------------------------------------------- 1 | if (DEBIAN_USE_GTEST_SOURCE_PACKAGE) 2 | set(GTEST_SOURCES /usr/src/gtest/src/gtest-all.cc) 3 | include_directories(/usr/src/gtest) 4 | 5 | if (NOT EXISTS /usr/include/gtest/gtest.h OR 6 | NOT EXISTS ${GTEST_SOURCES}) 7 | message(FATAL_ERROR "Please install the libgtest-dev package") 8 | endif() 9 | 10 | elseif (STATIC_BUILD OR NOT USE_DYNAMIC_GOOGLE_TEST) 11 | SET(GTEST_SOURCES_DIR ${CMAKE_BINARY_DIR}/gtest-1.6.0) 12 | DownloadPackage( 13 | "4577b49f2973c90bf9ba69aa8166b786" 14 | "http://www.montefiore.ulg.ac.be/~jodogne/Orthanc/ThirdPartyDownloads/gtest-1.6.0.zip" 15 | "${GTEST_SOURCES_DIR}" "" "") 16 | 17 | include_directories( 18 | ${GTEST_SOURCES_DIR}/include 19 | ${GTEST_SOURCES_DIR} 20 | ) 21 | 22 | set(GTEST_SOURCES 23 | ${GTEST_SOURCES_DIR}/src/gtest-all.cc 24 | ) 25 | 26 | else() 27 | include(FindGTest) 28 | if (NOT GTEST_FOUND) 29 | message(FATAL_ERROR "Unable to find GoogleTest") 30 | endif() 31 | 32 | include_directories(${GTEST_INCLUDE_DIRS}) 33 | link_libraries(${GTEST_LIBRARIES}) 34 | endif() 35 | -------------------------------------------------------------------------------- /Resources/CMake/JsonCppConfiguration.cmake: -------------------------------------------------------------------------------- 1 | if (USE_DYNAMIC_JSONCPP) 2 | CHECK_INCLUDE_FILE_CXX(jsoncpp/json/reader.h HAVE_JSONCPP_H) 3 | if (NOT HAVE_JSONCPP_H) 4 | message(FATAL_ERROR "Please install the libjsoncpp-dev package") 5 | endif() 6 | 7 | include_directories(/usr/include/jsoncpp) 8 | link_libraries(jsoncpp) 9 | 10 | else() 11 | SET(JSONCPP_SOURCES_DIR ${CMAKE_BINARY_DIR}/jsoncpp-src-0.5.0) 12 | DownloadPackage( 13 | "24482b67c1cb17aac1ed1814288a3a8f" 14 | "http://www.montefiore.ulg.ac.be/~jodogne/Orthanc/ThirdPartyDownloads/jsoncpp-src-0.5.0.tar.gz" 15 | "${JSONCPP_SOURCES_DIR}" "" "") 16 | 17 | list(APPEND THIRD_PARTY_SOURCES 18 | ${JSONCPP_SOURCES_DIR}/src/lib_json/json_reader.cpp 19 | ${JSONCPP_SOURCES_DIR}/src/lib_json/json_value.cpp 20 | ${JSONCPP_SOURCES_DIR}/src/lib_json/json_writer.cpp 21 | ) 22 | 23 | include_directories( 24 | ${JSONCPP_SOURCES_DIR}/include 25 | ) 26 | 27 | source_group(ThirdParty\\JsonCpp REGULAR_EXPRESSION ${JSONCPP_SOURCES_DIR}/.*) 28 | endif() 29 | 30 | -------------------------------------------------------------------------------- /Resources/CMake/LibPngConfiguration.cmake: -------------------------------------------------------------------------------- 1 | if (${STATIC_BUILD}) 2 | SET(LIBPNG_SOURCES_DIR ${CMAKE_BINARY_DIR}/libpng-1.5.12) 3 | DownloadPackage( 4 | "8ea7f60347a306c5faf70b977fa80e28" 5 | "http://www.montefiore.ulg.ac.be/~jodogne/Orthanc/ThirdPartyDownloads/libpng-1.5.12.tar.gz" 6 | "${LIBPNG_SOURCES_DIR}" "${LIBPNG_PRELOADED}" "") 7 | 8 | include_directories( 9 | ${LIBPNG_SOURCES_DIR} 10 | ) 11 | 12 | configure_file( 13 | ${LIBPNG_SOURCES_DIR}/scripts/pnglibconf.h.prebuilt 14 | ${LIBPNG_SOURCES_DIR}/pnglibconf.h 15 | COPY_ONLY) 16 | 17 | set(LIBPNG_SOURCES 18 | #${LIBPNG_SOURCES_DIR}/example.c 19 | ${LIBPNG_SOURCES_DIR}/png.c 20 | ${LIBPNG_SOURCES_DIR}/pngerror.c 21 | ${LIBPNG_SOURCES_DIR}/pngget.c 22 | ${LIBPNG_SOURCES_DIR}/pngmem.c 23 | ${LIBPNG_SOURCES_DIR}/pngpread.c 24 | ${LIBPNG_SOURCES_DIR}/pngread.c 25 | ${LIBPNG_SOURCES_DIR}/pngrio.c 26 | ${LIBPNG_SOURCES_DIR}/pngrtran.c 27 | ${LIBPNG_SOURCES_DIR}/pngrutil.c 28 | ${LIBPNG_SOURCES_DIR}/pngset.c 29 | #${LIBPNG_SOURCES_DIR}/pngtest.c 30 | ${LIBPNG_SOURCES_DIR}/pngtrans.c 31 | ${LIBPNG_SOURCES_DIR}/pngwio.c 32 | ${LIBPNG_SOURCES_DIR}/pngwrite.c 33 | ${LIBPNG_SOURCES_DIR}/pngwtran.c 34 | ${LIBPNG_SOURCES_DIR}/pngwutil.c 35 | ) 36 | 37 | #set_property( 38 | # SOURCE ${LIBPNG_SOURCES} 39 | # PROPERTY COMPILE_FLAGS -UHAVE_CONFIG_H) 40 | 41 | list(APPEND THIRD_PARTY_SOURCES ${LIBPNG_SOURCES}) 42 | 43 | add_definitions( 44 | -DPNG_NO_CONSOLE_IO=1 45 | -DPNG_NO_STDIO=1 46 | ) 47 | 48 | source_group(ThirdParty\\Libpng REGULAR_EXPRESSION ${LIBPNG_SOURCES_DIR}/.*) 49 | 50 | else() 51 | include(FindPNG) 52 | 53 | if (NOT ${PNG_FOUND}) 54 | message(FATAL_ERROR "Unable to find LibPNG") 55 | endif() 56 | 57 | include_directories(${PNG_INCLUDE_DIRS}) 58 | link_libraries(${PNG_LIBRARIES}) 59 | add_definitions(${PNG_DEFINITIONS}) 60 | endif() 61 | -------------------------------------------------------------------------------- /Resources/CMake/LuaConfiguration.cmake: -------------------------------------------------------------------------------- 1 | if (STATIC_BUILD OR NOT USE_DYNAMIC_LUA) 2 | SET(LUA_SOURCES_DIR ${CMAKE_BINARY_DIR}/lua-5.1.5) 3 | DownloadPackage( 4 | "2e115fe26e435e33b0d5c022e4490567" 5 | "http://www.montefiore.ulg.ac.be/~jodogne/Orthanc/ThirdPartyDownloads/lua-5.1.5.tar.gz" 6 | "${LUA_SOURCES_DIR}" "" "") 7 | 8 | add_definitions( 9 | #-DLUA_LIB=1 10 | #-Dluaall_c=1 11 | #-DLUA_COMPAT_ALL=1 # Compile a generic version of Lua 12 | ) 13 | 14 | include_directories( 15 | ${LUA_SOURCES_DIR}/src 16 | ) 17 | 18 | set(LUA_SOURCES 19 | # Core Lua 20 | ${LUA_SOURCES_DIR}/src/lapi.c 21 | ${LUA_SOURCES_DIR}/src/lcode.c 22 | ${LUA_SOURCES_DIR}/src/ldebug.c 23 | ${LUA_SOURCES_DIR}/src/ldo.c 24 | ${LUA_SOURCES_DIR}/src/ldump.c 25 | ${LUA_SOURCES_DIR}/src/lfunc.c 26 | ${LUA_SOURCES_DIR}/src/lgc.c 27 | ${LUA_SOURCES_DIR}/src/llex.c 28 | ${LUA_SOURCES_DIR}/src/lmem.c 29 | ${LUA_SOURCES_DIR}/src/lobject.c 30 | ${LUA_SOURCES_DIR}/src/lopcodes.c 31 | ${LUA_SOURCES_DIR}/src/lparser.c 32 | ${LUA_SOURCES_DIR}/src/lstate.c 33 | ${LUA_SOURCES_DIR}/src/lstring.c 34 | ${LUA_SOURCES_DIR}/src/ltable.c 35 | ${LUA_SOURCES_DIR}/src/ltm.c 36 | ${LUA_SOURCES_DIR}/src/lundump.c 37 | ${LUA_SOURCES_DIR}/src/lvm.c 38 | ${LUA_SOURCES_DIR}/src/lzio.c 39 | 40 | # Base Lua modules 41 | ${LUA_SOURCES_DIR}/src/lauxlib.c 42 | ${LUA_SOURCES_DIR}/src/lbaselib.c 43 | ${LUA_SOURCES_DIR}/src/ldblib.c 44 | ${LUA_SOURCES_DIR}/src/liolib.c 45 | ${LUA_SOURCES_DIR}/src/lmathlib.c 46 | ${LUA_SOURCES_DIR}/src/loslib.c 47 | ${LUA_SOURCES_DIR}/src/ltablib.c 48 | ${LUA_SOURCES_DIR}/src/lstrlib.c 49 | ${LUA_SOURCES_DIR}/src/loadlib.c 50 | ${LUA_SOURCES_DIR}/src/linit.c 51 | ) 52 | 53 | add_library(Lua STATIC ${LUA_SOURCES}) 54 | link_libraries(Lua) 55 | 56 | source_group(ThirdParty\\Lua REGULAR_EXPRESSION ${LUA_SOURCES_DIR}/.*) 57 | 58 | else() 59 | include(FindLua51) 60 | 61 | if (NOT LUA51_FOUND) 62 | message(FATAL_ERROR "Please install the liblua-dev package") 63 | endif() 64 | 65 | include_directories(${LUA_INCLUDE_DIR}) 66 | link_libraries(${LUA_LIBRARIES}) 67 | endif() 68 | -------------------------------------------------------------------------------- /Resources/CMake/MongooseConfiguration.cmake: -------------------------------------------------------------------------------- 1 | if (STATIC_BUILD OR NOT USE_DYNAMIC_MONGOOSE) 2 | SET(MONGOOSE_SOURCES_DIR ${CMAKE_BINARY_DIR}/mongoose) 3 | DownloadPackage( 4 | "e718fc287b4eb1bd523be3fa00942bb0" 5 | "http://www.montefiore.ulg.ac.be/~jodogne/Orthanc/ThirdPartyDownloads/mongoose-3.1.tgz" 6 | "${MONGOOSE_SOURCES_DIR}" "" "") 7 | 8 | # Patch mongoose 9 | execute_process( 10 | COMMAND patch mongoose.c ${CMAKE_SOURCE_DIR}/Resources/Patches/mongoose-patch.diff 11 | WORKING_DIRECTORY ${MONGOOSE_SOURCES_DIR} 12 | ) 13 | 14 | include_directories( 15 | ${MONGOOSE_SOURCES_DIR} 16 | ) 17 | 18 | list(APPEND THIRD_PARTY_SOURCES 19 | ${MONGOOSE_SOURCES_DIR}/mongoose.c 20 | ) 21 | 22 | 23 | if (${ENABLE_SSL}) 24 | add_definitions( 25 | -DNO_SSL_DL=1 26 | ) 27 | if (${CMAKE_SYSTEM_NAME} STREQUAL "Linux") 28 | link_libraries(dl) 29 | endif() 30 | 31 | else() 32 | add_definitions( 33 | -DNO_SSL=1 # Remove SSL support from mongoose 34 | ) 35 | endif() 36 | 37 | source_group(ThirdParty\\Mongoose REGULAR_EXPRESSION ${MONGOOSE_SOURCES_DIR}/.*) 38 | 39 | else() 40 | CHECK_INCLUDE_FILE_CXX(mongoose.h HAVE_MONGOOSE_H) 41 | if (NOT HAVE_MONGOOSE_H) 42 | message(FATAL_ERROR "Please install the mongoose-devel package") 43 | endif() 44 | 45 | CHECK_LIBRARY_EXISTS(mongoose mg_start "" HAVE_MONGOOSE_LIB) 46 | if (NOT HAVE_MONGOOSE_LIB) 47 | message(FATAL_ERROR "Please install the mongoose-devel package") 48 | endif() 49 | 50 | link_libraries(mongoose) 51 | endif() 52 | -------------------------------------------------------------------------------- /Resources/CMake/SQLiteConfiguration.cmake: -------------------------------------------------------------------------------- 1 | if (STATIC_BUILD OR NOT USE_DYNAMIC_SQLITE) 2 | SET(SQLITE_SOURCES_DIR ${CMAKE_BINARY_DIR}/sqlite-amalgamation-3071300) 3 | DownloadPackage( 4 | "5fbeff9645ab035a1f580e90b279a16d" 5 | "http://www.montefiore.ulg.ac.be/~jodogne/Orthanc/ThirdPartyDownloads/sqlite-amalgamation-3071300.zip" 6 | "${SQLITE_SOURCES_DIR}" "" "") 7 | 8 | list(APPEND THIRD_PARTY_SOURCES 9 | ${SQLITE_SOURCES_DIR}/sqlite3.c 10 | ) 11 | 12 | add_definitions( 13 | # For SQLite to run in the "Serialized" thread-safe mode 14 | # http://www.sqlite.org/threadsafe.html 15 | -DSQLITE_THREADSAFE=1 16 | -DSQLITE_OMIT_LOAD_EXTENSION # Disable SQLite plugins 17 | ) 18 | 19 | include_directories( 20 | ${SQLITE_SOURCES_DIR} 21 | ) 22 | 23 | source_group(ThirdParty\\SQLite REGULAR_EXPRESSION ${SQLITE_SOURCES_DIR}/.*) 24 | 25 | else() 26 | CHECK_INCLUDE_FILE_CXX(sqlite3.h HAVE_SQLITE_H) 27 | if (NOT HAVE_SQLITE_H) 28 | message(FATAL_ERROR "Please install the libsqlite3-dev package") 29 | endif() 30 | 31 | # Autodetection of the version of SQLite 32 | file(STRINGS "/usr/include/sqlite3.h" SQLITE_VERSION_NUMBER1 REGEX "#define SQLITE_VERSION_NUMBER.*$") 33 | string(REGEX REPLACE "#define SQLITE_VERSION_NUMBER(.*)$" "\\1" SQLITE_VERSION_NUMBER ${SQLITE_VERSION_NUMBER1}) 34 | 35 | message("Detected version of SQLite: ${SQLITE_VERSION_NUMBER}") 36 | 37 | IF (${SQLITE_VERSION_NUMBER} LESS 3007000) 38 | # "sqlite3_create_function_v2" is not defined in SQLite < 3.7.0 39 | message(FATAL_ERROR "SQLite version must be above 3.7.0. Please set the CMake variable USE_DYNAMIC_SQLITE to OFF.") 40 | ENDIF() 41 | 42 | link_libraries(sqlite3) 43 | endif() 44 | -------------------------------------------------------------------------------- /Resources/CMake/ZlibConfiguration.cmake: -------------------------------------------------------------------------------- 1 | # This is the minizip distribution to create ZIP files 2 | list(APPEND THIRD_PARTY_SOURCES 3 | ${CMAKE_SOURCE_DIR}/Resources/minizip/ioapi.c 4 | ${CMAKE_SOURCE_DIR}/Resources/minizip/zip.c 5 | ) 6 | 7 | if (${STATIC_BUILD}) 8 | SET(ZLIB_SOURCES_DIR ${CMAKE_BINARY_DIR}/zlib-1.2.7) 9 | DownloadPackage( 10 | "60df6a37c56e7c1366cca812414f7b85" 11 | "http://www.montefiore.ulg.ac.be/~jodogne/Orthanc/ThirdPartyDownloads/zlib-1.2.7.tar.gz" 12 | "${ZLIB_SOURCES_DIR}" "${ZLIB_PRELOADED}" "") 13 | 14 | include_directories( 15 | ${ZLIB_SOURCES_DIR} 16 | ) 17 | 18 | list(APPEND THIRD_PARTY_SOURCES 19 | ${ZLIB_SOURCES_DIR}/adler32.c 20 | ${ZLIB_SOURCES_DIR}/compress.c 21 | ${ZLIB_SOURCES_DIR}/crc32.c 22 | ${ZLIB_SOURCES_DIR}/deflate.c 23 | ${ZLIB_SOURCES_DIR}/gzclose.c 24 | ${ZLIB_SOURCES_DIR}/gzlib.c 25 | ${ZLIB_SOURCES_DIR}/gzread.c 26 | ${ZLIB_SOURCES_DIR}/gzwrite.c 27 | ${ZLIB_SOURCES_DIR}/infback.c 28 | ${ZLIB_SOURCES_DIR}/inffast.c 29 | ${ZLIB_SOURCES_DIR}/inflate.c 30 | ${ZLIB_SOURCES_DIR}/inftrees.c 31 | ${ZLIB_SOURCES_DIR}/trees.c 32 | ${ZLIB_SOURCES_DIR}/uncompr.c 33 | ${ZLIB_SOURCES_DIR}/zutil.c 34 | ) 35 | 36 | else() 37 | include(FindZLIB) 38 | include_directories(${ZLIB_INCLUDE_DIRS}) 39 | link_libraries(${ZLIB_LIBRARIES}) 40 | endif() 41 | 42 | source_group(ThirdParty\\ZLib REGULAR_EXPRESSION ${ZLIB_SOURCES_DIR}/.*) 43 | -------------------------------------------------------------------------------- /Resources/LinuxStandardBaseToolchain.cmake: -------------------------------------------------------------------------------- 1 | INCLUDE(CMakeForceCompiler) 2 | 3 | SET(LSB_PATH $ENV{LSB_PATH}) 4 | SET(LSB_TARGET_VERSION "4.0") 5 | 6 | IF ("${LSB_PATH}" STREQUAL "") 7 | SET(LSB_PATH "/opt/lsb") 8 | ENDIF() 9 | 10 | message("Using the following Linux Standard Base: ${LSB_PATH}") 11 | 12 | IF (EXISTS ${LSB_PATH}/lib64) 13 | SET(LSB_TARGET_PROCESSOR "x86_64") 14 | ELSEIF (EXISTS ${LSB_PATH}/lib) 15 | SET(LSB_TARGET_PROCESSOR "x86") 16 | ELSE() 17 | MESSAGE(FATAL_ERROR "Unable to detect the target processor architecture. Check the LSB_PATH environment variable.") 18 | ENDIF() 19 | 20 | SET(LSB_CPPPATH ${LSB_PATH}/include) 21 | SET(LSB_LIBPATH ${LSB_PATH}/lib-${LSB_TARGET_VERSION}) 22 | SET(PKG_CONFIG_PATH ${LSB_LIBPATH}/pkgconfig/) 23 | 24 | # the name of the target operating system 25 | SET(CMAKE_SYSTEM_NAME Linux) 26 | SET(CMAKE_SYSTEM_VERSION LinuxStandardBase) 27 | SET(CMAKE_SYSTEM_PROCESSOR ${LSB_TARGET_PROCESSOR}) 28 | 29 | # which compilers to use for C and C++ 30 | SET(CMAKE_C_COMPILER ${LSB_PATH}/bin/lsbcc) 31 | CMAKE_FORCE_CXX_COMPILER(${LSB_PATH}/bin/lsbc++ GNU) 32 | 33 | # here is the target environment located 34 | SET(CMAKE_FIND_ROOT_PATH ${LSB_PATH}) 35 | 36 | # adjust the default behaviour of the FIND_XXX() commands: 37 | # search headers and libraries in the target environment, search 38 | # programs in the host environment 39 | SET(CMAKE_FIND_ROOT_PATH_MODE_PROGRAM NEVER) 40 | SET(CMAKE_FIND_ROOT_PATH_MODE_LIBRARY ONLY) 41 | SET(CMAKE_FIND_ROOT_PATH_MODE_INCLUDE ONLY) 42 | -------------------------------------------------------------------------------- /Resources/MinGWToolchain.cmake: -------------------------------------------------------------------------------- 1 | # http://www.vtk.org/Wiki/CmakeMingw 2 | 3 | # the name of the target operating system 4 | SET(CMAKE_SYSTEM_NAME Windows) 5 | 6 | # which compilers to use for C and C++ 7 | SET(CMAKE_C_COMPILER i586-mingw32msvc-gcc) 8 | SET(CMAKE_CXX_COMPILER i586-mingw32msvc-g++) 9 | SET(CMAKE_RC_COMPILER i586-mingw32msvc-windres) 10 | 11 | # here is the target environment located 12 | SET(CMAKE_FIND_ROOT_PATH /usr/i586-mingw32msvc) 13 | 14 | # adjust the default behaviour of the FIND_XXX() commands: 15 | # search headers and libraries in the target environment, search 16 | # programs in the host environment 17 | set(CMAKE_FIND_ROOT_PATH_MODE_PROGRAM NEVER) 18 | set(CMAKE_FIND_ROOT_PATH_MODE_LIBRARY ONLY) 19 | set(CMAKE_FIND_ROOT_PATH_MODE_INCLUDE ONLY) 20 | -------------------------------------------------------------------------------- /Resources/Patches/glog-port-cc.diff: -------------------------------------------------------------------------------- 1 | --- i/glog-0.3.2/src/windows/port.cc 2011-08-30 09:56:13.000000000 +0200 2 | +++ port.cc 2012-10-03 17:11:54.000000000 +0200 3 | @@ -55,6 +55,7 @@ 4 | return _vsnprintf(str, size-1, format, ap); 5 | } 6 | 7 | +#if !defined(__MINGW32__) 8 | int snprintf(char *str, size_t size, const char *format, ...) { 9 | va_list ap; 10 | va_start(ap, format); 11 | @@ -62,3 +63,4 @@ 12 | va_end(ap); 13 | return r; 14 | } 15 | +#endif 16 | -------------------------------------------------------------------------------- /Resources/Patches/glog-port-h.diff: -------------------------------------------------------------------------------- 1 | --- /tmp/m/glog-0.3.2/src/windows/port.h 2012-10-03 12:54:10.958149861 +0200 2 | +++ port.h 2012-10-03 16:19:56.721837994 +0200 3 | @@ -129,6 +129,27 @@ 4 | #define pthread_self GetCurrentThreadId 5 | #define pthread_equal(pthread_t_1, pthread_t_2) ((pthread_t_1)==(pthread_t_2)) 6 | 7 | +#if defined(__MINGW32__) 8 | +inline int localtime_s(tm * _tm, const time_t * time) 9 | +{ 10 | + tm * posix_local_time_struct = localtime(time); 11 | + if (posix_local_time_struct == NULL) 12 | + { 13 | + return 1; 14 | + } 15 | + 16 | + *_tm = *posix_local_time_struct; 17 | + 18 | + return 0; 19 | +} 20 | + 21 | +inline char* strerror_s(char* buf, size_t buflen, int errnum) 22 | +{ 23 | + const char* str = strerror(errnum); 24 | + return strncpy(buf, str, buflen - 1); 25 | +} 26 | +#endif 27 | + 28 | inline struct tm* localtime_r(const time_t* timep, struct tm* result) { 29 | localtime_s(result, timep); 30 | return result; 31 | -------------------------------------------------------------------------------- /Resources/Patches/glog-utilities.diff: -------------------------------------------------------------------------------- 1 | --- /tmp/m/glog-0.3.2/src/utilities.cc 2012-01-12 09:40:21.000000000 +0100 2 | +++ utilities.cc 2012-10-03 16:04:19.745861665 +0200 3 | @@ -295,7 +295,7 @@ 4 | g_my_user_name = "invalid-user"; 5 | } 6 | } 7 | +REGISTER_MODULE_INITIALIZER(utilities, MyUserNameInitializer()) 8 | -REGISTER_MODULE_INITIALIZER(utilities, MyUserNameInitializer()); 9 | 10 | #ifdef HAVE_STACKTRACE 11 | void DumpStackTraceToString(string* stacktrace) { 12 | -------------------------------------------------------------------------------- /Resources/Patches/log4cplus-patch.diff: -------------------------------------------------------------------------------- 1 | --- log4cplus-1.0.4.1/src/factory.cxx 2010-05-28 11:06:51.000000000 +0200 2 | +++ factory.cxx 2012-10-02 11:43:31.808439489 +0200 3 | @@ -35,7 +35,7 @@ 4 | # if defined (LOG4CPLUS_HAVE_WIN32_CONSOLE) 5 | # include 6 | # endif 7 | -# include 8 | +# include 9 | #endif 10 | 11 | -------------------------------------------------------------------------------- /Resources/Patches/mongoose-patch.diff: -------------------------------------------------------------------------------- 1 | --- /home/jodogne/Subversion/Orthanc/ThirdPartyDownloads/mongoose/mongoose.c 2012-03-11 23:41:35.000000000 +0100 2 | +++ mongoose.c 2013-03-07 10:07:00.566266153 +0100 3 | @@ -92,8 +92,9 @@ 4 | #define strtoll(x, y, z) strtol(x, y, z) 5 | #else 6 | #define __func__ __FUNCTION__ 7 | -#define strtoull(x, y, z) _strtoui64(x, y, z) 8 | -#define strtoll(x, y, z) _strtoi64(x, y, z) 9 | +#include 10 | +//#define strtoull(x, y, z) _strtoui64(x, y, z) 11 | +//#define strtoll(x, y, z) _strtoi64(x, y, z) 12 | #endif // _MSC_VER 13 | 14 | #define ERRNO GetLastError() 15 | @@ -253,6 +254,14 @@ 16 | #define MSG_NOSIGNAL 0 17 | #endif 18 | 19 | +#if __gnu_hurd__ == 1 20 | +/** 21 | + * There is no limit on the length on a path under GNU Hurd, so we set 22 | + * it to an arbitrary constant. 23 | + **/ 24 | +#define PATH_MAX 4096 25 | +#endif 26 | + 27 | typedef void * (*mg_thread_func_t)(void *); 28 | 29 | static const char *http_500_error = "Internal Server Error"; 30 | @@ -3844,10 +3853,8 @@ 31 | } 32 | 33 | static void discard_current_request_from_buffer(struct mg_connection *conn) { 34 | - char *buffered; 35 | int buffered_len, body_len; 36 | 37 | - buffered = conn->buf + conn->request_len; 38 | buffered_len = conn->data_len - conn->request_len; 39 | assert(buffered_len >= 0); 40 | 41 | @@ -4148,7 +4155,13 @@ 42 | 43 | // Wait until mg_fini() stops 44 | while (ctx->stop_flag != 2) { 45 | +#if defined(__linux) 46 | + usleep(100000); 47 | +#elif defined(_WIN32) 48 | + Sleep(100); 49 | +#else 50 | (void) sleep(0); 51 | +#endif 52 | } 53 | free_context(ctx); 54 | 55 | -------------------------------------------------------------------------------- /Resources/Samples/ImportDicomFiles/ImportDicomFiles.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/python 2 | 3 | import os 4 | import sys 5 | import os.path 6 | import httplib2 7 | import base64 8 | 9 | if len(sys.argv) != 4 and len(sys.argv) != 6: 10 | print(""" 11 | Sample script to recursively import in Orthanc all the DICOM files 12 | that are stored in some path. Please make sure that Orthanc is running 13 | before starting this script. The files are uploaded through the REST 14 | API. 15 | 16 | Usage: %s [hostname] [HTTP port] [path] 17 | Usage: %s [hostname] [HTTP port] [path] [username] [password] 18 | For instance: %s localhost 8042 . 19 | """ % (sys.argv[0], sys.argv[0], sys.argv[0])) 20 | exit(-1) 21 | 22 | URL = 'http://%s:%d/instances' % (sys.argv[1], int(sys.argv[2])) 23 | 24 | success = 0 25 | 26 | 27 | # This function will upload a single file to Orthanc through the REST API 28 | def UploadFile(path): 29 | global success 30 | 31 | f = open(path, "rb") 32 | content = f.read() 33 | f.close() 34 | 35 | try: 36 | sys.stdout.write("Importing %s" % path) 37 | 38 | h = httplib2.Http() 39 | 40 | headers = { 'content-type' : 'application/dicom' } 41 | 42 | if len(sys.argv) == 6: 43 | username = sys.argv[4] 44 | password = sys.argv[5] 45 | 46 | # h.add_credentials(username, password) 47 | 48 | # This is a custom reimplementation of the 49 | # "Http.add_credentials()" method for Basic HTTP Access 50 | # Authentication (for some weird reason, this method does 51 | # not always work) 52 | # http://en.wikipedia.org/wiki/Basic_access_authentication 53 | headers['authorization'] = 'Basic ' + base64.b64encode(username + ':' + password) 54 | 55 | resp, content = h.request(URL, 'POST', 56 | body = content, 57 | headers = headers) 58 | 59 | if resp.status == 200: 60 | sys.stdout.write(" => success\n") 61 | success += 1 62 | else: 63 | sys.stdout.write(" => failure (Is it a DICOM file?)\n") 64 | 65 | except: 66 | sys.stdout.write(" => unable to connect (Is Orthanc running? Is there a password?)\n") 67 | 68 | 69 | if os.path.isfile(sys.argv[3]): 70 | # Upload a single file 71 | UploadFile(sys.argv[3]) 72 | else: 73 | # Recursively upload a directory 74 | for root, dirs, files in os.walk(sys.argv[3]): 75 | for f in files: 76 | UploadFile(os.path.join(root, f)) 77 | 78 | 79 | print("\nSummary: %d DICOM file(s) have been imported" % success) 80 | -------------------------------------------------------------------------------- /Resources/Samples/OrthancCppClient/Basic/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | # Mini-project to check whether "OrthancCppClient" can compile in a 2 | # standalone fashion 3 | 4 | cmake_minimum_required(VERSION 2.8) 5 | 6 | project(OrthancCppClientTest) 7 | 8 | set(STATIC_BUILD OFF) 9 | set(ORTHANC_ROOT ${CMAKE_SOURCE_DIR}/../../../..) 10 | 11 | include(../OrthancCppClient.cmake) 12 | 13 | add_executable(Test 14 | main.cpp 15 | ${ORTHANC_CPP_CLIENT_SOURCES} 16 | ) 17 | -------------------------------------------------------------------------------- /Resources/Samples/OrthancCppClient/Basic/main.cpp: -------------------------------------------------------------------------------- 1 | /** 2 | * Orthanc - A Lightweight, RESTful DICOM Store 3 | * Copyright (C) 2012-2013 Medical Physics Department, CHU of Liege, 4 | * Belgium 5 | * 6 | * Permission is hereby granted, free of charge, to any person 7 | * obtaining a copy of this software and associated documentation 8 | * files (the "Software"), to deal in the Software without 9 | * restriction, including without limitation the rights to use, copy, 10 | * modify, merge, publish, distribute, sublicense, and/or sell copies 11 | * of the Software, and to permit persons to whom the Software is 12 | * furnished to do so, subject to the following conditions: 13 | * 14 | * The above copyright notice and this permission notice shall be 15 | * included in all copies or substantial portions of the Software. 16 | * 17 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 18 | * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 19 | * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 20 | * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS 21 | * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN 22 | * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 23 | * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 24 | * SOFTWARE. 25 | **/ 26 | 27 | 28 | #include 29 | 30 | #include "../../../../Core/HttpClient.h" 31 | #include "../../../../OrthancCppClient/OrthancConnection.h" 32 | 33 | int main() 34 | { 35 | // Prepare a simple call to a Web service 36 | Orthanc::HttpClient c; 37 | c.SetUrl("http://nominatim.openstreetmap.org/search?format=json&q=chu+liege+belgium"); 38 | 39 | // Do the request and store the result in a JSON structure 40 | Json::Value result; 41 | c.Apply(result); 42 | 43 | // Display the JSON answer 44 | std::cout << result << std::endl; 45 | 46 | // Display the content of the local Orthanc instance 47 | OrthancClient::OrthancConnection orthanc("http://localhost:8042"); 48 | 49 | for (unsigned int i = 0; i < orthanc.GetPatientCount(); i++) 50 | { 51 | OrthancClient::Patient& patient = orthanc.GetPatient(i); 52 | std::cout << "Patient: " << patient.GetId() << std::endl; 53 | 54 | for (unsigned int j = 0; j < patient.GetStudyCount(); j++) 55 | { 56 | OrthancClient::Study& study = patient.GetStudy(j); 57 | std::cout << " Study: " << study.GetId() << std::endl; 58 | 59 | for (unsigned int k = 0; k < study.GetSeriesCount(); k++) 60 | { 61 | OrthancClient::Series& series = study.GetSeries(k); 62 | std::cout << " Series: " << series.GetId() << std::endl; 63 | 64 | for (unsigned int l = 0; l < series.GetInstanceCount(); l++) 65 | { 66 | std::cout << " Instance: " << series.GetInstance(l).GetId() << std::endl; 67 | } 68 | } 69 | } 70 | } 71 | 72 | return 0; 73 | } 74 | -------------------------------------------------------------------------------- /Resources/Samples/OrthancCppClient/OrthancCppClient.cmake: -------------------------------------------------------------------------------- 1 | include(${ORTHANC_ROOT}/Resources/CMake/DownloadPackage.cmake) 2 | include(${ORTHANC_ROOT}/Resources/CMake/JsonCppConfiguration.cmake) 3 | include(${ORTHANC_ROOT}/Resources/CMake/LibCurlConfiguration.cmake) 4 | include(${ORTHANC_ROOT}/Resources/CMake/LibPngConfiguration.cmake) 5 | include(${ORTHANC_ROOT}/Resources/CMake/BoostConfiguration.cmake) 6 | 7 | if (${CMAKE_COMPILER_IS_GNUCXX}) 8 | set(CMAKE_C_FLAGS "-Wall -pedantic -Wno-implicit-function-declaration") # --std=c99 makes libcurl not to compile 9 | set(CMAKE_CXX_FLAGS "-Wall -pedantic -Wno-long-long -Wno-variadic-macros") 10 | set(CMAKE_EXE_LINKER_FLAGS "-Wl,--as-needed") 11 | set(CMAKE_SHARED_LINKER_FLAGS "-Wl,--no-undefined") 12 | elseif (${MSVC}) 13 | add_definitions(-D_CRT_SECURE_NO_WARNINGS=1) 14 | endif() 15 | 16 | set(ORTHANC_CPP_CLIENT_SOURCES 17 | ${THIRD_PARTY_SOURCES} 18 | ${ORTHANC_ROOT}/Core/OrthancException.cpp 19 | ${ORTHANC_ROOT}/Core/Enumerations.cpp 20 | ${ORTHANC_ROOT}/Core/Toolbox.cpp 21 | ${ORTHANC_ROOT}/Core/HttpClient.cpp 22 | ${ORTHANC_ROOT}/Core/MultiThreading/ArrayFilledByThreads.cpp 23 | ${ORTHANC_ROOT}/Core/MultiThreading/ThreadedCommandProcessor.cpp 24 | ${ORTHANC_ROOT}/Core/MultiThreading/SharedMessageQueue.cpp 25 | ${ORTHANC_ROOT}/Core/FileFormats/PngReader.cpp 26 | ${ORTHANC_ROOT}/OrthancCppClient/OrthancConnection.cpp 27 | ${ORTHANC_ROOT}/OrthancCppClient/Series.cpp 28 | ${ORTHANC_ROOT}/OrthancCppClient/Study.cpp 29 | ${ORTHANC_ROOT}/OrthancCppClient/Instance.cpp 30 | ${ORTHANC_ROOT}/OrthancCppClient/Patient.cpp 31 | ${ORTHANC_ROOT}/Resources/sha1/sha1.cpp 32 | ${ORTHANC_ROOT}/Resources/md5/md5.c 33 | ${ORTHANC_ROOT}/Resources/base64/base64.cpp 34 | ) 35 | -------------------------------------------------------------------------------- /Resources/Samples/OrthancCppClient/Vtk/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | cmake_minimum_required(VERSION 2.8) 2 | 3 | project(OrthancCppClientTest) 4 | 5 | set(STATIC_BUILD OFF) 6 | set(ORTHANC_ROOT ${CMAKE_SOURCE_DIR}/../../../..) 7 | 8 | include(../OrthancCppClient.cmake) 9 | 10 | find_package(VTK REQUIRED) 11 | include(${VTK_USE_FILE}) 12 | 13 | add_executable(Test 14 | main.cpp 15 | ${ORTHANC_CPP_CLIENT_SOURCES} 16 | ) 17 | 18 | if(VTK_LIBRARIES) 19 | target_link_libraries(Test ${VTK_LIBRARIES}) 20 | else() 21 | target_link_libraries(Test vtkHybrid vtkVolumeRendering) 22 | endif() 23 | 24 | -------------------------------------------------------------------------------- /Resources/Samples/Python/AnonymizeAllPatients.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/python 2 | # -*- coding: utf-8 -*- 3 | 4 | 5 | URL = 'http://localhost:8042' 6 | 7 | # 8 | # This sample code will anonymize all the patients that are stored in 9 | # Orthanc. 10 | # 11 | 12 | import sys 13 | import RestToolbox 14 | 15 | # Loop over the patients 16 | for patient in RestToolbox.DoGet('%s/patients' % URL): 17 | 18 | # Ignore patients whose name starts with "Anonymized", as it is 19 | # the result of a previous anonymization 20 | infos = RestToolbox.DoGet('%s/patients/%s' % (URL, patient)) 21 | name = infos['MainDicomTags']['PatientName'].lower() 22 | if not name.startswith('anonymized'): 23 | 24 | # Trigger the anonymization 25 | RestToolbox.DoPost('%s/patients/%s/anonymize' % (URL, patient), 26 | { 'Keep' : [ 'SeriesDescription', 27 | 'StudyDescription' ] }) 28 | -------------------------------------------------------------------------------- /Resources/Samples/Python/ChangesLoop.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/python 2 | 3 | import time 4 | import sys 5 | import RestToolbox 6 | 7 | 8 | ## 9 | ## Print help message 10 | ## 11 | 12 | if len(sys.argv) != 3: 13 | print(""" 14 | Sample script that continuously monitors the arrival of new DICOM 15 | images into Orthanc (through the Changes API). 16 | 17 | Usage: %s [hostname] [HTTP port] 18 | For instance: %s localhost 8042 19 | """ % (sys.argv[0], sys.argv[0])) 20 | exit(-1) 21 | 22 | URL = 'http://%s:%d' % (sys.argv[1], int(sys.argv[2])) 23 | 24 | 25 | 26 | ## 27 | ## The following function is called each time a new instance is 28 | ## received. 29 | ## 30 | 31 | def NewInstanceReceived(path): 32 | global URL 33 | patientName = RestToolbox.DoGet(URL + path + '/content/PatientName') 34 | 35 | # Remove the possible trailing characters due to DICOM padding 36 | patientName = patientName.strip() 37 | 38 | print 'New instance received for patient "%s": "%s"' % (patientName, path) 39 | 40 | 41 | 42 | ## 43 | ## Main loop that listens to the changes API. 44 | ## 45 | 46 | current = 0 47 | while True: 48 | r = RestToolbox.DoGet(URL + '/changes', { 49 | 'since' : current, 50 | 'limit' : 4 # Retrieve at most 4 changes at once 51 | }) 52 | 53 | for change in r['Changes']: 54 | # We are only interested interested in the arrival of new instances 55 | if change['ChangeType'] == 'NewInstance': 56 | # Call the callback function 57 | path = change['Path'] 58 | NewInstanceReceived(path) 59 | 60 | # Delete the instance once it has been discovered 61 | RestToolbox.DoDelete(URL + path) 62 | 63 | current = r['Last'] 64 | 65 | if r['Done']: 66 | print "Everything has been processed: Waiting..." 67 | time.sleep(1) 68 | -------------------------------------------------------------------------------- /Resources/Samples/Python/DownloadAnonymized.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/python 2 | # -*- coding: utf-8 -*- 3 | 4 | 5 | URL = 'http://localhost:8042' 6 | 7 | # 8 | # This sample code will download a ZIP file for each patient that has 9 | # been anonymized in Orthanc. 10 | # 11 | 12 | import os 13 | import os.path 14 | import sys 15 | import RestToolbox 16 | 17 | # Loop over the patients 18 | for patient in RestToolbox.DoGet('%s/patients' % URL): 19 | 20 | # Ignore patients whose name starts with "Anonymized", as it is 21 | # the result of a previous anonymization 22 | infos = RestToolbox.DoGet('%s/patients/%s' % (URL, patient)) 23 | name = infos['MainDicomTags']['PatientName'].lower() 24 | if name.startswith('anonymized'): 25 | 26 | # Trigger the download 27 | print 'Downloading %s' % name 28 | zipContent = RestToolbox.DoGet('%s/patients/%s/archive' % (URL, patient)) 29 | f = open(os.path.join('/tmp', name + '.zip'), 'wb') 30 | f.write(zipContent) 31 | f.close() 32 | -------------------------------------------------------------------------------- /Resources/Samples/Python/RestToolbox.py: -------------------------------------------------------------------------------- 1 | import httplib2 2 | import json 3 | from urllib import urlencode 4 | 5 | _credentials = None 6 | 7 | def SetCredentials(username, password): 8 | global _credentials 9 | _credentials = (username, password) 10 | 11 | def _SetupCredentials(h): 12 | global _credentials 13 | if _credentials != None: 14 | h.add_credentials(_credentials[0], _credentials[1]) 15 | 16 | def DoGet(uri, data = {}, interpretAsJson = True): 17 | d = '' 18 | if len(data.keys()) > 0: 19 | d = '?' + urlencode(data) 20 | 21 | h = httplib2.Http() 22 | _SetupCredentials(h) 23 | resp, content = h.request(uri + d, 'GET') 24 | if not (resp.status in [ 200 ]): 25 | raise Exception(resp.status) 26 | elif not interpretAsJson: 27 | return content 28 | else: 29 | try: 30 | return json.loads(content) 31 | except: 32 | return content 33 | 34 | 35 | def _DoPutOrPost(uri, method, data, contentType): 36 | h = httplib2.Http() 37 | _SetupCredentials(h) 38 | 39 | if isinstance(data, str): 40 | body = data 41 | if len(contentType) != 0: 42 | headers = { 'content-type' : contentType } 43 | else: 44 | headers = { 'content-type' : 'text/plain' } 45 | else: 46 | body = json.dumps(data) 47 | headers = { 'content-type' : 'application/json' } 48 | 49 | resp, content = h.request( 50 | uri, method, 51 | body = body, 52 | headers = headers) 53 | 54 | if not (resp.status in [ 200, 302 ]): 55 | raise Exception(resp.status) 56 | else: 57 | try: 58 | return json.loads(content) 59 | except: 60 | return content 61 | 62 | 63 | def DoDelete(uri): 64 | h = httplib2.Http() 65 | _SetupCredentials(h) 66 | resp, content = h.request(uri, 'DELETE') 67 | 68 | if not (resp.status in [ 200 ]): 69 | raise Exception(resp.status) 70 | else: 71 | try: 72 | return json.loads(content) 73 | except: 74 | return content 75 | 76 | 77 | def DoPut(uri, data = {}, contentType = ''): 78 | return _DoPutOrPost(uri, 'PUT', data, contentType) 79 | 80 | 81 | def DoPost(uri, data = {}, contentType = ''): 82 | return _DoPutOrPost(uri, 'POST', data, contentType) 83 | -------------------------------------------------------------------------------- /Resources/Samples/RestApi/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | cmake_minimum_required(VERSION 2.8) 2 | 3 | project(RestApiSample) 4 | 5 | include(ExternalProject) 6 | 7 | # Send the toolchain information to the Orthanc 8 | if (CMAKE_TOOLCHAIN_FILE) 9 | set(TOOLCHAIN "-DCMAKE_TOOLCHAIN_FILE=${CMAKE_TOOLCHAIN_FILE}") 10 | endif() 11 | 12 | ExternalProject_Add( 13 | ORTHANC_CORE 14 | 15 | # We use the Orthanc-0.3.1 branch for this sample 16 | DOWNLOAD_COMMAND hg clone https://code.google.com/p/orthanc/ -r Orthanc-0.3.1 17 | 18 | # Optional step, to reuse the third-party downloads 19 | PATCH_COMMAND ${CMAKE_COMMAND} -E create_symlink ${CMAKE_SOURCE_DIR}/../../../ThirdPartyDownloads ThirdPartyDownloads 20 | 21 | PREFIX ${CMAKE_BINARY_DIR}/Orthanc/ 22 | UPDATE_COMMAND "" 23 | SOURCE_DIR ${CMAKE_BINARY_DIR}/Orthanc/src/orthanc/ 24 | CMAKE_COMMAND ${CMAKE_COMMAND} 25 | CMAKE_ARGS -DSTATIC_BUILD=ON -DSTANDALONE_BUILD=ON -DUSE_DYNAMIC_GOOGLE_LOG=OFF -DUSE_DYNAMIC_SQLITE=OFF -DONLY_CORE_LIBRARY=ON -DENABLE_SSL=OFF ${TOOLCHAIN} 26 | BUILD_COMMAND $(MAKE) 27 | INSTALL_COMMAND "" 28 | BUILD_IN_SOURCE 0 29 | ) 30 | 31 | ExternalProject_Get_Property(ORTHANC_CORE source_dir) 32 | include_directories(${source_dir}) 33 | 34 | ExternalProject_Get_Property(ORTHANC_CORE binary_dir) 35 | link_directories(${binary_dir}) 36 | include_directories(${binary_dir}/jsoncpp-src-0.5.0/include) 37 | include_directories(${binary_dir}/glog-0.3.2/src) 38 | include_directories(${binary_dir}/boost_1_49_0) 39 | 40 | 41 | add_executable(RestApiSample 42 | Sample.cpp 43 | ) 44 | 45 | add_dependencies(RestApiSample ORTHANC_CORE) 46 | 47 | target_link_libraries(RestApiSample 48 | # From Orthanc 49 | CoreLibrary 50 | GoogleLog 51 | 52 | # These two libraries are not necessary 53 | #OpenSSL 54 | #Curl 55 | ) 56 | 57 | if (${CMAKE_SYSTEM_NAME} STREQUAL "Linux") 58 | target_link_libraries(RestApiSample pthread) 59 | elseif (${CMAKE_SYSTEM_NAME} STREQUAL "Windows") 60 | add_definitions(-DGOOGLE_GLOG_DLL_DECL=) 61 | target_link_libraries(RestApiSample wsock32) 62 | endif() 63 | -------------------------------------------------------------------------------- /Resources/Samples/RestApiLinuxDynamic/AutoGeneratedCode.cmake: -------------------------------------------------------------------------------- 1 | set(AUTOGENERATED_DIR "${CMAKE_CURRENT_BINARY_DIR}/AUTOGENERATED") 2 | set(AUTOGENERATED_SOURCES) 3 | 4 | file(MAKE_DIRECTORY ${AUTOGENERATED_DIR}) 5 | include_directories(${AUTOGENERATED_DIR}) 6 | 7 | macro(EmbedResources) 8 | # Convert a semicolon separated list to a whitespace separated string 9 | set(SCRIPT_ARGUMENTS) 10 | set(DEPENDENCIES) 11 | set(IS_PATH_NAME false) 12 | foreach(arg ${ARGN}) 13 | if (${IS_PATH_NAME}) 14 | list(APPEND SCRIPT_ARGUMENTS "${arg}") 15 | list(APPEND DEPENDENCIES "${arg}") 16 | set(IS_PATH_NAME false) 17 | else() 18 | list(APPEND SCRIPT_ARGUMENTS "${arg}") 19 | set(IS_PATH_NAME true) 20 | endif() 21 | endforeach() 22 | 23 | set(TARGET_BASE "${AUTOGENERATED_DIR}/EmbeddedResources") 24 | add_custom_command( 25 | OUTPUT 26 | "${TARGET_BASE}.h" 27 | "${TARGET_BASE}.cpp" 28 | COMMAND 29 | python 30 | "${ORTHANC_DIR}/Resources/EmbedResources.py" 31 | "${AUTOGENERATED_DIR}/EmbeddedResources" 32 | ${SCRIPT_ARGUMENTS} 33 | DEPENDS 34 | "${ORTHANC_DIR}/Resources/EmbedResources.py" 35 | ${DEPENDENCIES} 36 | ) 37 | 38 | list(APPEND AUTOGENERATED_SOURCES 39 | "${AUTOGENERATED_DIR}/EmbeddedResources.cpp" 40 | ) 41 | endmacro() 42 | -------------------------------------------------------------------------------- /Resources/Samples/RestApiLinuxDynamic/README.txt: -------------------------------------------------------------------------------- 1 | This folder shows how it is possible to link against the "Core" and 2 | "OrthancCppClient" libraries from the Orthanc distribution. It is 3 | shown how a sample REST API can be created. 4 | 5 | This is the same sample than in folder "../RestApi", but with a 6 | different build script and the use of C++ lambda functions. 7 | 8 | The build script of this folder does not rely on the default CMake 9 | script from Orthanc. It dynamically links against the standard system 10 | Linux libraries. This results in a simpler, standalone build 11 | script. However, it will only work on Linux-based systems. 12 | -------------------------------------------------------------------------------- /Resources/Toolbox.lua: -------------------------------------------------------------------------------- 1 | --[[ PrintRecursive(struct, [limit], [indent]) Recursively print arbitrary data. 2 | Set limit (default 100) to stanch infinite loops. 3 | Indents tables as [KEY] VALUE, nested tables as [KEY] [KEY]...[KEY] VALUE 4 | Set indent ("") to prefix each line: Mytable [KEY] [KEY]...[KEY] VALUE 5 | Source: https://gist.github.com/stuby/5445834#file-rprint-lua 6 | --]] 7 | 8 | function PrintRecursive(s, l, i) -- recursive Print (structure, limit, indent) 9 | l = (l) or 100; i = i or ""; -- default item limit, indent string 10 | if (l<1) then print "ERROR: Item limit reached."; return l-1 end; 11 | local ts = type(s); 12 | if (ts ~= "table") then print (i,ts,s); return l-1 end 13 | print (i,ts); -- print "table" 14 | for k,v in pairs(s) do -- print "[KEY] VALUE" 15 | l = PrintRecursive(v, l, i.."\t["..tostring(k).."]"); 16 | if (l < 0) then break end 17 | end 18 | return l 19 | end 20 | 21 | print('Lua toolbox installed') 22 | -------------------------------------------------------------------------------- /Resources/base64/base64.cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/amirkogithub/orthanc/a49a40f82813a2330390712318cf0610b9777b42/Resources/base64/base64.cpp -------------------------------------------------------------------------------- /Resources/base64/base64.h: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | std::string base64_encode(const std::string& stringToEncode); 4 | std::string base64_decode(const std::string& s); 5 | -------------------------------------------------------------------------------- /Resources/minizip/NOTES: -------------------------------------------------------------------------------- 1 | These files come from the "contrib/minizip" directory in zlib 1.2.7. 2 | -------------------------------------------------------------------------------- /Resources/sha1/Makefile: -------------------------------------------------------------------------------- 1 | # 2 | # Makefile 3 | # 4 | # Copyright (C) 1998, 2009 5 | # Paul E. Jones 6 | # All Rights Reserved. 7 | # 8 | ############################################################################# 9 | # $Id: Makefile 12 2009-06-22 19:34:25Z paulej $ 10 | ############################################################################# 11 | # 12 | # Description: 13 | # This is a makefile for UNIX to build the programs sha, shacmp, and 14 | # shatest 15 | # 16 | # 17 | 18 | CC = g++ 19 | 20 | CFLAGS = -c -O2 -Wall -D_FILE_OFFSET_BITS=64 21 | 22 | LIBS = 23 | 24 | OBJS = sha1.o 25 | 26 | all: sha shacmp shatest 27 | 28 | sha: sha.o $(OBJS) 29 | $(CC) -o $@ sha.o $(OBJS) $(LIBS) 30 | 31 | shacmp: shacmp.o $(OBJS) 32 | $(CC) -o $@ shacmp.o $(OBJS) $(LIBS) 33 | 34 | shatest: shatest.o $(OBJS) 35 | $(CC) -o $@ shatest.o $(OBJS) $(LIBS) 36 | 37 | %.o: %.cpp 38 | $(CC) $(CFLAGS) -o $@ $< 39 | 40 | clean: 41 | $(RM) *.o sha shacmp shatest 42 | -------------------------------------------------------------------------------- /Resources/sha1/Makefile.nt: -------------------------------------------------------------------------------- 1 | # 2 | # Makefile.nt 3 | # 4 | # Copyright (C) 1998, 2009 5 | # Paul E. Jones 6 | # All Rights Reserved. 7 | # 8 | ############################################################################# 9 | # $Id: Makefile.nt 13 2009-06-22 20:20:32Z paulej $ 10 | ############################################################################# 11 | # 12 | # Description: 13 | # This is a makefile for Win32 to build the programs sha, shacmp, and 14 | # shatest 15 | # 16 | # Portability Issues: 17 | # Designed to work with Visual C++ 18 | # 19 | # 20 | 21 | .silent: 22 | 23 | !include 24 | 25 | RM = del /q 26 | 27 | LIBS = $(conlibs) setargv.obj 28 | 29 | CFLAGS = -D _CRT_SECURE_NO_WARNINGS /EHsc /O2 /W3 30 | 31 | OBJS = sha1.obj 32 | 33 | all: sha.exe shacmp.exe shatest.exe 34 | 35 | sha.exe: sha.obj $(OBJS) 36 | $(link) $(conflags) -out:$@ sha.obj $(OBJS) $(LIBS) 37 | 38 | shacmp.exe: shacmp.obj $(OBJS) 39 | $(link) $(conflags) -out:$@ shacmp.obj $(OBJS) $(LIBS) 40 | 41 | shatest.exe: shatest.obj $(OBJS) 42 | $(link) $(conflags) -out:$@ shatest.obj $(OBJS) $(LIBS) 43 | 44 | .cpp.obj: 45 | $(cc) $(CFLAGS) $(cflags) $(cvars) $< 46 | 47 | clean: 48 | $(RM) *.obj sha.exe shacmp.exe shatest.exe 49 | -------------------------------------------------------------------------------- /Resources/sha1/license.txt: -------------------------------------------------------------------------------- 1 | Copyright (C) 1998, 2009 2 | Paul E. Jones 3 | 4 | Freeware Public License (FPL) 5 | 6 | This software is licensed as "freeware." Permission to distribute 7 | this software in source and binary forms, including incorporation 8 | into other products, is hereby granted without a fee. THIS SOFTWARE 9 | IS PROVIDED 'AS IS' AND WITHOUT ANY EXPRESSED OR IMPLIED WARRANTIES, 10 | INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY 11 | AND FITNESS FOR A PARTICULAR PURPOSE. THE AUTHOR SHALL NOT BE HELD 12 | LIABLE FOR ANY DAMAGES RESULTING FROM THE USE OF THIS SOFTWARE, EITHER 13 | DIRECTLY OR INDIRECTLY, INCLUDING, BUT NOT LIMITED TO, LOSS OF DATA 14 | OR DATA BEING RENDERED INACCURATE. 15 | -------------------------------------------------------------------------------- /Resources/sha1/sha1.h: -------------------------------------------------------------------------------- 1 | /* 2 | * sha1.h 3 | * 4 | * Copyright (C) 1998, 2009 5 | * Paul E. Jones 6 | * All Rights Reserved. 7 | * 8 | ***************************************************************************** 9 | * $Id: sha1.h 12 2009-06-22 19:34:25Z paulej $ 10 | ***************************************************************************** 11 | * 12 | * Description: 13 | * This class implements the Secure Hashing Standard as defined 14 | * in FIPS PUB 180-1 published April 17, 1995. 15 | * 16 | * Many of the variable names in this class, especially the single 17 | * character names, were used because those were the names used 18 | * in the publication. 19 | * 20 | * Please read the file sha1.cpp for more information. 21 | * 22 | */ 23 | 24 | #ifndef _SHA1_H_ 25 | #define _SHA1_H_ 26 | 27 | class SHA1 28 | { 29 | 30 | public: 31 | 32 | SHA1(); 33 | virtual ~SHA1(); 34 | 35 | /* 36 | * Re-initialize the class 37 | */ 38 | void Reset(); 39 | 40 | /* 41 | * Returns the message digest 42 | */ 43 | bool Result(unsigned *message_digest_array); 44 | 45 | /* 46 | * Provide input to SHA1 47 | */ 48 | void Input( const unsigned char *message_array, 49 | unsigned length); 50 | void Input( const char *message_array, 51 | unsigned length); 52 | void Input(unsigned char message_element); 53 | void Input(char message_element); 54 | SHA1& operator<<(const char *message_array); 55 | SHA1& operator<<(const unsigned char *message_array); 56 | SHA1& operator<<(const char message_element); 57 | SHA1& operator<<(const unsigned char message_element); 58 | 59 | private: 60 | 61 | /* 62 | * Process the next 512 bits of the message 63 | */ 64 | void ProcessMessageBlock(); 65 | 66 | /* 67 | * Pads the current message block to 512 bits 68 | */ 69 | void PadMessage(); 70 | 71 | /* 72 | * Performs a circular left shift operation 73 | */ 74 | inline unsigned CircularShift(int bits, unsigned word); 75 | 76 | unsigned H[5]; // Message digest buffers 77 | 78 | unsigned Length_Low; // Message length in bits 79 | unsigned Length_High; // Message length in bits 80 | 81 | unsigned char Message_Block[64]; // 512-bit message blocks 82 | int Message_Block_Index; // Index into message block array 83 | 84 | bool Computed; // Is the digest computed? 85 | bool Corrupted; // Is the message digest corruped? 86 | 87 | }; 88 | 89 | #endif 90 | -------------------------------------------------------------------------------- /THANKS: -------------------------------------------------------------------------------- 1 | Orthanc - A Lightweight, RESTful DICOM Server 2 | ============================================= 3 | 4 | Orthanc has originally been written by Sebastien Jodogne 5 | (cf. "AUTHORS" file). This file contains the list of the people that 6 | have further contributed to Orthanc by reporting problems, suggesting 7 | various improvements, or submitting actual code. Please help keep it 8 | complete and exempt or errors. 9 | 10 | 11 | Code contributors 12 | ----------------- 13 | 14 | * Cyril Paulus (cyril.paulus@student.ulg.ac.be), for the build process 15 | and suggestions about the REST API. 16 | * Will Ryder (will.ryder@sydney.edu.au), for improvements with the 17 | handling of series with temporal positions (fMRI and dynamic PET). 18 | * Ryan Walklin (ryanwalklin@gmail.com), for Mac OS X build. 19 | 20 | 21 | Artwork 22 | ------- 23 | 24 | https://code.google.com/p/orthanc/wiki/Logos 25 | 26 | * Benjamin Golinvaux (golinvauxb@gmail.com), for creating the official logo. 27 | * Jean-François Degbomont (jfdegbo@gmail.com), for submitting a logo. 28 | * Martin Jolly (martin.jolly@gmail.com), for submitting a logo. 29 | * Philippe Sepers (sepers.philippe@gmail.com), for submitting a logo. 30 | 31 | 32 | Debian 33 | ------ 34 | 35 | * Mathieu Malaterre (mathieu.malaterre@gmail.com), for sponsoring Orthanc. 36 | * Andreas Tille (andreas@an3as.eu), for help about packaging. 37 | 38 | 39 | Fedora and Red Hat 40 | ------------------ 41 | 42 | * Mario Ceresa (mrceresa@gmail.com), for help about packaging. 43 | -------------------------------------------------------------------------------- /UnitTests/Lua.cpp: -------------------------------------------------------------------------------- 1 | #include "gtest/gtest.h" 2 | 3 | #include "../Core/Lua/LuaFunctionCall.h" 4 | 5 | 6 | TEST(Lua, Simple) 7 | { 8 | Orthanc::LuaContext lua; 9 | lua.Execute(Orthanc::EmbeddedResources::LUA_TOOLBOX); 10 | lua.Execute("a={}"); 11 | lua.Execute("a['x'] = 10"); 12 | lua.Execute("a['y'] = {}"); 13 | lua.Execute("a['y'][1] = 20"); 14 | lua.Execute("a['y'][2] = 20"); 15 | lua.Execute("PrintRecursive(a)"); 16 | 17 | lua.Execute("function f(a) print(a.bool) return a.bool,20,30,40,50,60 end"); 18 | 19 | Json::Value v, vv, o; 20 | //v["a"] = "b"; 21 | v.append("hello"); 22 | v.append("world"); 23 | v.append("42"); 24 | vv.append("sub"); 25 | vv.append("set"); 26 | v.append(vv); 27 | o = Json::objectValue; 28 | o["x"] = 10; 29 | o["y"] = 20; 30 | o["z"] = 20.5f; 31 | v.append(o); 32 | 33 | { 34 | Orthanc::LuaFunctionCall f(lua, "PrintRecursive"); 35 | f.PushJSON(v); 36 | f.Execute(); 37 | } 38 | 39 | { 40 | Orthanc::LuaFunctionCall f(lua, "f"); 41 | f.PushJSON(o); 42 | ASSERT_THROW(f.ExecutePredicate(), Orthanc::LuaException); 43 | } 44 | 45 | o["bool"] = false; 46 | 47 | { 48 | Orthanc::LuaFunctionCall f(lua, "f"); 49 | f.PushJSON(o); 50 | ASSERT_FALSE(f.ExecutePredicate()); 51 | } 52 | 53 | o["bool"] = true; 54 | 55 | { 56 | Orthanc::LuaFunctionCall f(lua, "f"); 57 | f.PushJSON(o); 58 | ASSERT_TRUE(f.ExecutePredicate()); 59 | } 60 | } 61 | 62 | 63 | TEST(Lua, Existing) 64 | { 65 | Orthanc::LuaContext lua; 66 | lua.Execute("a={}"); 67 | lua.Execute("function f() end"); 68 | 69 | ASSERT_TRUE(lua.IsExistingFunction("f")); 70 | ASSERT_FALSE(lua.IsExistingFunction("a")); 71 | ASSERT_FALSE(lua.IsExistingFunction("Dummy")); 72 | } 73 | -------------------------------------------------------------------------------- /UnitTests/RestApi.cpp: -------------------------------------------------------------------------------- 1 | #include "gtest/gtest.h" 2 | 3 | #include 4 | #include 5 | 6 | #include "../Core/RestApi/RestApi.h" 7 | #include "../Core/Uuid.h" 8 | #include "../Core/OrthancException.h" 9 | #include "../Core/Compression/ZlibCompressor.h" 10 | 11 | using namespace Orthanc; 12 | 13 | TEST(RestApi, ParseCookies) 14 | { 15 | HttpHandler::Arguments headers; 16 | HttpHandler::Arguments cookies; 17 | 18 | headers["cookie"] = "a=b;c=d;;;e=f;;g=h;"; 19 | HttpHandler::ParseCookies(cookies, headers); 20 | ASSERT_EQ(4u, cookies.size()); 21 | ASSERT_EQ("b", cookies["a"]); 22 | ASSERT_EQ("d", cookies["c"]); 23 | ASSERT_EQ("f", cookies["e"]); 24 | ASSERT_EQ("h", cookies["g"]); 25 | 26 | headers["cookie"] = " name = value ; name2=value2"; 27 | HttpHandler::ParseCookies(cookies, headers); 28 | ASSERT_EQ(2u, cookies.size()); 29 | ASSERT_EQ("value", cookies["name"]); 30 | ASSERT_EQ("value2", cookies["name2"]); 31 | 32 | headers["cookie"] = " ;;; "; 33 | HttpHandler::ParseCookies(cookies, headers); 34 | ASSERT_EQ(0u, cookies.size()); 35 | 36 | headers["cookie"] = " ; n=v ;; "; 37 | HttpHandler::ParseCookies(cookies, headers); 38 | ASSERT_EQ(1u, cookies.size()); 39 | ASSERT_EQ("v", cookies["n"]); 40 | } 41 | 42 | TEST(RestApi, RestApiPath) 43 | { 44 | RestApiPath::Components args; 45 | UriComponents trail; 46 | 47 | { 48 | RestApiPath uri("/coucou/{abc}/d/*"); 49 | ASSERT_TRUE(uri.Match(args, trail, "/coucou/moi/d/e/f/g")); 50 | ASSERT_EQ(1u, args.size()); 51 | ASSERT_EQ(3u, trail.size()); 52 | ASSERT_EQ("moi", args["abc"]); 53 | ASSERT_EQ("e", trail[0]); 54 | ASSERT_EQ("f", trail[1]); 55 | ASSERT_EQ("g", trail[2]); 56 | 57 | ASSERT_FALSE(uri.Match(args, trail, "/coucou/moi/f")); 58 | ASSERT_TRUE(uri.Match(args, trail, "/coucou/moi/d/")); 59 | ASSERT_FALSE(uri.Match(args, trail, "/a/moi/d")); 60 | ASSERT_FALSE(uri.Match(args, trail, "/coucou/moi")); 61 | } 62 | 63 | { 64 | RestApiPath uri("/coucou/{abc}/d"); 65 | ASSERT_FALSE(uri.Match(args, trail, "/coucou/moi/d/e/f/g")); 66 | ASSERT_TRUE(uri.Match(args, trail, "/coucou/moi/d")); 67 | ASSERT_EQ(1u, args.size()); 68 | ASSERT_EQ(0u, trail.size()); 69 | ASSERT_EQ("moi", args["abc"]); 70 | } 71 | 72 | { 73 | RestApiPath uri("/*"); 74 | ASSERT_TRUE(uri.Match(args, trail, "/a/b/c")); 75 | ASSERT_EQ(0u, args.size()); 76 | ASSERT_EQ(3u, trail.size()); 77 | ASSERT_EQ("a", trail[0]); 78 | ASSERT_EQ("b", trail[1]); 79 | ASSERT_EQ("c", trail[2]); 80 | } 81 | } 82 | -------------------------------------------------------------------------------- /UnitTests/Versions.cpp: -------------------------------------------------------------------------------- 1 | #include "gtest/gtest.h" 2 | 3 | #include 4 | #include 5 | #include 6 | #include 7 | #include 8 | #include 9 | #include 10 | #include 11 | #include 12 | 13 | 14 | TEST(Versions, Zlib) 15 | { 16 | ASSERT_STREQ(zlibVersion(), ZLIB_VERSION); 17 | } 18 | 19 | TEST(Versions, Curl) 20 | { 21 | curl_version_info_data* v = curl_version_info(CURLVERSION_NOW); 22 | ASSERT_STREQ(LIBCURL_VERSION, v->version); 23 | } 24 | 25 | TEST(Versions, Png) 26 | { 27 | ASSERT_EQ(PNG_LIBPNG_VER_MAJOR * 10000 + PNG_LIBPNG_VER_MINOR * 100 + PNG_LIBPNG_VER_RELEASE, 28 | png_access_version_number()); 29 | } 30 | 31 | TEST(Versions, SQLite) 32 | { 33 | // http://www.sqlite.org/capi3ref.html#sqlite3_libversion 34 | assert(sqlite3_libversion_number() == SQLITE_VERSION_NUMBER ); 35 | assert(strcmp(sqlite3_sourceid(), SQLITE_SOURCE_ID) == 0); 36 | assert(strcmp(sqlite3_libversion(), SQLITE_VERSION) == 0); 37 | 38 | // Ensure that the SQLite version is above 3.7.0. 39 | // "sqlite3_create_function_v2" is not defined in previous versions. 40 | ASSERT_GE(SQLITE_VERSION_NUMBER, 3007000); 41 | } 42 | 43 | 44 | TEST(Versions, Lua) 45 | { 46 | // Ensure that the Lua version is above 5.1.0. This version has 47 | // introduced some API changes. 48 | ASSERT_GE(LUA_VERSION_NUM, 501); 49 | } 50 | 51 | 52 | #if ORTHANC_STATIC == 1 53 | TEST(Versions, ZlibStatic) 54 | { 55 | ASSERT_STREQ("1.2.7", zlibVersion()); 56 | } 57 | 58 | TEST(Versions, BoostStatic) 59 | { 60 | ASSERT_STREQ("1_49", BOOST_LIB_VERSION); 61 | } 62 | 63 | TEST(Versions, CurlStatic) 64 | { 65 | curl_version_info_data* v = curl_version_info(CURLVERSION_NOW); 66 | ASSERT_STREQ("7.26.0", v->version); 67 | } 68 | 69 | TEST(Versions, PngStatic) 70 | { 71 | ASSERT_EQ(10512, png_access_version_number()); 72 | ASSERT_STREQ("1.5.12", PNG_LIBPNG_VER_STRING); 73 | } 74 | 75 | TEST(Versions, CurlSslStatic) 76 | { 77 | curl_version_info_data * vinfo = curl_version_info(CURLVERSION_NOW); 78 | 79 | // Check that SSL support is enabled when required 80 | bool curlSupportsSsl = vinfo->features & CURL_VERSION_SSL; 81 | 82 | #if ORTHANC_SSL_ENABLED == 0 83 | ASSERT_FALSE(curlSupportsSsl); 84 | #else 85 | ASSERT_TRUE(curlSupportsSsl); 86 | #endif 87 | } 88 | 89 | TEST(Version, LuaStatic) 90 | { 91 | ASSERT_STREQ("Lua 5.1.5", LUA_RELEASE); 92 | } 93 | #endif 94 | 95 | --------------------------------------------------------------------------------