Mercurial > hg > orthanc
comparison OrthancServer/OrthancRestApi/OrthancRestApi.cpp @ 948:e57e08ed510f dicom-rt
integration mainline -> dicom-rt
author | Sebastien Jodogne <s.jodogne@gmail.com> |
---|---|
date | Wed, 25 Jun 2014 13:57:05 +0200 |
parents | c19552f604d5 84513f2ee1f3 |
children |
comparison
equal
deleted
inserted
replaced
767:c19552f604d5 | 948:e57e08ed510f |
---|---|
28 * You should have received a copy of the GNU General Public License | 28 * You should have received a copy of the GNU General Public License |
29 * along with this program. If not, see <http://www.gnu.org/licenses/>. | 29 * along with this program. If not, see <http://www.gnu.org/licenses/>. |
30 **/ | 30 **/ |
31 | 31 |
32 | 32 |
33 #include "../PrecompiledHeadersServer.h" | |
33 #include "OrthancRestApi.h" | 34 #include "OrthancRestApi.h" |
35 | |
36 #include "../DicomModification.h" | |
34 | 37 |
35 #include <glog/logging.h> | 38 #include <glog/logging.h> |
36 | 39 |
37 namespace Orthanc | 40 namespace Orthanc |
38 { | 41 { |
42 void OrthancRestApi::AnswerStoredInstance(RestApi::PostCall& call, | |
43 const std::string& publicId, | |
44 StoreStatus status) | |
45 { | |
46 Json::Value result = Json::objectValue; | |
47 | |
48 if (status != StoreStatus_Failure) | |
49 { | |
50 result["ID"] = publicId; | |
51 result["Path"] = GetBasePath(ResourceType_Instance, publicId); | |
52 } | |
53 | |
54 result["Status"] = EnumerationToString(status); | |
55 call.GetOutput().AnswerJson(result); | |
56 } | |
57 | |
58 | |
59 | |
39 // Upload of DICOM files through HTTP --------------------------------------- | 60 // Upload of DICOM files through HTTP --------------------------------------- |
40 | 61 |
41 static void UploadDicomFile(RestApi::PostCall& call) | 62 static void UploadDicomFile(RestApi::PostCall& call) |
42 { | 63 { |
43 ServerContext& context = OrthancRestApi::GetContext(call); | 64 ServerContext& context = OrthancRestApi::GetContext(call); |
50 | 71 |
51 LOG(INFO) << "Receiving a DICOM file of " << postData.size() << " bytes through HTTP"; | 72 LOG(INFO) << "Receiving a DICOM file of " << postData.size() << " bytes through HTTP"; |
52 | 73 |
53 std::string publicId; | 74 std::string publicId; |
54 StoreStatus status = context.Store(publicId, postData); | 75 StoreStatus status = context.Store(publicId, postData); |
55 Json::Value result = Json::objectValue; | |
56 | 76 |
57 if (status != StoreStatus_Failure) | 77 OrthancRestApi::GetApi(call).AnswerStoredInstance(call, publicId, status); |
58 { | |
59 result["ID"] = publicId; | |
60 result["Path"] = GetBasePath(ResourceType_Instance, publicId); | |
61 } | |
62 | |
63 result["Status"] = EnumerationToString(status); | |
64 call.GetOutput().AnswerJson(result); | |
65 } | 78 } |
66 | 79 |
67 | 80 |
68 | 81 |
69 // Registration of the various REST handlers -------------------------------- | 82 // Registration of the various REST handlers -------------------------------- |