comparison OrthancServer/OrthancRestApi.cpp @ 173:68dae290d5fa Orthanc-0.2.3-Paulus

fix
author Sebastien Jodogne <s.jodogne@gmail.com>
date Mon, 19 Nov 2012 13:50:19 +0100
parents da7e915202c7
children
comparison
equal deleted inserted replaced
171:da7e915202c7 173:68dae290d5fa
123 const UriComponents& uri) 123 const UriComponents& uri)
124 { 124 {
125 // TODO: Implement a true caching mechanism! 125 // TODO: Implement a true caching mechanism!
126 static boost::mutex mutex_; 126 static boost::mutex mutex_;
127 static std::string lastFileUuid_; 127 static std::string lastFileUuid_;
128 static DcmFileFormat dicomFile_; 128 static std::auto_ptr<DcmFileFormat> dicomFile_;
129 129
130 boost::mutex::scoped_lock lock(mutex_); 130 boost::mutex::scoped_lock lock(mutex_);
131 131
132 if (fileUuid != lastFileUuid_) 132 if (dicomFile_.get() == NULL ||
133 fileUuid != lastFileUuid_)
133 { 134 {
134 LOG(INFO) << "Parsing file " << fileUuid; 135 LOG(INFO) << "Parsing file " << fileUuid;
135 std::string content; 136 std::string content;
136 storage.ReadFile(content, fileUuid); 137 storage.ReadFile(content, fileUuid);
137 138
140 { 141 {
141 is.setBuffer(&content[0], content.size()); 142 is.setBuffer(&content[0], content.size());
142 } 143 }
143 is.setEos(); 144 is.setEos();
144 145
145 if (!dicomFile_.read(is).good()) 146 dicomFile_.reset(new DcmFileFormat);
147
148 if (!dicomFile_->read(is).good())
146 { 149 {
147 return false; 150 return false;
148 } 151 }
149 152
150 lastFileUuid_ = fileUuid; 153 lastFileUuid_ = fileUuid;
155 } 158 }
156 159
157 if (uri.size() == 3) 160 if (uri.size() == 3)
158 { 161 {
159 DicomMap dicomSummary; 162 DicomMap dicomSummary;
160 FromDcmtkBridge::Convert(dicomSummary, *dicomFile_.getDataset()); 163 FromDcmtkBridge::Convert(dicomSummary, *dicomFile_->getDataset());
161 164
162 DicomArray a(dicomSummary); 165 DicomArray a(dicomSummary);
163 166
164 Json::Value target = Json::arrayValue; 167 Json::Value target = Json::arrayValue;
165 for (size_t i = 0; i < a.GetSize(); i++) 168 for (size_t i = 0; i < a.GetSize(); i++)
189 } 192 }
190 193
191 DcmTagKey tag(group, element); 194 DcmTagKey tag(group, element);
192 DcmElement* item = NULL; 195 DcmElement* item = NULL;
193 196
194 if (dicomFile_.getDataset()->findAndGetElement(tag, item).good() && 197 if (dicomFile_->getDataset()->findAndGetElement(tag, item).good() &&
195 item != NULL) 198 item != NULL)
196 { 199 {
197 std::string buffer; 200 std::string buffer;
198 buffer.resize(65536); 201 buffer.resize(65536);
199 Uint32 length = item->getLength(); 202 Uint32 length = item->getLength();