comparison OrthancServer/OrthancGetRequestHandler.cpp @ 3954:67b457283499 c-get

coding style
author Sebastien Jodogne <s.jodogne@gmail.com>
date Wed, 20 May 2020 09:52:20 +0200
parents 620e87e9e816
children 66879215cbf3
comparison
equal deleted inserted replaced
3953:620e87e9e816 3954:67b457283499
84 FromDcmtkBridge::LoadFromMemoryBuffer(dicom.c_str(), dicom.size())); 84 FromDcmtkBridge::LoadFromMemoryBuffer(dicom.c_str(), dicom.size()));
85 85
86 // Determine the storage SOP class UID for this instance 86 // Determine the storage SOP class UID for this instance
87 DIC_UI sopClass; 87 DIC_UI sopClass;
88 DIC_UI sopInstance; 88 DIC_UI sopInstance;
89 89
90 {
91 bool ok;
92
90 #if DCMTK_VERSION_NUMBER >= 364 93 #if DCMTK_VERSION_NUMBER >= 364
91 if (!DU_findSOPClassAndInstanceInDataSet(static_cast<DcmItem *> (parsed->getDataset()), 94 ok = DU_findSOPClassAndInstanceInDataSet(static_cast<DcmItem *> (parsed->getDataset()),
92 sopClass, sizeof(sopClass), 95 sopClass, sizeof(sopClass),
93 sopInstance, sizeof(sopInstance))) 96 sopInstance, sizeof(sopInstance));
94 #else 97 #else
95 if (!DU_findSOPClassAndInstanceInDataSet(parsed->getDataset(), sopClass, sopInstance)) 98 ok = DU_findSOPClassAndInstanceInDataSet(parsed->getDataset(), sopClass, sopInstance);
96 #endif 99 #endif
100
101 if (!ok)
97 { 102 {
98 throw OrthancException(ErrorCode_NoSopClassOrInstance, 103 throw OrthancException(ErrorCode_NoSopClassOrInstance,
99 "Unable to determine the SOP class/instance for C-STORE with AET " + 104 "Unable to determine the SOP class/instance for C-STORE with AET " +
100 originatorAet_); 105 originatorAet_);
101 } 106 }
102 107 }
103 OFCondition cond = performGetSubOp(assoc, sopClass, sopInstance, parsed->getDataset()); 108
109 OFCondition cond = PerformGetSubOp(assoc, sopClass, sopInstance, parsed->getDataset());
110
104 if (getCancelled_) 111 if (getCancelled_)
105 { 112 {
106 LOG(INFO) << "Get SCP: Received C-Cancel RQ"; 113 LOG(INFO) << "Get SCP: Received C-Cancel RQ";
107 } 114 }
108 115
113 120
114 return Status_Success; 121 return Status_Success;
115 } 122 }
116 123
117 124
118 void OrthancGetRequestHandler::addFailedUIDInstance(const char *sopInstance) 125 void OrthancGetRequestHandler::AddFailedUIDInstance(const char *sopInstance)
119 { 126 {
120 if (failedUIDs_.empty()) 127 if (failedUIDs_.empty())
121 { 128 {
122 failedUIDs_ = sopInstance; 129 failedUIDs_ = sopInstance;
123 } 130 }
126 failedUIDs_ += "\\" + std::string(sopInstance); 133 failedUIDs_ += "\\" + std::string(sopInstance);
127 } 134 }
128 } 135 }
129 136
130 137
131 OFCondition OrthancGetRequestHandler::performGetSubOp(T_ASC_Association* assoc, 138 OFCondition OrthancGetRequestHandler::PerformGetSubOp(T_ASC_Association* assoc,
132 DIC_UI sopClass, 139 DIC_UI sopClass,
133 DIC_UI sopInstance, 140 DIC_UI sopInstance,
134 DcmDataset *dataset) 141 DcmDataset *dataset)
135 { 142 {
136 OFCondition cond = EC_Normal; 143 OFCondition cond = EC_Normal;
146 presId = ASC_findAcceptedPresentationContextID(assoc, sopClass); 153 presId = ASC_findAcceptedPresentationContextID(assoc, sopClass);
147 154
148 if (presId == 0) 155 if (presId == 0)
149 { 156 {
150 nFailed_++; 157 nFailed_++;
151 addFailedUIDInstance(sopInstance); 158 AddFailedUIDInstance(sopInstance);
152 LOG(ERROR) << "Get SCP: storeSCU: No presentation context for: (" 159 LOG(ERROR) << "Get SCP: storeSCU: No presentation context for: ("
153 << dcmSOPClassUIDToModality(sopClass, "OT") << ") " << sopClass; 160 << dcmSOPClassUIDToModality(sopClass, "OT") << ") " << sopClass;
154 return DIMSE_NOVALIDPRESENTATIONCONTEXTID; 161 return DIMSE_NOVALIDPRESENTATIONCONTEXTID;
155 } 162 }
156 else 163 else
157 { 164 {
158 // make sure that we can send images in this presentation context 165 // make sure that we can send images in this presentation context
159 T_ASC_PresentationContext pc; 166 T_ASC_PresentationContext pc;
160 ASC_findAcceptedPresentationContext(assoc->params, presId, &pc); 167 ASC_findAcceptedPresentationContext(assoc->params, presId, &pc);
161 // the acceptedRole is the association requestor role 168 // the acceptedRole is the association requestor role
162 if ((pc.acceptedRole != ASC_SC_ROLE_SCP) && (pc.acceptedRole != ASC_SC_ROLE_SCUSCP)) 169 if ((pc.acceptedRole != ASC_SC_ROLE_SCP) &&
170 (pc.acceptedRole != ASC_SC_ROLE_SCUSCP))
163 { 171 {
164 // the role is not appropriate 172 // the role is not appropriate
165 nFailed_++; 173 nFailed_++;
166 addFailedUIDInstance(sopInstance); 174 AddFailedUIDInstance(sopInstance);
167 LOG(ERROR) <<"Get SCP: storeSCU: [No presentation context with requestor SCP role for: (" 175 LOG(ERROR) <<"Get SCP: storeSCU: [No presentation context with requestor SCP role for: ("
168 << dcmSOPClassUIDToModality(sopClass, "OT") << ") " << sopClass; 176 << dcmSOPClassUIDToModality(sopClass, "OT") << ") " << sopClass;
169 return DIMSE_NOVALIDPRESENTATIONCONTEXTID; 177 return DIMSE_NOVALIDPRESENTATIONCONTEXTID;
170 } 178 }
171 } 179 }
188 196
189 if (cond.good()) 197 if (cond.good())
190 { 198 {
191 if (cancelParameters.cancelEncountered) 199 if (cancelParameters.cancelEncountered)
192 { 200 {
193 if (origPresId == cancelParameters.presId && 201 if (origPresId_ == cancelParameters.presId &&
194 origMsgId == cancelParameters.req.MessageIDBeingRespondedTo) 202 origMsgId_ == cancelParameters.req.MessageIDBeingRespondedTo)
195 { 203 {
196 getCancelled_ = OFTrue; 204 getCancelled_ = OFTrue;
197 } 205 }
198 else 206 else
199 { 207 {
215 << DU_cstoreStatusString(rsp.DimseStatus); 223 << DU_cstoreStatusString(rsp.DimseStatus);
216 } 224 }
217 else 225 else
218 { 226 {
219 nFailed_++; 227 nFailed_++;
220 addFailedUIDInstance(sopInstance); 228 AddFailedUIDInstance(sopInstance);
221 // print a status message 229 // print a status message
222 LOG(ERROR) << "Get SCP: Store Failed: Response Status: " 230 LOG(ERROR) << "Get SCP: Store Failed: Response Status: "
223 << DU_cstoreStatusString(rsp.DimseStatus); 231 << DU_cstoreStatusString(rsp.DimseStatus);
224 } 232 }
225 } 233 }
226 else 234 else
227 { 235 {
228 nFailed_++; 236 nFailed_++;
229 addFailedUIDInstance(sopInstance); 237 AddFailedUIDInstance(sopInstance);
230 OFString temp_str; 238 OFString temp_str;
231 LOG(ERROR) << "Get SCP: storeSCU: Store Request Failed: " << DimseCondition::dump(temp_str, cond); 239 LOG(ERROR) << "Get SCP: storeSCU: Store Request Failed: " << DimseCondition::dump(temp_str, cond);
232 } 240 }
233 241
234 if (stDetail) 242 if (stDetail)
336 * Lookup for the resource to be sent. 344 * Lookup for the resource to be sent.
337 **/ 345 **/
338 346
339 std::vector<std::string> publicIds; 347 std::vector<std::string> publicIds;
340 348
341 bool retVal = LookupIdentifiers(publicIds, level, input); 349 if (!LookupIdentifiers(publicIds, level, input))
350 {
351 LOG(ERROR) << "Cannot determine what resources are requested by C-GET";
352 return false;
353 }
354
342 localAet_ = context_.GetDefaultLocalApplicationEntityTitle(); 355 localAet_ = context_.GetDefaultLocalApplicationEntityTitle();
343 position_ = 0; 356 position_ = 0;
344 originatorAet_ = originatorAet; 357 originatorAet_ = originatorAet;
345 358
346 { 359 {
348 remote_ = lock.GetConfiguration().GetModalityUsingAet(originatorAet); 361 remote_ = lock.GetConfiguration().GetModalityUsingAet(originatorAet);
349 } 362 }
350 363
351 for (size_t i = 0; i < publicIds.size(); i++) 364 for (size_t i = 0; i < publicIds.size(); i++)
352 { 365 {
353 LOG(INFO) << "Sending resource " << publicIds[i] << " to modality \"" 366 LOG(INFO) << "C-GET: Sending resource " << publicIds[i]
354 << originatorAet << "\" in synchronous mode"; 367 << " to modality \"" << originatorAet << "\"";
355 368
356 std::list<std::string> tmp; 369 std::list<std::string> tmp;
357 context_.GetIndex().GetChildInstances(tmp, publicIds[i]); 370 context_.GetIndex().GetChildInstances(tmp, publicIds[i]);
358 371
359 instances_.reserve(tmp.size()); 372 instances_.reserve(tmp.size());
369 nRemaining_ = GetSubOperationCount(); 382 nRemaining_ = GetSubOperationCount();
370 nCompleted_ = 0; 383 nCompleted_ = 0;
371 nFailed_ = 0; 384 nFailed_ = 0;
372 warningCount_ = 0; 385 warningCount_ = 0;
373 386
374 return retVal; 387 return true;
375 } 388 }
376 }; 389 };