ctkExchangeSoapMessageProcessor.cpp 4.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124
  1. /*=============================================================================
  2. Library: CTK
  3. Copyright (c) German Cancer Research Center,
  4. Division of Medical and Biological Informatics
  5. Licensed under the Apache License, Version 2.0 (the "License");
  6. you may not use this file except in compliance with the License.
  7. You may obtain a copy of the License at
  8. http://www.apache.org/licenses/LICENSE-2.0
  9. Unless required by applicable law or agreed to in writing, software
  10. distributed under the License is distributed on an "AS IS" BASIS,
  11. WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  12. See the License for the specific language governing permissions and
  13. limitations under the License.
  14. =============================================================================*/
  15. #include "ctkExchangeSoapMessageProcessor.h"
  16. #include "ctkSoapLog.h"
  17. #include <ctkDicomAppHostingTypesHelper.h>
  18. #include <QFile>
  19. #include <QTextStream>
  20. //----------------------------------------------------------------------------
  21. ctkExchangeSoapMessageProcessor::ctkExchangeSoapMessageProcessor(ctkDicomExchangeInterface* inter)
  22. : exchangeInterface(inter)
  23. {}
  24. //----------------------------------------------------------------------------
  25. bool ctkExchangeSoapMessageProcessor::process(
  26. const QtSoapMessage& message, QtSoapMessage* reply ) const
  27. {
  28. // TODO check for NULL exchangeInterface?
  29. const QtSoapType& method = message.method();
  30. QString methodName = method.name().name();
  31. qDebug() << "ExchangeMessageProcessor: Received soap method request: " << methodName;
  32. bool foundMethod = false;
  33. if (methodName == "NotifyDataAvailable")
  34. {
  35. processNotifyDataAvailable(message, reply);
  36. foundMethod = true;
  37. }
  38. else if (methodName == "GetData")
  39. {
  40. processGetData(message, reply);
  41. foundMethod = true;
  42. }
  43. else if (methodName == "ReleaseData")
  44. {
  45. processReleaseData(message, reply);
  46. foundMethod = true;
  47. }
  48. return foundMethod;
  49. }
  50. //----------------------------------------------------------------------------
  51. void ctkExchangeSoapMessageProcessor::processNotifyDataAvailable(
  52. const QtSoapMessage &message, QtSoapMessage *reply) const
  53. {
  54. // extract arguments from input message
  55. const QtSoapType& inputType = message.method()[0];//"availableData"];
  56. if(inputType.isValid()==false)
  57. {
  58. qCritical() << " NotifyDataAvailable: availableData not valid. " << inputType.errorString();
  59. }
  60. CTK_SOAP_LOG( << inputType.toString());
  61. const ctkDicomAppHosting::AvailableData data = ctkDicomSoapAvailableData::getAvailableData(inputType);
  62. const QtSoapType& inputType2 = message.method()["lastData"];
  63. const bool lastData = ctkDicomSoapBool::getBool(inputType2);
  64. CTK_SOAP_LOG_HIGHLEVEL( << " NotifyDataAvailable: patients.count: " << data.patients.count());
  65. // query interface
  66. bool result = exchangeInterface->notifyDataAvailable(data, lastData);
  67. // set reply message
  68. reply->setMethod("NotifyDataAvailableResponse");
  69. QtSoapType* resultType = new ctkDicomSoapBool("NotifyDataAvailableResult",result);
  70. reply->addMethodArgument(resultType);
  71. }
  72. //----------------------------------------------------------------------------
  73. void ctkExchangeSoapMessageProcessor::processGetData(
  74. const QtSoapMessage &message, QtSoapMessage *reply) const
  75. {
  76. // extract arguments from input message
  77. const QtSoapType& inputType = message.method()["objects"];
  78. const QList<QUuid> objectUUIDs = ctkDicomSoapArrayOfUUIDS::getArray(inputType);
  79. const QtSoapType& inputType2 = message.method()["acceptableTransferSyntaxes"];
  80. const QList<QString> acceptableTransferSyntaxUIDs = ctkDicomSoapArrayOfUIDS::getArray(inputType2);
  81. const QtSoapType& inputType3 = message.method()["includeBulkData"];
  82. const bool includeBulkData = ctkDicomSoapBool::getBool(inputType3);
  83. // query interface
  84. const QList<ctkDicomAppHosting::ObjectLocator> result = exchangeInterface->getData(
  85. objectUUIDs, acceptableTransferSyntaxUIDs, includeBulkData);
  86. // set reply message
  87. reply->setMethod(QtSoapQName("GetDataResponse","http://dicom.nema.org/PS3.19/ApplicationService-20100825"));
  88. //reply->setMethod(QtSoapQName("GetDataResponse","http://dicom.nema.org/PS3.19/HostService-20100825"));
  89. QtSoapType* resultType = new ctkDicomSoapArrayOfObjectLocators("GetDataResult", result);
  90. reply->addMethodArgument(resultType);
  91. }
  92. //----------------------------------------------------------------------------
  93. void ctkExchangeSoapMessageProcessor::processReleaseData(
  94. const QtSoapMessage &message, QtSoapMessage * /*reply*/) const
  95. {
  96. // extract arguments from input message
  97. const QtSoapType& inputType = message.method()["objects"];
  98. const QList<QUuid> objectUUIDs = ctkDicomSoapArrayOfUUIDS::getArray(
  99. dynamic_cast<const QtSoapArray&>(inputType));
  100. // query interface
  101. exchangeInterface->releaseData(objectUUIDs);
  102. // set reply message: nothing to be done
  103. }