changeset 3173:096f4a29f223

merge
author Sebastien Jodogne <s.jodogne@gmail.com>
date Tue, 29 Jan 2019 10:34:00 +0100
parents b626fefdb507 (current diff) 81cd9a4f3018 (diff)
children 8ea7c4546c3a
files
diffstat 6 files changed, 70 insertions(+), 42 deletions(-) [+]
line wrap: on
line diff
--- a/Core/HttpServer/HttpOutput.cpp	Tue Jan 29 10:32:21 2019 +0100
+++ b/Core/HttpServer/HttpOutput.cpp	Tue Jan 29 10:34:00 2019 +0100
@@ -177,6 +177,10 @@
       {
         s += "Connection: keep-alive\r\n";
       }
+      else
+      {
+        s += "Connection: close\r\n";
+      }
 
       for (std::list<std::string>::const_iterator
              it = headers_.begin(); it != headers_.end(); ++it)
@@ -435,6 +439,10 @@
       header += "Connection: close\r\n";
 #endif
     }
+    else
+    {
+      header += "Connection: close\r\n";
+    }
 
     // Possibly add the cookies
     for (std::list<std::string>::const_iterator
--- a/NEWS	Tue Jan 29 10:32:21 2019 +0100
+++ b/NEWS	Tue Jan 29 10:34:00 2019 +0100
@@ -1,6 +1,10 @@
 Pending changes in the mainline
 ===============================
 
+
+Version 1.5.3 (2019-01-25)
+==========================
+
 General
 -------
 
@@ -11,6 +15,7 @@
 
 * Don't return tags whose group is below 0x0008 in C-FIND SCP answers
 * Fix compatibility with DICOMweb plugin (allow multipart answers over HTTP Keep-Alive)
+* Fix issue #73 (/modalities/{modalityId}/store raises 500 errors instead of 404)
 * Fix issue #90 (C-Find shall match missing tags to null/empty string)
 * Fix issue #119 (/patients/.../archive returns a 500 when JobsHistorySize is 0)
 * Fix issue #128 (Asynchronous C-MOVE: invalid number of remaining sub-operations)
--- a/OrthancExplorer/explorer.html	Tue Jan 29 10:32:21 2019 +0100
+++ b/OrthancExplorer/explorer.html	Tue Jan 29 10:34:00 2019 +0100
@@ -50,6 +50,14 @@
       </div>
     </div>
     <div data-role="content">
+      <div data-role="content" id="content" style="padding:0px">
+        <p align="center">
+          <a href="http://www.orthanc-server.com/" target="_blank" alt="Orthanc homepage">
+            <img src="orthanc-logo.png" alt="Orthanc" style="max-width:100%" />
+          </a>
+        </p>
+      </div>
+      
       <form data-ajax="false" id="lookup-form">
         <div data-role="fieldcontain">
           <label for="lookup-patient-id">Patient ID:</label>
Binary file OrthancExplorer/orthanc-logo.png has changed
--- a/OrthancServer/OrthancRestApi/OrthancRestModalities.cpp	Tue Jan 29 10:32:21 2019 +0100
+++ b/OrthancServer/OrthancRestApi/OrthancRestModalities.cpp	Tue Jan 29 10:34:00 2019 +0100
@@ -813,7 +813,7 @@
    * DICOM C-Store SCU
    ***************************************************************************/
 
-  static bool GetInstancesToExport(Json::Value& otherArguments,
+  static void GetInstancesToExport(Json::Value& otherArguments,
                                    SetOfInstancesJob& job,
                                    const std::string& remote,
                                    RestApiPostCall& call)
@@ -834,7 +834,7 @@
     else if (!call.ParseJsonRequest(request))
     {
       // Bad JSON request
-      return false;
+      throw OrthancException(ErrorCode_BadFileFormat, "Must provide a JSON value");
     }
 
     if (request.isString())
@@ -843,6 +843,11 @@
       request = Json::arrayValue;
       request.append(item);
     }
+    else if (!request.isArray() &&
+             !request.isObject())
+    {
+      throw OrthancException(ErrorCode_BadFileFormat, "Must provide a JSON object, or a JSON array of strings");
+    }
 
     const Json::Value* resources;
     if (request.isArray())
@@ -854,13 +859,15 @@
       if (request.type() != Json::objectValue ||
           !request.isMember(KEY_RESOURCES))
       {
-        return false;
+        throw OrthancException(ErrorCode_BadFileFormat,
+                               "Missing field in JSON: \"" + std::string(KEY_RESOURCES) + "\"");
       }
 
       resources = &request[KEY_RESOURCES];
       if (!resources->isArray())
       {
-        return false;
+        throw OrthancException(ErrorCode_BadFileFormat,
+                               "JSON field \"" + std::string(KEY_RESOURCES) + "\" must contain an array");
       }
 
       // Copy the remaining arguments
@@ -882,24 +889,24 @@
     {
       if (!(*resources) [i].isString())
       {
-        return false;
+        throw OrthancException(ErrorCode_BadFileFormat,
+                               "Resources to be exported must be specified as a JSON array of strings");
       }
 
       std::string stripped = Toolbox::StripSpaces((*resources) [i].asString());
       if (!Toolbox::IsSHA1(stripped))
       {
-        return false;
+        throw OrthancException(ErrorCode_BadFileFormat,
+                               "This string is not a valid Orthanc identifier: " + stripped);
       }
 
+      context.AddChildInstances(job, stripped);
+
       if (logExportedResources)
       {
         context.GetIndex().LogExportedResource(stripped, remote);
       }
-
-      context.AddChildInstances(job, stripped);
     }
-
-    return true;
   }
 
 
@@ -912,26 +919,25 @@
     Json::Value request;
     std::auto_ptr<DicomModalityStoreJob> job(new DicomModalityStoreJob(context));
 
-    if (GetInstancesToExport(request, *job, remote, call))
-    {
-      std::string localAet = Toolbox::GetJsonStringField
-        (request, "LocalAet", context.GetDefaultLocalApplicationEntityTitle());
-      std::string moveOriginatorAET = Toolbox::GetJsonStringField
-        (request, "MoveOriginatorAet", context.GetDefaultLocalApplicationEntityTitle());
-      int moveOriginatorID = Toolbox::GetJsonIntegerField
-        (request, "MoveOriginatorID", 0 /* By default, not a C-MOVE */);
+    GetInstancesToExport(request, *job, remote, call);
+
+    std::string localAet = Toolbox::GetJsonStringField
+      (request, "LocalAet", context.GetDefaultLocalApplicationEntityTitle());
+    std::string moveOriginatorAET = Toolbox::GetJsonStringField
+      (request, "MoveOriginatorAet", context.GetDefaultLocalApplicationEntityTitle());
+    int moveOriginatorID = Toolbox::GetJsonIntegerField
+      (request, "MoveOriginatorID", 0 /* By default, not a C-MOVE */);
 
-      job->SetLocalAet(localAet);
-      job->SetRemoteModality(MyGetModalityUsingSymbolicName(remote));
+    job->SetLocalAet(localAet);
+    job->SetRemoteModality(MyGetModalityUsingSymbolicName(remote));
 
-      if (moveOriginatorID != 0)
-      {
-        job->SetMoveOriginator(moveOriginatorAET, moveOriginatorID);
-      }
+    if (moveOriginatorID != 0)
+    {
+      job->SetMoveOriginator(moveOriginatorAET, moveOriginatorID);
+    }
 
-      OrthancRestApi::GetApi(call).SubmitCommandsJob
-        (call, job.release(), true /* synchronous by default */, request);
-    }
+    OrthancRestApi::GetApi(call).SubmitCommandsJob
+      (call, job.release(), true /* synchronous by default */, request);
   }
 
 
@@ -1059,22 +1065,21 @@
     Json::Value request;
     std::auto_ptr<OrthancPeerStoreJob> job(new OrthancPeerStoreJob(context));
 
-    if (GetInstancesToExport(request, *job, remote, call))
-    {
-      OrthancConfiguration::ReaderLock lock;
+    GetInstancesToExport(request, *job, remote, call);
+    
+    OrthancConfiguration::ReaderLock lock;
 
-      WebServiceParameters peer;
-      if (lock.GetConfiguration().LookupOrthancPeer(peer, remote))
-      {
-        job->SetPeer(peer);    
-        OrthancRestApi::GetApi(call).SubmitCommandsJob
-          (call, job.release(), true /* synchronous by default */, request);
-      }
-      else
-      {
-        throw OrthancException(ErrorCode_UnknownResource,
-                               "No peer with symbolic name: " + remote);
-      }
+    WebServiceParameters peer;
+    if (lock.GetConfiguration().LookupOrthancPeer(peer, remote))
+    {
+      job->SetPeer(peer);    
+      OrthancRestApi::GetApi(call).SubmitCommandsJob
+        (call, job.release(), true /* synchronous by default */, request);
+    }
+    else
+    {
+      throw OrthancException(ErrorCode_UnknownResource,
+                             "No peer with symbolic name: " + remote);
     }
   }
 
--- a/Resources/DownloadOrthancFramework.cmake	Tue Jan 29 10:32:21 2019 +0100
+++ b/Resources/DownloadOrthancFramework.cmake	Tue Jan 29 10:34:00 2019 +0100
@@ -97,6 +97,8 @@
         set(ORTHANC_FRAMEWORK_MD5 "099671538865e5da96208b37494d6718")
       elseif (ORTHANC_FRAMEWORK_VERSION STREQUAL "1.5.2")
         set(ORTHANC_FRAMEWORK_MD5 "8867050f3e9a1ce6157c1ea7a9433b1b")
+      elseif (ORTHANC_FRAMEWORK_VERSION STREQUAL "1.5.3")
+        set(ORTHANC_FRAMEWORK_MD5 "bf2f5ed1adb8b0fc5f10d278e68e1dfe")
       endif()
     endif()
   endif()