changeset 2127:bfa92c9328d7

cleaning up
author Sebastien Jodogne <s.jodogne@gmail.com>
date Mon, 07 Nov 2016 13:59:36 +0100
parents 03b065778fc3
children 9329ba17a069
files OrthancServer/OrthancRestApi/OrthancRestResources.cpp OrthancServer/ServerContext.cpp OrthancServer/ServerContext.h
diffstat 3 files changed, 16 insertions(+), 4 deletions(-) [+]
line wrap: on
line diff
--- a/OrthancServer/OrthancRestApi/OrthancRestResources.cpp	Mon Nov 07 13:47:21 2016 +0100
+++ b/OrthancServer/OrthancRestApi/OrthancRestResources.cpp	Mon Nov 07 13:59:36 2016 +0100
@@ -215,7 +215,9 @@
     }
     else
     {
-      context.AnswerAttachment(call.GetOutput(), publicId, FileContentType_DicomAsJson);
+      std::string full;
+      context.ReadDicomAsJson(full, publicId);
+      call.GetOutput().AnswerBuffer(full, "application/json");
     }
   }
 
--- a/OrthancServer/ServerContext.cpp	Mon Nov 07 13:47:21 2016 +0100
+++ b/OrthancServer/ServerContext.cpp	Mon Nov 07 13:59:36 2016 +0100
@@ -368,14 +368,21 @@
   }
 
 
+  void ServerContext::ReadDicomAsJson(std::string& result,
+                                      const std::string& instancePublicId)
+  {
+    ReadFile(result, instancePublicId, FileContentType_DicomAsJson, true /* decompress if needed */);
+  }
+
+
   void ServerContext::ReadDicomAsJson(Json::Value& result,
                                       const std::string& instancePublicId)
   {
-    std::string s;
-    ReadFile(s, instancePublicId, FileContentType_DicomAsJson, true /* decompress if needed */);
+    std::string tmp;
+    ReadDicomAsJson(tmp, instancePublicId);
 
     Json::Reader reader;
-    if (!reader.parse(s, result))
+    if (!reader.parse(tmp, result))
     {
       throw OrthancException(ErrorCode_CorruptedFile);
     }
--- a/OrthancServer/ServerContext.h	Mon Nov 07 13:47:21 2016 +0100
+++ b/OrthancServer/ServerContext.h	Mon Nov 07 13:59:36 2016 +0100
@@ -191,6 +191,9 @@
                                      FileContentType attachmentType,
                                      CompressionType compression);
 
+    void ReadDicomAsJson(std::string& result,
+                         const std::string& instancePublicId);
+
     void ReadDicomAsJson(Json::Value& result,
                          const std::string& instancePublicId);