Mercurial > hg > orthanc-dicomweb
changeset 131:17c916a8bc65 dev
use of OrthancPlugins::PluginException troughout the plugin
author | Sebastien Jodogne <s.jodogne@gmail.com> |
---|---|
date | Fri, 24 Jun 2016 11:45:21 +0200 |
parents | f5d135633484 |
children | 972a2cca130d |
files | CMakeLists.txt Plugin/ChunkedBuffer.cpp Plugin/ChunkedBuffer.h Plugin/Configuration.cpp Plugin/Dicom.cpp Plugin/DicomResults.cpp Plugin/DicomResults.h Plugin/DicomWebServers.cpp Plugin/Plugin.cpp Plugin/QidoRs.cpp Plugin/StowRs.cpp Plugin/StowRsClient.cpp Plugin/WadoRs.cpp Plugin/WadoRsRetrieveFrames.cpp Plugin/WadoUri.cpp |
diffstat | 15 files changed, 67 insertions(+), 223 deletions(-) [+] |
line wrap: on
line diff
--- a/CMakeLists.txt Fri Jun 24 11:34:56 2016 +0200 +++ b/CMakeLists.txt Fri Jun 24 11:45:21 2016 +0200 @@ -119,7 +119,6 @@ ${ORTHANC_ROOT}/Core/WebServiceParameters.cpp ${ORTHANC_ROOT}/Plugins/Samples/Common/OrthancPluginCppWrapper.cpp - Plugin/ChunkedBuffer.cpp Plugin/Configuration.cpp Plugin/Dicom.cpp Plugin/DicomResults.cpp
--- a/Plugin/ChunkedBuffer.cpp Fri Jun 24 11:34:56 2016 +0200 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,86 +0,0 @@ -/** - * Orthanc - A Lightweight, RESTful DICOM Store - * Copyright (C) 2012-2016 Sebastien Jodogne, Medical Physics - * Department, University Hospital of Liege, Belgium - * - * This program is free software: you can redistribute it and/or - * modify it under the terms of the GNU Affero General Public License - * as published by the Free Software Foundation, either version 3 of - * the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, but - * WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Affero General Public License for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see <http://www.gnu.org/licenses/>. - **/ - - -#include "ChunkedBuffer.h" - -#include <cassert> -#include <string.h> - - -namespace OrthancPlugins -{ - void ChunkedBuffer::Clear() - { - numBytes_ = 0; - - for (Chunks::iterator it = chunks_.begin(); - it != chunks_.end(); ++it) - { - delete *it; - } - } - - - void ChunkedBuffer::AddChunk(const char* chunkData, - size_t chunkSize) - { - if (chunkSize == 0) - { - return; - } - - assert(chunkData != NULL); - chunks_.push_back(new std::string(chunkData, chunkSize)); - numBytes_ += chunkSize; - } - - - void ChunkedBuffer::AddChunk(const std::string& chunk) - { - if (chunk.size() > 0) - { - AddChunk(&chunk[0], chunk.size()); - } - } - - - void ChunkedBuffer::Flatten(std::string& result) - { - result.resize(numBytes_); - - size_t pos = 0; - for (Chunks::iterator it = chunks_.begin(); - it != chunks_.end(); ++it) - { - assert(*it != NULL); - - size_t s = (*it)->size(); - if (s != 0) - { - memcpy(&result[pos], (*it)->c_str(), s); - pos += s; - } - - delete *it; - } - - chunks_.clear(); - } -}
--- a/Plugin/ChunkedBuffer.h Fri Jun 24 11:34:56 2016 +0200 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,59 +0,0 @@ -/** - * Orthanc - A Lightweight, RESTful DICOM Store - * Copyright (C) 2012-2016 Sebastien Jodogne, Medical Physics - * Department, University Hospital of Liege, Belgium - * - * This program is free software: you can redistribute it and/or - * modify it under the terms of the GNU Affero General Public License - * as published by the Free Software Foundation, either version 3 of - * the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, but - * WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Affero General Public License for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see <http://www.gnu.org/licenses/>. - **/ - - -#pragma once - -#include <list> -#include <string> - -namespace OrthancPlugins -{ - class ChunkedBuffer - { - private: - typedef std::list<std::string*> Chunks; - size_t numBytes_; - Chunks chunks_; - - void Clear(); - - public: - ChunkedBuffer() : numBytes_(0) - { - } - - ~ChunkedBuffer() - { - Clear(); - } - - size_t GetNumBytes() const - { - return numBytes_; - } - - void AddChunk(const char* chunkData, - size_t chunkSize); - - void AddChunk(const std::string& chunk); - - void Flatten(std::string& result); - }; -}
--- a/Plugin/Configuration.cpp Fri Jun 24 11:34:56 2016 +0200 +++ b/Plugin/Configuration.cpp Fri Jun 24 11:45:21 2016 +0200 @@ -316,7 +316,7 @@ if (value.type() != Json::objectValue) { OrthancPlugins::Configuration::LogError("This is not a JSON object"); - throw Orthanc::OrthancException(Orthanc::ErrorCode_BadFileFormat); + throw OrthancPlugins::PluginException(OrthancPluginErrorCode_BadFileFormat); } if (!value.isMember(key)) @@ -330,7 +330,7 @@ { OrthancPlugins::Configuration::LogError("The field \"" + key + "\" of a JSON object is " "not a JSON associative array as expected"); - throw Orthanc::OrthancException(Orthanc::ErrorCode_BadFileFormat); + throw OrthancPlugins::PluginException(OrthancPluginErrorCode_BadFileFormat); } Json::Value::Members names = tmp.getMemberNames(); @@ -341,7 +341,7 @@ { OrthancPlugins::Configuration::LogError("Some value in the associative array \"" + key + "\" is not a string as expected"); - throw Orthanc::OrthancException(Orthanc::ErrorCode_BadFileFormat); + throw OrthancPlugins::PluginException(OrthancPluginErrorCode_BadFileFormat); } else {
--- a/Plugin/Dicom.cpp Fri Jun 24 11:34:56 2016 +0200 +++ b/Plugin/Dicom.cpp Fri Jun 24 11:45:21 2016 +0200 @@ -23,7 +23,6 @@ #include "Plugin.h" #include "ChunkedBuffer.h" -#include "../Orthanc/Core/OrthancException.h" #include "../Orthanc/Core/Toolbox.h" #include <gdcmDictEntry.h> @@ -176,7 +175,7 @@ { /* "GDCM cannot read this DICOM instance of length " + boost::lexical_cast<std::string>(dicom.size()) */ - throw Orthanc::OrthancException(Orthanc::ErrorCode_BadFileFormat); + throw OrthancPlugins::PluginException(OrthancPluginErrorCode_BadFileFormat); } } @@ -244,7 +243,7 @@ { if (!GetDataSet().FindDataElement(tag)) { - throw Orthanc::OrthancException(Orthanc::ErrorCode_InexistentTag); + throw OrthancPlugins::PluginException(OrthancPluginErrorCode_InexistentTag); } const gdcm::DataElement& element = GetDataSet().GetDataElement(tag); @@ -310,7 +309,6 @@ return "RetrieveURL"; } - //throw Orthanc::OrthancException("Unknown keyword for tag: " + FormatTag(tag)); return NULL; } @@ -694,7 +692,7 @@ if (key.find('.') != std::string::npos) { OrthancPlugins::Configuration::LogError("This DICOMweb plugin does not support hierarchical queries: " + key); - throw Orthanc::OrthancException(Orthanc::ErrorCode_NotImplemented); + throw OrthancPlugins::PluginException(OrthancPluginErrorCode_NotImplemented); } if (key.size() == 8 && // This is the DICOMweb convention @@ -734,12 +732,12 @@ if (key.find('.') != std::string::npos) { OrthancPlugins::Configuration::LogError("This QIDO-RS implementation does not support search over sequences: " + key); - throw Orthanc::OrthancException(Orthanc::ErrorCode_NotImplemented); + throw OrthancPlugins::PluginException(OrthancPluginErrorCode_NotImplemented); } else { OrthancPlugins::Configuration::LogError("Illegal tag name in QIDO-RS: " + key); - throw Orthanc::OrthancException(Orthanc::ErrorCode_UnknownDicomTag); + throw OrthancPlugins::PluginException(OrthancPluginErrorCode_UnknownDicomTag); } }
--- a/Plugin/DicomResults.cpp Fri Jun 24 11:34:56 2016 +0200 +++ b/Plugin/DicomResults.cpp Fri Jun 24 11:45:21 2016 +0200 @@ -21,8 +21,8 @@ #include "DicomResults.h" #include "Dicom.h" -#include "../Orthanc/Core/OrthancException.h" #include "../Orthanc/Core/Toolbox.h" +#include "../Orthanc/Plugins/Samples/Common/OrthancPluginCppWrapper.h" #include <boost/lexical_cast.hpp> #include <boost/noncopyable.hpp> @@ -47,7 +47,7 @@ OrthancPluginStartMultipartAnswer(context_, output_, "related", "application/dicom+xml") != 0) { OrthancPlugins::Configuration::LogError("Unable to create a multipart stream of DICOM+XML answers"); - throw Orthanc::OrthancException(Orthanc::ErrorCode_NetworkProtocol); + throw OrthancPlugins::PluginException(OrthancPluginErrorCode_NetworkProtocol); } jsonWriter_.AddChunk("[\n"); @@ -61,7 +61,7 @@ if (OrthancPluginSendMultipartItem(context_, output_, item.c_str(), item.size()) != 0) { OrthancPlugins::Configuration::LogError("Unable to create a multipart stream of DICOM+XML answers"); - throw Orthanc::OrthancException(Orthanc::ErrorCode_NetworkProtocol); + throw OrthancPlugins::PluginException(OrthancPluginErrorCode_NetworkProtocol); } } else @@ -120,7 +120,7 @@ { if (source.type() != Json::objectValue) { - throw Orthanc::OrthancException(Orthanc::ErrorCode_InternalError); + throw OrthancPlugins::PluginException(OrthancPluginErrorCode_InternalError); } Json::Value::Members members = source.getMemberNames(); @@ -133,7 +133,7 @@ !source[members[i]].isMember("Type") || source[members[i]]["Type"].type() != Json::stringValue) { - throw Orthanc::OrthancException(Orthanc::ErrorCode_InternalError); + throw OrthancPlugins::PluginException(OrthancPluginErrorCode_InternalError); } const Json::Value& value = source[members[i]]["Value"]; @@ -213,7 +213,7 @@ if (type != "Sequence" || value.type() != Json::arrayValue) { - throw Orthanc::OrthancException(Orthanc::ErrorCode_InternalError); + throw OrthancPlugins::PluginException(OrthancPluginErrorCode_InternalError); } node["Value"] = Json::arrayValue; @@ -222,7 +222,7 @@ { if (value[i].type() != Json::objectValue) { - throw Orthanc::OrthancException(Orthanc::ErrorCode_InternalError); + throw OrthancPlugins::PluginException(OrthancPluginErrorCode_InternalError); } Json::Value child; @@ -307,14 +307,14 @@ if (type != "Sequence" || value.type() != Json::arrayValue) { - throw Orthanc::OrthancException(Orthanc::ErrorCode_InternalError); + throw OrthancPlugins::PluginException(OrthancPluginErrorCode_InternalError); } for (Json::Value::ArrayIndex i = 0; i < value.size(); i++) { if (value[i].type() != Json::objectValue) { - throw Orthanc::OrthancException(Orthanc::ErrorCode_InternalError); + throw OrthancPlugins::PluginException(OrthancPluginErrorCode_InternalError); } pugi::xml_node child = node.append_child("Item");
--- a/Plugin/DicomResults.h Fri Jun 24 11:34:56 2016 +0200 +++ b/Plugin/DicomResults.h Fri Jun 24 11:45:21 2016 +0200 @@ -37,7 +37,7 @@ OrthancPluginRestOutput* output_; std::string wadoBase_; const gdcm::Dict& dictionary_; - ChunkedBuffer jsonWriter_; // Used for JSON output + Orthanc::ChunkedBuffer jsonWriter_; // Used for JSON output bool isFirst_; bool isXml_; bool isBulkAccessible_;
--- a/Plugin/DicomWebServers.cpp Fri Jun 24 11:34:56 2016 +0200 +++ b/Plugin/DicomWebServers.cpp Fri Jun 24 11:45:21 2016 +0200 @@ -21,7 +21,6 @@ #include "DicomWebServers.h" #include "Configuration.h" -#include "../Orthanc/Core/OrthancException.h" #include "../Orthanc/Core/Toolbox.h" namespace OrthancPlugins @@ -72,7 +71,7 @@ if (!ok) { OrthancPlugins::Configuration::LogError("Cannot parse the \"DicomWeb.Servers\" section of the configuration file"); - throw Orthanc::OrthancException(Orthanc::ErrorCode_BadFileFormat); + throw OrthancPlugins::PluginException(OrthancPluginErrorCode_BadFileFormat); } } @@ -93,7 +92,7 @@ server->second == NULL) { OrthancPlugins::Configuration::LogError("Inexistent server: " + name); - throw Orthanc::OrthancException(Orthanc::ErrorCode_InexistentItem); + throw OrthancPlugins::PluginException(OrthancPluginErrorCode_InexistentItem); } else { @@ -242,7 +241,7 @@ { OrthancPlugins::Configuration::LogError("The GET arguments must be provided in a separate field " "(explicit \"?\" is disallowed): " + resource); - throw Orthanc::OrthancException(Orthanc::ErrorCode_BadFileFormat); + throw OrthancPlugins::PluginException(OrthancPluginErrorCode_BadFileFormat); } uri = resource;
--- a/Plugin/Plugin.cpp Fri Jun 24 11:34:56 2016 +0200 +++ b/Plugin/Plugin.cpp Fri Jun 24 11:45:21 2016 +0200 @@ -41,7 +41,6 @@ const gdcm::Dict* dictionary_ = NULL; -#include "../Orthanc/Core/OrthancException.h" #include <boost/lexical_cast.hpp> @@ -146,7 +145,7 @@ { if (json.type() != Json::objectValue) { - throw Orthanc::OrthancException(Orthanc::ErrorCode_BadFileFormat); + throw OrthancPlugins::PluginException(OrthancPluginErrorCode_BadFileFormat); } else if (!json.isMember(key)) { @@ -156,7 +155,7 @@ else if (json[key].type() != Json::stringValue) { OrthancPlugins::Configuration::LogError("The field \"" + key + "\" in a JSON object should be a string"); - throw Orthanc::OrthancException(Orthanc::ErrorCode_BadFileFormat); + throw OrthancPlugins::PluginException(OrthancPluginErrorCode_BadFileFormat); } else {
--- a/Plugin/QidoRs.cpp Fri Jun 24 11:34:56 2016 +0200 +++ b/Plugin/QidoRs.cpp Fri Jun 24 11:45:21 2016 +0200 @@ -26,7 +26,6 @@ #include "DicomResults.h" #include "Configuration.h" #include "../Orthanc/Core/Toolbox.h" -#include "../Orthanc/Core/OrthancException.h" #include <gdcmTag.h> #include <list> @@ -151,7 +150,7 @@ break; default: - throw Orthanc::OrthancException(Orthanc::ErrorCode_InternalError); + throw OrthancPlugins::PluginException(OrthancPluginErrorCode_InternalError); } } @@ -189,7 +188,7 @@ else { OrthancPlugins::Configuration::LogError("Not a proper value for fuzzy matching (true or false): " + value); - throw Orthanc::OrthancException(Orthanc::ErrorCode_BadRequest); + throw OrthancPlugins::PluginException(OrthancPluginErrorCode_BadRequest); } } else if (key == "includefield") @@ -261,7 +260,7 @@ break; default: - throw Orthanc::OrthancException(Orthanc::ErrorCode_InternalError); + throw OrthancPlugins::PluginException(OrthancPluginErrorCode_InternalError); } result["Expand"] = false; @@ -507,7 +506,7 @@ if (!OrthancPlugins::RestApiPostJson(resources, OrthancPlugins::Configuration::GetContext(), "/tools/find", body) || resources.type() != Json::arrayValue) { - throw Orthanc::OrthancException(Orthanc::ErrorCode_InternalError); + throw OrthancPlugins::PluginException(OrthancPluginErrorCode_InternalError); } typedef std::list< std::pair<std::string, std::string> > ResourcesAndInstances;
--- a/Plugin/StowRs.cpp Fri Jun 24 11:34:56 2016 +0200 +++ b/Plugin/StowRs.cpp Fri Jun 24 11:45:21 2016 +0200 @@ -24,7 +24,6 @@ #include "Configuration.h" #include "Dicom.h" #include "../Orthanc/Core/Toolbox.h" -#include "../Orthanc/Core/OrthancException.h" #include <stdexcept>
--- a/Plugin/StowRsClient.cpp Fri Jun 24 11:34:56 2016 +0200 +++ b/Plugin/StowRsClient.cpp Fri Jun 24 11:45:21 2016 +0200 @@ -28,7 +28,6 @@ #include <boost/lexical_cast.hpp> #include "../Orthanc/Core/ChunkedBuffer.h" -#include "../Orthanc/Core/OrthancException.h" #include "../Orthanc/Core/Toolbox.h" @@ -39,7 +38,7 @@ !instance.isMember("ID") || instance["ID"].type() != Json::stringValue) { - throw Orthanc::OrthancException(Orthanc::ErrorCode_InternalError); + throw OrthancPlugins::PluginException(OrthancPluginErrorCode_InternalError); } else { @@ -72,7 +71,7 @@ { OrthancPlugins::Configuration::LogError("The STOW-RS JSON response from DICOMweb server " + server + " does not contain the mandatory tag " + upper); - throw Orthanc::OrthancException(Orthanc::ErrorCode_NetworkProtocol); + throw OrthancPlugins::PluginException(OrthancPluginErrorCode_NetworkProtocol); } else { @@ -84,7 +83,7 @@ (*value) ["Value"].type() != Json::arrayValue) { OrthancPlugins::Configuration::LogError("Unable to parse STOW-RS JSON response from DICOMweb server " + server); - throw Orthanc::OrthancException(Orthanc::ErrorCode_NetworkProtocol); + throw OrthancPlugins::PluginException(OrthancPluginErrorCode_NetworkProtocol); } result = (*value) ["Value"].size(); @@ -110,7 +109,7 @@ OrthancPlugins::Configuration::LogError("A request to the DICOMweb STOW-RS client must provide a JSON object " "with the field \"" + std::string(RESOURCES) + "\" containing an array of resources to be sent"); - throw Orthanc::OrthancException(Orthanc::ErrorCode_BadFileFormat); + throw OrthancPlugins::PluginException(OrthancPluginErrorCode_BadFileFormat); } OrthancPlugins::ParseAssociativeArray(httpHeaders, body, HTTP_HEADERS); @@ -122,13 +121,13 @@ { if (resources[i].type() != Json::stringValue) { - throw Orthanc::OrthancException(Orthanc::ErrorCode_BadFileFormat); + throw OrthancPlugins::PluginException(OrthancPluginErrorCode_BadFileFormat); } std::string resource = resources[i].asString(); if (resource.empty()) { - throw Orthanc::OrthancException(Orthanc::ErrorCode_UnknownResource); + throw OrthancPlugins::PluginException(OrthancPluginErrorCode_UnknownResource); } Json::Value tmp; @@ -145,7 +144,7 @@ { if (tmp.type() != Json::arrayValue) { - throw Orthanc::OrthancException(Orthanc::ErrorCode_InternalError); + throw OrthancPlugins::PluginException(OrthancPluginErrorCode_InternalError); } for (Json::Value::ArrayIndex j = 0; j < tmp.size(); j++) @@ -155,7 +154,7 @@ } else { - throw Orthanc::OrthancException(Orthanc::ErrorCode_UnknownResource); + throw OrthancPlugins::PluginException(OrthancPluginErrorCode_UnknownResource); } } } @@ -193,7 +192,7 @@ !response.isMember("00081199")) { OrthancPlugins::Configuration::LogError("Unable to parse STOW-RS JSON response from DICOMweb server " + server.GetUrl()); - throw Orthanc::OrthancException(Orthanc::ErrorCode_NetworkProtocol); + throw OrthancPlugins::PluginException(OrthancPluginErrorCode_NetworkProtocol); } size_t size; @@ -203,7 +202,7 @@ OrthancPlugins::Configuration::LogError("The STOW-RS server was only able to receive " + boost::lexical_cast<std::string>(size) + " instances out of " + boost::lexical_cast<std::string>(countInstances)); - throw Orthanc::OrthancException(Orthanc::ErrorCode_NetworkProtocol); + throw OrthancPlugins::PluginException(OrthancPluginErrorCode_NetworkProtocol); } if (GetSequenceSize(size, response, "00081198", false, server.GetUrl()) && @@ -212,7 +211,7 @@ OrthancPlugins::Configuration::LogError("The response from the STOW-RS server contains " + boost::lexical_cast<std::string>(size) + " items in its Failed SOP Sequence (0008,1198) tag"); - throw Orthanc::OrthancException(Orthanc::ErrorCode_NetworkProtocol); + throw OrthancPlugins::PluginException(OrthancPluginErrorCode_NetworkProtocol); } if (GetSequenceSize(size, response, "0008119A", false, server.GetUrl()) && @@ -221,7 +220,7 @@ OrthancPlugins::Configuration::LogError("The response from the STOW-RS server contains " + boost::lexical_cast<std::string>(size) + " items in its Other Failures Sequence (0008,119A) tag"); - throw Orthanc::OrthancException(Orthanc::ErrorCode_NetworkProtocol); + throw OrthancPlugins::PluginException(OrthancPluginErrorCode_NetworkProtocol); } countInstances = 0; @@ -235,7 +234,7 @@ { if (request->groupsCount != 1) { - throw Orthanc::OrthancException(Orthanc::ErrorCode_BadRequest); + throw OrthancPlugins::PluginException(OrthancPluginErrorCode_BadRequest); } if (request->method != OrthancPluginHttpMethod_Post) @@ -257,7 +256,7 @@ catch (...) { OrthancPluginFreeString(OrthancPlugins::Configuration::GetContext(), uuid); - throw Orthanc::OrthancException(Orthanc::ErrorCode_NotEnoughMemory); + throw OrthancPlugins::PluginException(OrthancPluginErrorCode_NotEnoughMemory); } OrthancPluginFreeString(OrthancPlugins::Configuration::GetContext(), uuid);
--- a/Plugin/WadoRs.cpp Fri Jun 24 11:34:56 2016 +0200 +++ b/Plugin/WadoRs.cpp Fri Jun 24 11:45:21 2016 +0200 @@ -24,7 +24,6 @@ #include "Dicom.h" #include "DicomResults.h" #include "../Orthanc/Core/Toolbox.h" -#include "../Orthanc/Core/OrthancException.h" #include <boost/lexical_cast.hpp> #include <memory> @@ -183,7 +182,7 @@ if (OrthancPluginStartMultipartAnswer(OrthancPlugins::Configuration::GetContext(), output, "related", "application/dicom")) { - throw Orthanc::OrthancException(Orthanc::ErrorCode_NetworkProtocol); + throw OrthancPlugins::PluginException(OrthancPluginErrorCode_NetworkProtocol); } for (Json::Value::ArrayIndex i = 0; i < instances.size(); i++) @@ -193,7 +192,7 @@ if (OrthancPlugins::RestApiGetString(dicom, OrthancPlugins::Configuration::GetContext(), uri) && OrthancPluginSendMultipartItem(OrthancPlugins::Configuration::GetContext(), output, dicom.c_str(), dicom.size()) != 0) { - throw Orthanc::OrthancException(Orthanc::ErrorCode_InternalError); + throw OrthancPlugins::PluginException(OrthancPluginErrorCode_InternalError); } } } @@ -425,14 +424,14 @@ { if (OrthancPluginStartMultipartAnswer(OrthancPlugins::Configuration::GetContext(), output, "related", "application/dicom")) { - throw Orthanc::OrthancException(Orthanc::ErrorCode_NetworkProtocol); + throw OrthancPlugins::PluginException(OrthancPluginErrorCode_NetworkProtocol); } std::string dicom; if (OrthancPlugins::RestApiGetString(dicom, OrthancPlugins::Configuration::GetContext(), uri + "/file") && OrthancPluginSendMultipartItem(OrthancPlugins::Configuration::GetContext(), output, dicom.c_str(), dicom.size()) != 0) { - throw Orthanc::OrthancException(Orthanc::ErrorCode_NetworkProtocol); + throw OrthancPlugins::PluginException(OrthancPluginErrorCode_NetworkProtocol); } } } @@ -598,7 +597,7 @@ if (OrthancPluginStartMultipartAnswer(OrthancPlugins::Configuration::GetContext(), output, "related", "application/octet-stream") != 0 || OrthancPluginSendMultipartItem(OrthancPlugins::Configuration::GetContext(), output, result.c_str(), result.size()) != 0) { - throw Orthanc::OrthancException(Orthanc::ErrorCode_Plugin); + throw OrthancPlugins::PluginException(OrthancPluginErrorCode_Plugin); } } else
--- a/Plugin/WadoRsRetrieveFrames.cpp Fri Jun 24 11:34:56 2016 +0200 +++ b/Plugin/WadoRsRetrieveFrames.cpp Fri Jun 24 11:45:21 2016 +0200 @@ -21,7 +21,6 @@ #include "WadoRs.h" #include "../Orthanc/Core/Toolbox.h" -#include "../Orthanc/Core/OrthancException.h" #include "Dicom.h" #include "Plugin.h" @@ -69,7 +68,7 @@ if (tokens[0] != "multipart/related") { - throw Orthanc::OrthancException(Orthanc::ErrorCode_ParameterOutOfRange); + throw OrthancPlugins::PluginException(OrthancPluginErrorCode_ParameterOutOfRange); } std::string type("application/octet-stream"); @@ -82,7 +81,7 @@ if (parsed.size() != 2) { - throw Orthanc::OrthancException(Orthanc::ErrorCode_BadRequest); + throw OrthancPlugins::PluginException(OrthancPluginErrorCode_BadRequest); } if (parsed[0] == "type") @@ -106,7 +105,7 @@ { OrthancPlugins::Configuration::LogError("DICOMweb RetrieveFrames: Cannot specify a transfer syntax (" + transferSyntax + ") for default Little Endian uncompressed pixel data"); - throw Orthanc::OrthancException(Orthanc::ErrorCode_BadRequest); + throw OrthancPlugins::PluginException(OrthancPluginErrorCode_BadRequest); } } else @@ -165,7 +164,7 @@ { OrthancPlugins::Configuration::LogError("DICOMweb RetrieveFrames: Transfer syntax \"" + transferSyntax + "\" is incompatible with media type \"" + type + "\""); - throw Orthanc::OrthancException(Orthanc::ErrorCode_BadRequest); + throw OrthancPlugins::PluginException(OrthancPluginErrorCode_BadRequest); } } } @@ -200,7 +199,7 @@ if (frame <= 0) { OrthancPlugins::Configuration::LogError("Invalid frame number (must be > 0): " + tokens[i]); - throw Orthanc::OrthancException(Orthanc::ErrorCode_ParameterOutOfRange); + throw OrthancPlugins::PluginException(OrthancPluginErrorCode_ParameterOutOfRange); } frames.push_back(static_cast<unsigned int>(frame - 1)); @@ -250,7 +249,7 @@ return "image/dicom+jpx; transfer-syntax=1.2.840.10008.1.2.4.93"; default: - throw Orthanc::OrthancException(Orthanc::ErrorCode_InternalError); + throw OrthancPlugins::PluginException(OrthancPluginErrorCode_InternalError); } } @@ -276,7 +275,7 @@ if (error != OrthancPluginErrorCode_Success) { - throw Orthanc::OrthancException(Orthanc::ErrorCode_NetworkProtocol); + throw OrthancPlugins::PluginException(OrthancPluginErrorCode_NetworkProtocol); } } @@ -290,7 +289,7 @@ { if (!dicom.GetDataSet().FindDataElement(OrthancPlugins::DICOM_TAG_PIXEL_DATA)) { - throw Orthanc::OrthancException(Orthanc::ErrorCode_IncompatibleImageFormat); + throw OrthancPlugins::PluginException(OrthancPluginErrorCode_IncompatibleImageFormat); } const gdcm::DataElement& pixelData = dicom.GetDataSet().GetDataElement(OrthancPlugins::DICOM_TAG_PIXEL_DATA); @@ -308,7 +307,7 @@ if (pixelData.GetByteValue() == NULL) { OrthancPlugins::Configuration::LogError("Image was not properly decoded"); - throw Orthanc::OrthancException(Orthanc::ErrorCode_InternalError); + throw OrthancPlugins::PluginException(OrthancPluginErrorCode_InternalError); } int width, height, bits; @@ -317,14 +316,14 @@ !dicom.GetIntegerTag(width, *dictionary_, OrthancPlugins::DICOM_TAG_COLUMNS) || !dicom.GetIntegerTag(bits, *dictionary_, OrthancPlugins::DICOM_TAG_BITS_ALLOCATED)) { - throw Orthanc::OrthancException(Orthanc::ErrorCode_BadFileFormat); + throw OrthancPlugins::PluginException(OrthancPluginErrorCode_BadFileFormat); } size_t frameSize = height * width * bits / 8; if (pixelData.GetByteValue()->GetLength() % frameSize != 0) { - throw Orthanc::OrthancException(Orthanc::ErrorCode_InternalError); + throw OrthancPlugins::PluginException(OrthancPluginErrorCode_InternalError); } size_t framesCount = pixelData.GetByteValue()->GetLength() / frameSize; @@ -348,7 +347,7 @@ { OrthancPlugins::Configuration::LogError("Trying to access frame number " + boost::lexical_cast<std::string>(*frame + 1) + " of an image with " + boost::lexical_cast<std::string>(framesCount) + " frames"); - throw Orthanc::OrthancException(Orthanc::ErrorCode_ParameterOutOfRange); + throw OrthancPlugins::PluginException(OrthancPluginErrorCode_ParameterOutOfRange); } else { @@ -381,7 +380,7 @@ " of an image with " + boost::lexical_cast<std::string>(fragments->GetNumberOfFragments()) + " frames"); - throw Orthanc::OrthancException(Orthanc::ErrorCode_ParameterOutOfRange); + throw OrthancPlugins::PluginException(OrthancPluginErrorCode_ParameterOutOfRange); } else { @@ -471,14 +470,14 @@ if (!reader.Read()) { OrthancPlugins::Configuration::LogError("Cannot decode the image"); - throw Orthanc::OrthancException(Orthanc::ErrorCode_BadFileFormat); + throw OrthancPlugins::PluginException(OrthancPluginErrorCode_BadFileFormat); } change.SetInput(reader.GetImage()); if (!change.Change()) { OrthancPlugins::Configuration::LogError("Cannot change the transfer syntax of the image"); - throw Orthanc::OrthancException(Orthanc::ErrorCode_InternalError); + throw OrthancPlugins::PluginException(OrthancPluginErrorCode_InternalError); } gdcm::ImageWriter writer; @@ -489,7 +488,7 @@ writer.SetStream(ss); if (!writer.Write()) { - throw Orthanc::OrthancException(Orthanc::ErrorCode_NotEnoughMemory); + throw OrthancPlugins::PluginException(OrthancPluginErrorCode_NotEnoughMemory); } OrthancPlugins::ParsedDicomFile transcoded(ss.str());
--- a/Plugin/WadoUri.cpp Fri Jun 24 11:34:56 2016 +0200 +++ b/Plugin/WadoUri.cpp Fri Jun 24 11:45:21 2016 +0200 @@ -21,7 +21,6 @@ #include "WadoUri.h" #include "Plugin.h" -#include "../Orthanc/Core/OrthancException.h" #include "Configuration.h" #include <string> @@ -158,7 +157,7 @@ else { OrthancPlugins::Configuration::LogError("WADO-URI: Unable to retrieve DICOM file from " + uri); - throw Orthanc::OrthancException(Orthanc::ErrorCode_Plugin); + throw OrthancPlugins::PluginException(OrthancPluginErrorCode_Plugin); } } @@ -190,7 +189,7 @@ } else { - throw Orthanc::OrthancException(Orthanc::ErrorCode_Plugin); + throw OrthancPlugins::PluginException(OrthancPluginErrorCode_Plugin); } } @@ -202,7 +201,7 @@ std::string png; if (!RetrievePngPreview(png, instance)) { - throw Orthanc::OrthancException(Orthanc::ErrorCode_Plugin); + throw OrthancPlugins::PluginException(OrthancPluginErrorCode_Plugin); } // Decode the PNG file @@ -237,7 +236,7 @@ std::string contentType = "image/jpg"; // By default, JPEG image will be returned if (!LocateInstance(instance, contentType, request)) { - throw Orthanc::OrthancException(Orthanc::ErrorCode_UnknownResource); + throw OrthancPlugins::PluginException(OrthancPluginErrorCode_UnknownResource); } if (contentType == "application/dicom") @@ -256,6 +255,6 @@ else { OrthancPlugins::Configuration::LogError("WADO-URI: Unsupported content type: \"" + contentType + "\""); - throw Orthanc::OrthancException(Orthanc::ErrorCode_BadRequest); + throw OrthancPlugins::PluginException(OrthancPluginErrorCode_BadRequest); } }