# HG changeset patch # User Sebastien Jodogne # Date 1528215923 -7200 # Node ID a6d3e45eeff54009f39b81cf06250b57d607b352 # Parent c196d76cb8fac85cb7dd655645e5f21ddcd565d8 SerializationToolbox diff -r c196d76cb8fa -r a6d3e45eeff5 Core/JobsEngine/GenericJobUnserializer.cpp --- a/Core/JobsEngine/GenericJobUnserializer.cpp Tue Jun 05 17:57:49 2018 +0200 +++ b/Core/JobsEngine/GenericJobUnserializer.cpp Tue Jun 05 18:25:23 2018 +0200 @@ -36,6 +36,7 @@ #include "../Logging.h" #include "../OrthancException.h" +#include "../SerializationToolbox.h" #include "Operations/LogJobOperation.h" #include "Operations/NullOperationValue.h" @@ -45,7 +46,7 @@ { IJob* GenericJobUnserializer::UnserializeJob(const Json::Value& source) { - const std::string type = ReadString(source, "Type"); + const std::string type = SerializationToolbox::ReadString(source, "Type"); LOG(ERROR) << "Cannot unserialize job of type: " << type; throw OrthancException(ErrorCode_BadFileFormat); @@ -54,7 +55,7 @@ IJobOperation* GenericJobUnserializer::UnserializeOperation(const Json::Value& source) { - const std::string type = ReadString(source, "Type"); + const std::string type = SerializationToolbox::ReadString(source, "Type"); if (type == "Log") { @@ -70,11 +71,11 @@ JobOperationValue* GenericJobUnserializer::UnserializeValue(const Json::Value& source) { - const std::string type = ReadString(source, "Type"); + const std::string type = SerializationToolbox::ReadString(source, "Type"); if (type == "String") { - return new StringOperationValue(ReadString(source, "Content")); + return new StringOperationValue(SerializationToolbox::ReadString(source, "Content")); } else if (type == "Null") { diff -r c196d76cb8fa -r a6d3e45eeff5 Core/JobsEngine/IJobUnserializer.cpp --- a/Core/JobsEngine/IJobUnserializer.cpp Tue Jun 05 17:57:49 2018 +0200 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,186 +0,0 @@ -/** - * Orthanc - A Lightweight, RESTful DICOM Store - * Copyright (C) 2012-2016 Sebastien Jodogne, Medical Physics - * Department, University Hospital of Liege, Belgium - * Copyright (C) 2017-2018 Osimis S.A., Belgium - * - * This program is free software: you can redistribute it and/or - * modify it under the terms of the GNU General Public License as - * published by the Free Software Foundation, either version 3 of the - * License, or (at your option) any later version. - * - * In addition, as a special exception, the copyright holders of this - * program give permission to link the code of its release with the - * OpenSSL project's "OpenSSL" library (or with modified versions of it - * that use the same license as the "OpenSSL" library), and distribute - * the linked executables. You must obey the GNU General Public License - * in all respects for all of the code used other than "OpenSSL". If you - * modify file(s) with this exception, you may extend this exception to - * your version of the file(s), but you are not obligated to do so. If - * you do not wish to do so, delete this exception statement from your - * version. If you delete this exception statement from all source files - * in the program, then also delete it here. - * - * 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 - * General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - **/ - - -#include "../PrecompiledHeaders.h" -#include "IJobUnserializer.h" - -#include "../OrthancException.h" - -namespace Orthanc -{ - std::string IJobUnserializer::ReadString(const Json::Value& value, - const std::string& field) - { - if (value.type() != Json::objectValue || - !value.isMember(field.c_str()) || - value[field.c_str()].type() != Json::stringValue) - { - throw OrthancException(ErrorCode_BadFileFormat); - } - else - { - return value[field.c_str()].asString(); - } - } - - - int IJobUnserializer::ReadInteger(const Json::Value& value, - const std::string& field) - { - if (value.type() != Json::objectValue || - !value.isMember(field.c_str()) || - (value[field.c_str()].type() != Json::intValue && - value[field.c_str()].type() != Json::uintValue)) - { - throw OrthancException(ErrorCode_BadFileFormat); - } - else - { - return value[field.c_str()].asInt(); - } - } - - - unsigned int IJobUnserializer::ReadUnsignedInteger(const Json::Value& value, - const std::string& field) - { - int tmp = ReadInteger(value, field); - - if (tmp < 0) - { - throw OrthancException(ErrorCode_BadFileFormat); - } - else - { - return static_cast(tmp); - } - } - - - bool IJobUnserializer::ReadBoolean(const Json::Value& value, - const std::string& field) - { - if (value.type() != Json::objectValue || - !value.isMember(field.c_str()) || - value[field.c_str()].type() != Json::booleanValue) - { - throw OrthancException(ErrorCode_BadFileFormat); - } - else - { - return value[field.c_str()].asBool(); - } - } - - - void IJobUnserializer::ReadArrayOfStrings(std::vector& target, - const Json::Value& value, - const std::string& field) - { - if (value.type() != Json::objectValue || - !value.isMember(field.c_str()) || - value[field.c_str()].type() != Json::arrayValue) - { - throw OrthancException(ErrorCode_BadFileFormat); - } - - target.clear(); - target.resize(value.size()); - - const Json::Value arr = value[field.c_str()]; - - for (Json::Value::ArrayIndex i = 0; i < arr.size(); i++) - { - if (arr[i].type() != Json::stringValue) - { - throw OrthancException(ErrorCode_BadFileFormat); - } - else - { - target[i] = arr[i].asString(); - } - } - } - - - void IJobUnserializer::ReadListOfStrings(std::list& target, - const Json::Value& value, - const std::string& field) - { - std::vector tmp; - ReadArrayOfStrings(tmp, value, field); - - target.clear(); - for (size_t i = 0; i < tmp.size(); i++) - { - target.push_back(tmp[i]); - } - } - - - void IJobUnserializer::ReadSetOfStrings(std::set& target, - const Json::Value& value, - const std::string& field) - { - std::vector tmp; - ReadArrayOfStrings(tmp, value, field); - - target.clear(); - for (size_t i = 0; i < tmp.size(); i++) - { - target.insert(tmp[i]); - } - } - - - void IJobUnserializer::WriteArrayOfStrings(Json::Value& target, - const std::vector& values, - const std::string& field) - { - if (target.type() != Json::objectValue || - target.isMember(field.c_str())) - { - throw OrthancException(ErrorCode_BadFileFormat); - } - - Json::Value tmp; - - tmp = Json::arrayValue; - for (size_t i = 0; i < values.size(); i++) - { - tmp.append(values[i]); - } - - target[field] = tmp; - } -} diff -r c196d76cb8fa -r a6d3e45eeff5 Core/JobsEngine/IJobUnserializer.h --- a/Core/JobsEngine/IJobUnserializer.h Tue Jun 05 17:57:49 2018 +0200 +++ b/Core/JobsEngine/IJobUnserializer.h Tue Jun 05 18:25:23 2018 +0200 @@ -53,33 +53,5 @@ virtual IJobOperation* UnserializeOperation(const Json::Value& value) = 0; virtual JobOperationValue* UnserializeValue(const Json::Value& value) = 0; - - static std::string ReadString(const Json::Value& value, - const std::string& field); - - static int ReadInteger(const Json::Value& value, - const std::string& field); - - static unsigned int ReadUnsignedInteger(const Json::Value& value, - const std::string& field); - - static bool ReadBoolean(const Json::Value& value, - const std::string& field); - - static void ReadArrayOfStrings(std::vector& target, - const Json::Value& value, - const std::string& field); - - static void ReadListOfStrings(std::list& target, - const Json::Value& value, - const std::string& field); - - static void ReadSetOfStrings(std::set& target, - const Json::Value& value, - const std::string& field); - - static void WriteArrayOfStrings(Json::Value& target, - const std::vector& values, - const std::string& field); }; } diff -r c196d76cb8fa -r a6d3e45eeff5 Core/JobsEngine/JobsRegistry.cpp --- a/Core/JobsEngine/JobsRegistry.cpp Tue Jun 05 17:57:49 2018 +0200 +++ b/Core/JobsEngine/JobsRegistry.cpp Tue Jun 05 18:25:23 2018 +0200 @@ -37,6 +37,7 @@ #include "../Logging.h" #include "../OrthancException.h" #include "../Toolbox.h" +#include "../SerializationToolbox.h" namespace Orthanc { @@ -265,12 +266,12 @@ pauseScheduled_(false), cancelScheduled_(false) { - id_ = StringToJobState(IJobUnserializer::ReadString(serialized, "ID")); - state_ = StringToJobState(IJobUnserializer::ReadString(serialized, "State")); - priority_ = IJobUnserializer::ReadInteger(serialized, "Priority"); + id_ = StringToJobState(SerializationToolbox::ReadString(serialized, "ID")); + state_ = StringToJobState(SerializationToolbox::ReadString(serialized, "State")); + priority_ = SerializationToolbox::ReadInteger(serialized, "Priority"); creationTime_ = boost::posix_time::from_iso_string - (IJobUnserializer::ReadString(serialized, "CreationTime")); - runtime_ = boost::posix_time::milliseconds(IJobUnserializer::ReadInteger(serialized, "Runtime")); + (SerializationToolbox::ReadString(serialized, "CreationTime")); + runtime_ = boost::posix_time::milliseconds(SerializationToolbox::ReadInteger(serialized, "Runtime")); retryTime_ = creationTime_; diff -r c196d76cb8fa -r a6d3e45eeff5 Core/JobsEngine/SetOfInstancesJob.cpp --- a/Core/JobsEngine/SetOfInstancesJob.cpp Tue Jun 05 17:57:49 2018 +0200 +++ b/Core/JobsEngine/SetOfInstancesJob.cpp Tue Jun 05 18:25:23 2018 +0200 @@ -35,7 +35,7 @@ #include "SetOfInstancesJob.h" #include "../OrthancException.h" -#include "IJobUnserializer.h" +#include "../SerializationToolbox.h" namespace Orthanc { @@ -198,41 +198,24 @@ value["Permissive"] = permissive_; value["Position"] = static_cast(position_); value["Description"] = description_; - - Json::Value v = Json::arrayValue; - - for (size_t i = 0; i < instances_.size(); i++) - { - v.append(instances_[i]); - } - value["Instances"] = v; - - v = Json::arrayValue; - - for (std::set::const_iterator it = failedInstances_.begin(); - it != failedInstances_.end(); ++it) - { - v.append(*it); - } - - value["FailedInstances"] = v; + SerializationToolbox::WriteArrayOfStrings(value, instances_, "Instances"); + SerializationToolbox::WriteSetOfStrings(value, failedInstances_, "FailedInstances"); } SetOfInstancesJob::SetOfInstancesJob(const Json::Value& value) : started_(false), - permissive_(IJobUnserializer::ReadBoolean(value, "Permissive")), - position_(IJobUnserializer::ReadUnsignedInteger(value, "Position")), - description_(IJobUnserializer::ReadString(value, "Description")) + permissive_(SerializationToolbox::ReadBoolean(value, "Permissive")), + position_(SerializationToolbox::ReadUnsignedInteger(value, "Position")), + description_(SerializationToolbox::ReadString(value, "Description")) { - IJobUnserializer::ReadArrayOfStrings(instances_, value, "Instances"); - IJobUnserializer::ReadSetOfStrings(failedInstances_, value, "FailedInstances"); + SerializationToolbox::ReadArrayOfStrings(instances_, value, "Instances"); + SerializationToolbox::ReadSetOfStrings(failedInstances_, value, "FailedInstances"); if (position_ > instances_.size()) { throw OrthancException(ErrorCode_BadFileFormat); } } - } diff -r c196d76cb8fa -r a6d3e45eeff5 Core/SerializationToolbox.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/Core/SerializationToolbox.cpp Tue Jun 05 18:25:23 2018 +0200 @@ -0,0 +1,205 @@ +/** + * Orthanc - A Lightweight, RESTful DICOM Store + * Copyright (C) 2012-2016 Sebastien Jodogne, Medical Physics + * Department, University Hospital of Liege, Belgium + * Copyright (C) 2017-2018 Osimis S.A., Belgium + * + * This program is free software: you can redistribute it and/or + * modify it under the terms of the GNU General Public License as + * published by the Free Software Foundation, either version 3 of the + * License, or (at your option) any later version. + * + * In addition, as a special exception, the copyright holders of this + * program give permission to link the code of its release with the + * OpenSSL project's "OpenSSL" library (or with modified versions of it + * that use the same license as the "OpenSSL" library), and distribute + * the linked executables. You must obey the GNU General Public License + * in all respects for all of the code used other than "OpenSSL". If you + * modify file(s) with this exception, you may extend this exception to + * your version of the file(s), but you are not obligated to do so. If + * you do not wish to do so, delete this exception statement from your + * version. If you delete this exception statement from all source files + * in the program, then also delete it here. + * + * 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 + * General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + **/ + + +#include "PrecompiledHeaders.h" +#include "SerializationToolbox.h" + +#include "OrthancException.h" + +namespace Orthanc +{ + namespace SerializationToolbox + { + std::string ReadString(const Json::Value& value, + const std::string& field) + { + if (value.type() != Json::objectValue || + !value.isMember(field.c_str()) || + value[field.c_str()].type() != Json::stringValue) + { + throw OrthancException(ErrorCode_BadFileFormat); + } + else + { + return value[field.c_str()].asString(); + } + } + + + int ReadInteger(const Json::Value& value, + const std::string& field) + { + if (value.type() != Json::objectValue || + !value.isMember(field.c_str()) || + (value[field.c_str()].type() != Json::intValue && + value[field.c_str()].type() != Json::uintValue)) + { + throw OrthancException(ErrorCode_BadFileFormat); + } + else + { + return value[field.c_str()].asInt(); + } + } + + + unsigned int ReadUnsignedInteger(const Json::Value& value, + const std::string& field) + { + int tmp = ReadInteger(value, field); + + if (tmp < 0) + { + throw OrthancException(ErrorCode_BadFileFormat); + } + else + { + return static_cast(tmp); + } + } + + + bool ReadBoolean(const Json::Value& value, + const std::string& field) + { + if (value.type() != Json::objectValue || + !value.isMember(field.c_str()) || + value[field.c_str()].type() != Json::booleanValue) + { + throw OrthancException(ErrorCode_BadFileFormat); + } + else + { + return value[field.c_str()].asBool(); + } + } + + + void ReadArrayOfStrings(std::vector& target, + const Json::Value& value, + const std::string& field) + { + if (value.type() != Json::objectValue || + !value.isMember(field.c_str()) || + value[field.c_str()].type() != Json::arrayValue) + { + throw OrthancException(ErrorCode_BadFileFormat); + } + + target.clear(); + target.resize(value.size()); + + const Json::Value arr = value[field.c_str()]; + + for (Json::Value::ArrayIndex i = 0; i < arr.size(); i++) + { + if (arr[i].type() != Json::stringValue) + { + throw OrthancException(ErrorCode_BadFileFormat); + } + else + { + target[i] = arr[i].asString(); + } + } + } + + + void ReadListOfStrings(std::list& target, + const Json::Value& value, + const std::string& field) + { + std::vector tmp; + ReadArrayOfStrings(tmp, value, field); + + target.clear(); + for (size_t i = 0; i < tmp.size(); i++) + { + target.push_back(tmp[i]); + } + } + + + void ReadSetOfStrings(std::set& target, + const Json::Value& value, + const std::string& field) + { + std::vector tmp; + ReadArrayOfStrings(tmp, value, field); + + target.clear(); + for (size_t i = 0; i < tmp.size(); i++) + { + target.insert(tmp[i]); + } + } + + + void WriteArrayOfStrings(Json::Value& target, + const std::vector& values, + const std::string& field) + { + if (target.type() != Json::objectValue || + target.isMember(field.c_str())) + { + throw OrthancException(ErrorCode_BadFileFormat); + } + + Json::Value tmp; + + tmp = Json::arrayValue; + for (size_t i = 0; i < values.size(); i++) + { + tmp.append(values[i]); + } + + target[field] = tmp; + } + + + void WriteSetOfStrings(Json::Value& target, + const std::set& values, + const std::string& field) + { + Json::Value v = Json::arrayValue; + + for (std::set::const_iterator it = values.begin(); + it != values.end(); ++it) + { + v.append(*it); + } + + target[field] = v; + } + } +} diff -r c196d76cb8fa -r a6d3e45eeff5 Core/SerializationToolbox.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/Core/SerializationToolbox.h Tue Jun 05 18:25:23 2018 +0200 @@ -0,0 +1,76 @@ +/** + * Orthanc - A Lightweight, RESTful DICOM Store + * Copyright (C) 2012-2016 Sebastien Jodogne, Medical Physics + * Department, University Hospital of Liege, Belgium + * Copyright (C) 2017-2018 Osimis S.A., Belgium + * + * This program is free software: you can redistribute it and/or + * modify it under the terms of the GNU General Public License as + * published by the Free Software Foundation, either version 3 of the + * License, or (at your option) any later version. + * + * In addition, as a special exception, the copyright holders of this + * program give permission to link the code of its release with the + * OpenSSL project's "OpenSSL" library (or with modified versions of it + * that use the same license as the "OpenSSL" library), and distribute + * the linked executables. You must obey the GNU General Public License + * in all respects for all of the code used other than "OpenSSL". If you + * modify file(s) with this exception, you may extend this exception to + * your version of the file(s), but you are not obligated to do so. If + * you do not wish to do so, delete this exception statement from your + * version. If you delete this exception statement from all source files + * in the program, then also delete it here. + * + * 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 + * General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + **/ + + +#pragma once + +#include +#include +#include + +namespace Orthanc +{ + namespace SerializationToolbox + { + std::string ReadString(const Json::Value& value, + const std::string& field); + + int ReadInteger(const Json::Value& value, + const std::string& field); + + unsigned int ReadUnsignedInteger(const Json::Value& value, + const std::string& field); + + bool ReadBoolean(const Json::Value& value, + const std::string& field); + + void ReadArrayOfStrings(std::vector& target, + const Json::Value& value, + const std::string& field); + + void ReadListOfStrings(std::list& target, + const Json::Value& value, + const std::string& field); + + void ReadSetOfStrings(std::set& target, + const Json::Value& value, + const std::string& field); + + void WriteArrayOfStrings(Json::Value& target, + const std::vector& values, + const std::string& field); + + void WriteSetOfStrings(Json::Value& target, + const std::set& values, + const std::string& field); + } +} diff -r c196d76cb8fa -r a6d3e45eeff5 OrthancServer/ServerJobs/Operations/ModifyInstanceOperation.cpp --- a/OrthancServer/ServerJobs/Operations/ModifyInstanceOperation.cpp Tue Jun 05 17:57:49 2018 +0200 +++ b/OrthancServer/ServerJobs/Operations/ModifyInstanceOperation.cpp Tue Jun 05 18:25:23 2018 +0200 @@ -37,6 +37,7 @@ #include "DicomInstanceOperationValue.h" #include "../../../Core/Logging.h" +#include "../../../Core/SerializationToolbox.h" namespace Orthanc { @@ -138,13 +139,13 @@ const Json::Value& serialized) : context_(context) { - if (IJobUnserializer::ReadString(serialized, "Type") != "ModifyInstance" || + if (SerializationToolbox::ReadString(serialized, "Type") != "ModifyInstance" || !serialized.isMember("Modification")) { throw OrthancException(ErrorCode_BadFileFormat); } - origin_ = StringToRequestOrigin(IJobUnserializer::ReadString(serialized, "Origin")); + origin_ = StringToRequestOrigin(SerializationToolbox::ReadString(serialized, "Origin")); modification_.reset(new DicomModification(serialized["Modification"])); } diff -r c196d76cb8fa -r a6d3e45eeff5 OrthancServer/ServerJobs/Operations/StorePeerOperation.cpp --- a/OrthancServer/ServerJobs/Operations/StorePeerOperation.cpp Tue Jun 05 17:57:49 2018 +0200 +++ b/OrthancServer/ServerJobs/Operations/StorePeerOperation.cpp Tue Jun 05 18:25:23 2018 +0200 @@ -39,6 +39,7 @@ #include "../../../Core/Logging.h" #include "../../../Core/OrthancException.h" #include "../../../Core/HttpClient.h" +#include "../../../Core/SerializationToolbox.h" namespace Orthanc { @@ -92,7 +93,7 @@ StorePeerOperation::StorePeerOperation(const Json::Value& serialized) { - if (IJobUnserializer::ReadString(serialized, "Type") != "StorePeer" || + if (SerializationToolbox::ReadString(serialized, "Type") != "StorePeer" || !serialized.isMember("Peer")) { throw OrthancException(ErrorCode_BadFileFormat); diff -r c196d76cb8fa -r a6d3e45eeff5 OrthancServer/ServerJobs/Operations/StoreScuOperation.cpp --- a/OrthancServer/ServerJobs/Operations/StoreScuOperation.cpp Tue Jun 05 17:57:49 2018 +0200 +++ b/OrthancServer/ServerJobs/Operations/StoreScuOperation.cpp Tue Jun 05 18:25:23 2018 +0200 @@ -38,6 +38,7 @@ #include "../../../Core/Logging.h" #include "../../../Core/OrthancException.h" +#include "../../../Core/SerializationToolbox.h" namespace Orthanc { @@ -92,7 +93,7 @@ StoreScuOperation::StoreScuOperation(const Json::Value& serialized) { - if (IJobUnserializer::ReadString(serialized, "Type") != "StoreScu" || + if (SerializationToolbox::ReadString(serialized, "Type") != "StoreScu" || !serialized.isMember("LocalAET")) { throw OrthancException(ErrorCode_BadFileFormat); diff -r c196d76cb8fa -r a6d3e45eeff5 OrthancServer/ServerJobs/Operations/SystemCallOperation.cpp --- a/OrthancServer/ServerJobs/Operations/SystemCallOperation.cpp Tue Jun 05 17:57:49 2018 +0200 +++ b/OrthancServer/ServerJobs/Operations/SystemCallOperation.cpp Tue Jun 05 18:25:23 2018 +0200 @@ -38,6 +38,7 @@ #include "../../../Core/JobsEngine/Operations/StringOperationValue.h" #include "../../../Core/Logging.h" +#include "../../../Core/SerializationToolbox.h" #include "../../../Core/TemporaryFile.h" #include "../../../Core/Toolbox.h" @@ -118,20 +119,20 @@ result = Json::objectValue; result["Type"] = "SystemCall"; result["Command"] = command_; - IJobUnserializer::WriteArrayOfStrings(result, preArguments_, "PreArguments"); - IJobUnserializer::WriteArrayOfStrings(result, postArguments_, "PostArguments"); + SerializationToolbox::WriteArrayOfStrings(result, preArguments_, "PreArguments"); + SerializationToolbox::WriteArrayOfStrings(result, postArguments_, "PostArguments"); } SystemCallOperation::SystemCallOperation(const Json::Value& serialized) { - if (IJobUnserializer::ReadString(serialized, "Type") != "SystemCall") + if (SerializationToolbox::ReadString(serialized, "Type") != "SystemCall") { throw OrthancException(ErrorCode_BadFileFormat); } - command_ = IJobUnserializer::ReadString(serialized, "Command"); - IJobUnserializer::ReadArrayOfStrings(preArguments_, serialized, "PreArguments"); - IJobUnserializer::ReadArrayOfStrings(postArguments_, serialized, "PostArguments"); + command_ = SerializationToolbox::ReadString(serialized, "Command"); + SerializationToolbox::ReadArrayOfStrings(preArguments_, serialized, "PreArguments"); + SerializationToolbox::ReadArrayOfStrings(postArguments_, serialized, "PostArguments"); } } diff -r c196d76cb8fa -r a6d3e45eeff5 OrthancServer/ServerJobs/OrthancJobUnserializer.cpp --- a/OrthancServer/ServerJobs/OrthancJobUnserializer.cpp Tue Jun 05 17:57:49 2018 +0200 +++ b/OrthancServer/ServerJobs/OrthancJobUnserializer.cpp Tue Jun 05 18:25:23 2018 +0200 @@ -36,6 +36,7 @@ #include "../../Core/Logging.h" #include "../../Core/OrthancException.h" +#include "../../Core/SerializationToolbox.h" #include "Operations/DeleteResourceOperation.h" #include "Operations/DicomInstanceOperationValue.h" @@ -54,7 +55,7 @@ IJobOperation* OrthancJobUnserializer::UnserializeOperation(const Json::Value& source) { - const std::string type = ReadString(source, "Type"); + const std::string type = SerializationToolbox::ReadString(source, "Type"); if (type == "DeleteResource") { @@ -85,11 +86,11 @@ JobOperationValue* OrthancJobUnserializer::UnserializeValue(const Json::Value& source) { - const std::string type = ReadString(source, "Type"); + const std::string type = SerializationToolbox::ReadString(source, "Type"); if (type == "DicomInstance") { - return new DicomInstanceOperationValue(context_, ReadString(source, "ID")); + return new DicomInstanceOperationValue(context_, SerializationToolbox::ReadString(source, "ID")); } else { diff -r c196d76cb8fa -r a6d3e45eeff5 Resources/CMake/OrthancFrameworkConfiguration.cmake --- a/Resources/CMake/OrthancFrameworkConfiguration.cmake Tue Jun 05 17:57:49 2018 +0200 +++ b/Resources/CMake/OrthancFrameworkConfiguration.cmake Tue Jun 05 18:25:23 2018 +0200 @@ -139,6 +139,7 @@ ${ORTHANC_ROOT}/Core/Images/ImageBuffer.cpp ${ORTHANC_ROOT}/Core/Images/ImageProcessing.cpp ${ORTHANC_ROOT}/Core/Logging.cpp + ${ORTHANC_ROOT}/Core/SerializationToolbox.cpp ${ORTHANC_ROOT}/Core/Toolbox.cpp ${ORTHANC_ROOT}/Core/WebServiceParameters.cpp ) @@ -499,7 +500,6 @@ ${ORTHANC_ROOT}/Core/Cache/SharedArchive.cpp ${ORTHANC_ROOT}/Core/FileStorage/FilesystemStorage.cpp ${ORTHANC_ROOT}/Core/JobsEngine/GenericJobUnserializer.cpp - ${ORTHANC_ROOT}/Core/JobsEngine/IJobUnserializer.cpp ${ORTHANC_ROOT}/Core/JobsEngine/JobInfo.cpp ${ORTHANC_ROOT}/Core/JobsEngine/JobStatus.cpp ${ORTHANC_ROOT}/Core/JobsEngine/JobStepResult.cpp diff -r c196d76cb8fa -r a6d3e45eeff5 UnitTestsSources/MultiThreadingTests.cpp --- a/UnitTestsSources/MultiThreadingTests.cpp Tue Jun 05 17:57:49 2018 +0200 +++ b/UnitTestsSources/MultiThreadingTests.cpp Tue Jun 05 18:25:23 2018 +0200 @@ -38,6 +38,7 @@ #include "../Core/JobsEngine/JobsEngine.h" #include "../Core/MultiThreading/SharedMessageQueue.h" #include "../Core/OrthancException.h" +#include "../Core/SerializationToolbox.h" #include "../Core/SystemToolbox.h" #include "../Core/Toolbox.h" #include "../OrthancServer/DatabaseWrapper.h" @@ -169,7 +170,7 @@ public: virtual IJob* UnserializeJob(const Json::Value& value) { - if (ReadString(value, "Type") == "DummyInstancesJob") + if (SerializationToolbox::ReadString(value, "Type") == "DummyInstancesJob") { return new DummyInstancesJob(value); }