Mercurial > hg > orthanc
comparison OrthancServer/Internals/CommandDispatcher.cpp @ 102:7593b57dc1bf
switch to google log
author | Sebastien Jodogne <s.jodogne@gmail.com> |
---|---|
date | Wed, 03 Oct 2012 16:28:13 +0200 |
parents | 428784e59dcd |
children | fe180eae201d |
comparison
equal
deleted
inserted
replaced
101:428784e59dcd | 102:7593b57dc1bf |
---|---|
21 #include "CommandDispatcher.h" | 21 #include "CommandDispatcher.h" |
22 | 22 |
23 #include "FindScp.h" | 23 #include "FindScp.h" |
24 #include "StoreScp.h" | 24 #include "StoreScp.h" |
25 #include "MoveScp.h" | 25 #include "MoveScp.h" |
26 #include "DcmtkLogging.h" | |
27 #include "../../Core/Toolbox.h" | 26 #include "../../Core/Toolbox.h" |
28 | 27 |
29 #include <dcmtk/dcmnet/dcasccfg.h> /* for class DcmAssociationConfiguration */ | 28 #include <dcmtk/dcmnet/dcasccfg.h> /* for class DcmAssociationConfiguration */ |
30 #include <boost/lexical_cast.hpp> | 29 #include <boost/lexical_cast.hpp> |
30 #include <glog/logging.h> | |
31 | 31 |
32 static OFBool opt_rejectWithoutImplementationUID = OFFalse; | 32 static OFBool opt_rejectWithoutImplementationUID = OFFalse; |
33 | 33 |
34 | 34 |
35 namespace Orthanc | 35 namespace Orthanc |
40 { | 40 { |
41 OFString temp_str; | 41 OFString temp_str; |
42 OFCondition cond = ASC_dropSCPAssociation(assoc); | 42 OFCondition cond = ASC_dropSCPAssociation(assoc); |
43 if (cond.bad()) | 43 if (cond.bad()) |
44 { | 44 { |
45 LOG4CPP_FATAL(Internals::GetLogger(), std::string(cond.text())); | 45 LOG(FATAL) << cond.text(); |
46 return cond; | 46 return cond; |
47 } | 47 } |
48 | 48 |
49 cond = ASC_destroyAssociation(&assoc); | 49 cond = ASC_destroyAssociation(&assoc); |
50 if (cond.bad()) | 50 if (cond.bad()) |
51 { | 51 { |
52 LOG4CPP_FATAL(Internals::GetLogger(), std::string(cond.text())); | 52 LOG(FATAL) << cond.text(); |
53 return cond; | 53 return cond; |
54 } | 54 } |
55 | 55 |
56 return cond; | 56 return cond; |
57 } | 57 } |
105 } | 105 } |
106 | 106 |
107 // if some kind of error occured, take care of it | 107 // if some kind of error occured, take care of it |
108 if (cond.bad()) | 108 if (cond.bad()) |
109 { | 109 { |
110 LOG4CPP_ERROR(Internals::GetLogger(), "Receiving Association failed: " + std::string(cond.text())); | 110 LOG(ERROR) << "Receiving Association failed: " << cond.text(); |
111 // no matter what kind of error occurred, we need to do a cleanup | 111 // no matter what kind of error occurred, we need to do a cleanup |
112 AssociationCleanup(assoc); | 112 AssociationCleanup(assoc); |
113 return NULL; | 113 return NULL; |
114 } | 114 } |
115 | 115 |
116 LOG4CPP_INFO(Internals::GetLogger(), "Association Received"); | 116 LOG(INFO) << "Association Received"; |
117 | 117 |
118 transferSyntaxes[0] = UID_LittleEndianExplicitTransferSyntax; | 118 transferSyntaxes[0] = UID_LittleEndianExplicitTransferSyntax; |
119 transferSyntaxes[1] = UID_BigEndianExplicitTransferSyntax; | 119 transferSyntaxes[1] = UID_BigEndianExplicitTransferSyntax; |
120 transferSyntaxes[2] = UID_LittleEndianImplicitTransferSyntax; | 120 transferSyntaxes[2] = UID_LittleEndianImplicitTransferSyntax; |
121 numTransferSyntaxes = 3; | 121 numTransferSyntaxes = 3; |
122 | 122 |
123 /* accept the Verification SOP Class if presented */ | 123 /* accept the Verification SOP Class if presented */ |
124 cond = ASC_acceptContextsWithPreferredTransferSyntaxes( assoc->params, &knownAbstractSyntaxes[0], knownAbstractSyntaxes.size(), transferSyntaxes, numTransferSyntaxes); | 124 cond = ASC_acceptContextsWithPreferredTransferSyntaxes( assoc->params, &knownAbstractSyntaxes[0], knownAbstractSyntaxes.size(), transferSyntaxes, numTransferSyntaxes); |
125 if (cond.bad()) | 125 if (cond.bad()) |
126 { | 126 { |
127 LOG4CPP_DEBUG(Internals::GetLogger(), std::string(cond.text())); | 127 LOG(INFO) << cond.text(); |
128 AssociationCleanup(assoc); | 128 AssociationCleanup(assoc); |
129 return NULL; | 129 return NULL; |
130 } | 130 } |
131 | 131 |
132 /* the array of Storage SOP Class UIDs comes from dcuid.h */ | 132 /* the array of Storage SOP Class UIDs comes from dcuid.h */ |
133 cond = ASC_acceptContextsWithPreferredTransferSyntaxes( assoc->params, dcmAllStorageSOPClassUIDs, numberOfAllDcmStorageSOPClassUIDs, transferSyntaxes, numTransferSyntaxes); | 133 cond = ASC_acceptContextsWithPreferredTransferSyntaxes( assoc->params, dcmAllStorageSOPClassUIDs, numberOfAllDcmStorageSOPClassUIDs, transferSyntaxes, numTransferSyntaxes); |
134 if (cond.bad()) | 134 if (cond.bad()) |
135 { | 135 { |
136 LOG4CPP_DEBUG(Internals::GetLogger(), std::string(cond.text())); | 136 LOG(INFO) << cond.text(); |
137 AssociationCleanup(assoc); | 137 AssociationCleanup(assoc); |
138 return NULL; | 138 return NULL; |
139 } | 139 } |
140 | 140 |
141 /* set our app title */ | 141 /* set our app title */ |
151 ASC_RESULT_REJECTEDPERMANENT, | 151 ASC_RESULT_REJECTEDPERMANENT, |
152 ASC_SOURCE_SERVICEUSER, | 152 ASC_SOURCE_SERVICEUSER, |
153 ASC_REASON_SU_APPCONTEXTNAMENOTSUPPORTED | 153 ASC_REASON_SU_APPCONTEXTNAMENOTSUPPORTED |
154 }; | 154 }; |
155 | 155 |
156 LOG4CPP_INFO(Internals::GetLogger(), "Association Rejected: Bad Application Context Name: " + std::string(buf)); | 156 LOG(INFO) << "Association Rejected: Bad Application Context Name: " << buf; |
157 cond = ASC_rejectAssociation(assoc, &rej); | 157 cond = ASC_rejectAssociation(assoc, &rej); |
158 if (cond.bad()) | 158 if (cond.bad()) |
159 { | 159 { |
160 LOG4CPP_DEBUG(Internals::GetLogger(), std::string(cond.text())); | 160 LOG(INFO) << cond.text(); |
161 } | 161 } |
162 AssociationCleanup(assoc); | 162 AssociationCleanup(assoc); |
163 return NULL; | 163 return NULL; |
164 } | 164 } |
165 | 165 |
227 ASC_RESULT_REJECTEDPERMANENT, | 227 ASC_RESULT_REJECTEDPERMANENT, |
228 ASC_SOURCE_SERVICEUSER, | 228 ASC_SOURCE_SERVICEUSER, |
229 ASC_REASON_SU_NOREASON | 229 ASC_REASON_SU_NOREASON |
230 }; | 230 }; |
231 | 231 |
232 LOG4CPP_INFO(Internals::GetLogger(), "Association Rejected: No Implementation Class UID provided"); | 232 LOG(INFO) << "Association Rejected: No Implementation Class UID provided"; |
233 cond = ASC_rejectAssociation(assoc, &rej); | 233 cond = ASC_rejectAssociation(assoc, &rej); |
234 if (cond.bad()) | 234 if (cond.bad()) |
235 { | 235 { |
236 LOG4CPP_DEBUG(Internals::GetLogger(), std::string(cond.text())); | 236 LOG(INFO) << cond.text(); |
237 } | 237 } |
238 AssociationCleanup(assoc); | 238 AssociationCleanup(assoc); |
239 return NULL; | 239 return NULL; |
240 } | 240 } |
241 | 241 |
242 { | 242 { |
243 cond = ASC_acknowledgeAssociation(assoc); | 243 cond = ASC_acknowledgeAssociation(assoc); |
244 if (cond.bad()) | 244 if (cond.bad()) |
245 { | 245 { |
246 LOG4CPP_ERROR(Internals::GetLogger(), std::string(cond.text())); | 246 LOG(ERROR) << cond.text(); |
247 AssociationCleanup(assoc); | 247 AssociationCleanup(assoc); |
248 return NULL; | 248 return NULL; |
249 } | 249 } |
250 LOG4CPP_INFO(Internals::GetLogger(), "Association Acknowledged (Max Send PDV: " + boost::lexical_cast<std::string>(assoc->sendPDVLength) + ")"); | 250 LOG(INFO) << "Association Acknowledged (Max Send PDV: " << assoc->sendPDVLength << ")"; |
251 if (ASC_countAcceptedPresentationContexts(assoc->params) == 0) | 251 if (ASC_countAcceptedPresentationContexts(assoc->params) == 0) |
252 LOG4CPP_INFO(Internals::GetLogger(), " (but no valid presentation contexts)"); | 252 LOG(INFO) << " (but no valid presentation contexts)"; |
253 } | 253 } |
254 | 254 |
255 return new CommandDispatcher(server, assoc); | 255 return new CommandDispatcher(server, assoc); |
256 } | 256 } |
257 | 257 |
345 break; | 345 break; |
346 | 346 |
347 default: | 347 default: |
348 // we cannot handle this kind of message | 348 // we cannot handle this kind of message |
349 cond = DIMSE_BADCOMMANDTYPE; | 349 cond = DIMSE_BADCOMMANDTYPE; |
350 LOG4CPP_ERROR(Internals::GetLogger(), "cannot handle command: 0x" | 350 LOG(ERROR) << "cannot handle command: 0x" << std::hex << msg.CommandField; |
351 + boost::lexical_cast<std::string>(hex) | |
352 + boost::lexical_cast<std::string>(msg.CommandField)); | |
353 break; | 351 break; |
354 } | 352 } |
355 } | 353 } |
356 else | 354 else |
357 { | 355 { |
362 | 360 |
363 if (finished) | 361 if (finished) |
364 { | 362 { |
365 if (cond == DUL_PEERREQUESTEDRELEASE) | 363 if (cond == DUL_PEERREQUESTEDRELEASE) |
366 { | 364 { |
367 LOG4CPP_INFO(Internals::GetLogger(), "Association Release"); | 365 LOG(INFO) << "Association Release"; |
368 ASC_acknowledgeRelease(assoc_); | 366 ASC_acknowledgeRelease(assoc_); |
369 } | 367 } |
370 else if (cond == DUL_PEERABORTEDASSOCIATION) | 368 else if (cond == DUL_PEERABORTEDASSOCIATION) |
371 { | 369 { |
372 LOG4CPP_INFO(Internals::GetLogger(), "Association Aborted"); | 370 LOG(INFO) << "Association Aborted"; |
373 } | 371 } |
374 else | 372 else |
375 { | 373 { |
376 OFString temp_str; | 374 OFString temp_str; |
377 LOG4CPP_ERROR(Internals::GetLogger(), "DIMSE failure (aborting association): " + std::string(cond.text())); | 375 LOG(ERROR) << "DIMSE failure (aborting association): " << cond.text(); |
378 /* some kind of error so abort the association */ | 376 /* some kind of error so abort the association */ |
379 ASC_abortAssociation(assoc_); | 377 ASC_abortAssociation(assoc_); |
380 } | 378 } |
381 } | 379 } |
382 | 380 |
385 | 383 |
386 | 384 |
387 OFCondition EchoScp( T_ASC_Association * assoc, T_DIMSE_Message * msg, T_ASC_PresentationContextID presID) | 385 OFCondition EchoScp( T_ASC_Association * assoc, T_DIMSE_Message * msg, T_ASC_PresentationContextID presID) |
388 { | 386 { |
389 OFString temp_str; | 387 OFString temp_str; |
390 LOG4CPP_INFO(Internals::GetLogger(), "Received Echo Request"); | 388 LOG(INFO) << "Received Echo Request"; |
391 //LOG4CPP_DEBUG(Internals::GetLogger(), DIMSE_dumpMessage(temp_str, msg->msg.CEchoRQ, DIMSE_INCOMING, NULL, presID)); | 389 //LOG(DEBUG) << DIMSE_dumpMessage(temp_str, msg->msg.CEchoRQ, DIMSE_INCOMING, NULL, presID)); |
392 | 390 |
393 /* the echo succeeded !! */ | 391 /* the echo succeeded !! */ |
394 OFCondition cond = DIMSE_sendEchoResponse(assoc, presID, &msg->msg.CEchoRQ, STATUS_Success, NULL); | 392 OFCondition cond = DIMSE_sendEchoResponse(assoc, presID, &msg->msg.CEchoRQ, STATUS_Success, NULL); |
395 if (cond.bad()) | 393 if (cond.bad()) |
396 { | 394 { |
397 LOG4CPP_ERROR(Internals::GetLogger(), "Echo SCP Failed: " + std::string(cond.text())); | 395 LOG(ERROR) << "Echo SCP Failed: " << cond.text(); |
398 } | 396 } |
399 return cond; | 397 return cond; |
400 } | 398 } |
401 } | 399 } |
402 } | 400 } |