comparison OrthancServer/OrthancRestApi.cpp @ 187:8e673a65564d

refactoring of storing new instances
author Sebastien Jodogne <s.jodogne@gmail.com>
date Mon, 12 Nov 2012 17:29:11 +0100
parents 93e1b0e3b83a
children b6cef9d45cc3
comparison
equal deleted inserted replaced
186:f68c039b0571 187:8e673a65564d
131 DcmFileFormat dicomFile; 131 DcmFileFormat dicomFile;
132 if (dicomFile.read(is).good()) 132 if (dicomFile.read(is).good())
133 { 133 {
134 DicomMap dicomSummary; 134 DicomMap dicomSummary;
135 FromDcmtkBridge::Convert(dicomSummary, *dicomFile.getDataset()); 135 FromDcmtkBridge::Convert(dicomSummary, *dicomFile.getDataset());
136 136
137 DicomInstanceHasher hasher(dicomSummary);
138
137 Json::Value dicomJson; 139 Json::Value dicomJson;
138 FromDcmtkBridge::ToJson(dicomJson, *dicomFile.getDataset()); 140 FromDcmtkBridge::ToJson(dicomJson, *dicomFile.getDataset());
139 141
140 std::string instanceUuid;
141 StoreStatus status = StoreStatus_Failure; 142 StoreStatus status = StoreStatus_Failure;
142 if (postData.size() > 0) 143 if (postData.size() > 0)
143 { 144 {
144 status = index_.Store 145 status = index_.Store
145 (instanceUuid, storage_, reinterpret_cast<const char*>(&postData[0]), 146 (storage_, reinterpret_cast<const char*>(&postData[0]),
146 postData.size(), dicomSummary, dicomJson, ""); 147 postData.size(), dicomSummary, dicomJson, "");
147 } 148 }
148 149
150 result["ID"] = hasher.HashInstance();
151 result["Path"] = "/instances/" + hasher.HashInstance();
152
149 switch (status) 153 switch (status)
150 { 154 {
151 case StoreStatus_Success: 155 case StoreStatus_Success:
152 result["ID"] = instanceUuid;
153 result["Path"] = "/instances/" + instanceUuid;
154 result["Status"] = "Success"; 156 result["Status"] = "Success";
155 return true; 157 return true;
156 158
157 case StoreStatus_AlreadyStored: 159 case StoreStatus_AlreadyStored:
158 result["ID"] = instanceUuid;
159 result["Path"] = "/instances/" + instanceUuid;
160 result["Status"] = "AlreadyStored"; 160 result["Status"] = "AlreadyStored";
161 return true; 161 return true;
162 162
163 default: 163 default:
164 return false; 164 return false;
425 if (method == "GET") 425 if (method == "GET")
426 { 426 {
427 result = Json::Value(Json::objectValue); 427 result = Json::Value(Json::objectValue);
428 result["Version"] = ORTHANC_VERSION; 428 result["Version"] = ORTHANC_VERSION;
429 result["Name"] = GetGlobalStringParameter("Name", ""); 429 result["Name"] = GetGlobalStringParameter("Name", "");
430 result["TotalCompressedSize"] = boost::lexical_cast<std::string>(index_.GetTotalCompressedSize());
431 result["TotalUncompressedSize"] = boost::lexical_cast<std::string>(index_.GetTotalUncompressedSize());
430 existingResource = true; 432 existingResource = true;
431 } 433 }
432 else 434 else
433 { 435 {
434 output.SendMethodNotAllowedError("GET,POST"); 436 output.SendMethodNotAllowedError("GET,POST");