Mercurial > hg > orthanc
changeset 1997:f9f2aa1cc594
"MoveOriginatorID" can be specified for /modalities/.../store
author | Sebastien Jodogne <s.jodogne@gmail.com> |
---|---|
date | Wed, 25 May 2016 11:50:35 +0200 |
parents | 66957f5c69ab |
children | 9b61701c35f2 |
files | NEWS OrthancServer/DicomProtocol/DicomUserConnection.cpp OrthancServer/DicomProtocol/DicomUserConnection.h OrthancServer/OrthancRestApi/OrthancRestModalities.cpp OrthancServer/Scheduler/StoreScuCommand.cpp OrthancServer/Scheduler/StoreScuCommand.h |
diffstat | 6 files changed, 59 insertions(+), 23 deletions(-) [+] |
line wrap: on
line diff
--- a/NEWS Wed May 25 07:24:10 2016 +0200 +++ b/NEWS Wed May 25 11:50:35 2016 +0200 @@ -31,6 +31,11 @@ * Access to the HTTP headers in the "IncomingHttpRequestFilter()" callback +REST API +-------- + +* "MoveOriginatorID" can be specified for /modalities/.../store + Maintenance -----------
--- a/OrthancServer/DicomProtocol/DicomUserConnection.cpp Wed May 25 07:24:10 2016 +0200 +++ b/OrthancServer/DicomProtocol/DicomUserConnection.cpp Wed May 25 11:50:35 2016 +0200 @@ -151,7 +151,7 @@ void Store(DcmInputStream& is, DicomUserConnection& connection, - uint16_t moveMessageID); + uint16_t moveOriginatorID); }; @@ -256,7 +256,7 @@ void DicomUserConnection::PImpl::Store(DcmInputStream& is, DicomUserConnection& connection, - uint16_t moveMessageID) + uint16_t moveOriginatorID) { CheckIsOpen(); @@ -342,9 +342,9 @@ connection.GetLocalApplicationEntityTitle().c_str(), DIC_AE_LEN); request.opts = O_STORE_MOVEORIGINATORAETITLE; - if (moveMessageID != 0) + if (moveOriginatorID != 0) { - request.MoveOriginatorID = moveMessageID; // The type DIC_US is an alias for uint16_t + request.MoveOriginatorID = moveOriginatorID; // The type DIC_US is an alias for uint16_t request.opts |= O_STORE_MOVEORIGINATORID; } @@ -939,7 +939,7 @@ void DicomUserConnection::Store(const char* buffer, size_t size, - uint16_t moveMessageID) + uint16_t moveOriginatorID) { // Prepare an input stream for the memory buffer DcmInputBufferStream is; @@ -947,24 +947,24 @@ is.setBuffer(buffer, size); is.setEos(); - pimpl_->Store(is, *this, moveMessageID); + pimpl_->Store(is, *this, moveOriginatorID); } void DicomUserConnection::Store(const std::string& buffer, - uint16_t moveMessageID) + uint16_t moveOriginatorID) { if (buffer.size() > 0) - Store(reinterpret_cast<const char*>(&buffer[0]), buffer.size(), moveMessageID); + Store(reinterpret_cast<const char*>(&buffer[0]), buffer.size(), moveOriginatorID); else - Store(NULL, 0, moveMessageID); + Store(NULL, 0, moveOriginatorID); } void DicomUserConnection::StoreFile(const std::string& path, - uint16_t moveMessageID) + uint16_t moveOriginatorID) { // Prepare an input stream for the file DcmInputFileStream is(path.c_str()); - pimpl_->Store(is, *this, moveMessageID); + pimpl_->Store(is, *this, moveOriginatorID); } bool DicomUserConnection::Echo()
--- a/OrthancServer/DicomProtocol/DicomUserConnection.h Wed May 25 07:24:10 2016 +0200 +++ b/OrthancServer/DicomProtocol/DicomUserConnection.h Wed May 25 11:50:35 2016 +0200 @@ -135,13 +135,13 @@ void Store(const char* buffer, size_t size, - uint16_t moveMessageID); + uint16_t moveOriginatorID); void Store(const std::string& buffer, - uint16_t moveMessageID); + uint16_t moveOriginatorID); void StoreFile(const std::string& path, - uint16_t moveMessageID); + uint16_t moveOriginatorID); void Find(DicomFindAnswers& result, ResourceType level,
--- a/OrthancServer/OrthancRestApi/OrthancRestModalities.cpp Wed May 25 07:24:10 2016 +0200 +++ b/OrthancServer/OrthancRestApi/OrthancRestModalities.cpp Wed May 25 11:50:35 2016 +0200 @@ -683,10 +683,41 @@ return; } + static const char* LOCAL_AET = "LocalAet"; std::string localAet = context.GetDefaultLocalApplicationEntityTitle(); - if (request.isMember("LocalAet")) + if (request.type() == Json::objectValue && + request.isMember(LOCAL_AET)) { - localAet = request["LocalAet"].asString(); + if (request[LOCAL_AET].type() == Json::stringValue) + { + localAet = request[LOCAL_AET].asString(); + } + else + { + throw OrthancException(ErrorCode_BadFileFormat); + } + } + + uint16_t moveOriginatorID = 0; /* By default, not a C-MOVE */ + + static const char* MOVE_ORIGINATOR_ID = "MoveOriginatorID"; + if (request.type() == Json::objectValue && + request.isMember(MOVE_ORIGINATOR_ID)) + { + if (request[MOVE_ORIGINATOR_ID].type() != Json::intValue) + { + throw OrthancException(ErrorCode_BadFileFormat); + } + + int v = request[MOVE_ORIGINATOR_ID].asInt(); + if (v <= 0 || v >= 65536) + { + throw OrthancException(ErrorCode_ParameterOutOfRange); + } + else + { + moveOriginatorID = boost::lexical_cast<uint16_t>(v); + } } RemoteModalityParameters p = Configuration::GetModalityUsingSymbolicName(remote); @@ -696,7 +727,7 @@ it = instances.begin(); it != instances.end(); ++it) { job.AddCommand(new StoreScuCommand(context, localAet, p, false, - 0 /* not a C-MOVE */)).AddInput(*it); + moveOriginatorID)).AddInput(*it); } job.SetDescription("HTTP request: Store-SCU to peer \"" + remote + "\"");
--- a/OrthancServer/Scheduler/StoreScuCommand.cpp Wed May 25 07:24:10 2016 +0200 +++ b/OrthancServer/Scheduler/StoreScuCommand.cpp Wed May 25 11:50:35 2016 +0200 @@ -41,12 +41,12 @@ const std::string& localAet, const RemoteModalityParameters& modality, bool ignoreExceptions, - uint16_t moveMessageID) : + uint16_t moveOriginatorID) : context_(context), modality_(modality), ignoreExceptions_(ignoreExceptions), localAet_(localAet), - moveMessageID_(moveMessageID) + moveOriginatorID_(moveOriginatorID) { } @@ -66,7 +66,7 @@ std::string dicom; context_.ReadFile(dicom, *it, FileContentType_Dicom); - locker.GetConnection().Store(dicom, moveMessageID_); + locker.GetConnection().Store(dicom, moveOriginatorID_); // Only chain with other commands if this command succeeds outputs.push_back(*it);
--- a/OrthancServer/Scheduler/StoreScuCommand.h Wed May 25 07:24:10 2016 +0200 +++ b/OrthancServer/Scheduler/StoreScuCommand.h Wed May 25 11:50:35 2016 +0200 @@ -44,15 +44,15 @@ RemoteModalityParameters modality_; bool ignoreExceptions_; std::string localAet_; - uint16_t moveMessageID_; + uint16_t moveOriginatorID_; public: StoreScuCommand(ServerContext& context, const std::string& localAet, const RemoteModalityParameters& modality, bool ignoreExceptions, - uint16_t moveMessageID /* only makes sense if this - command results from a C-MOVE */); + uint16_t moveOriginatorID /* only makes sense if this + command results from a C-MOVE */); virtual bool Apply(ListOfStrings& outputs, const ListOfStrings& inputs);