ctkExchangeSoapMessageProcessor.cpp 4.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118
  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. ctkExchangeSoapMessageProcessor::ctkExchangeSoapMessageProcessor(ctkDicomExchangeInterface* inter)
  19. : exchangeInterface(inter)
  20. {}
  21. bool ctkExchangeSoapMessageProcessor::process(
  22. const QtSoapMessage& message, QtSoapMessage* reply ) const
  23. {
  24. // TODO check for NULL exchangeInterface?
  25. const QtSoapType& method = message.method();
  26. QString methodName = method.name().name();
  27. qDebug() << "ExchangeMessageProcessor: Received soap method request: " << methodName;
  28. bool foundMethod = false;
  29. if (methodName == "notifyDataAvailable")
  30. {
  31. processNotifyDataAvailable(message, reply);
  32. foundMethod = true;
  33. }
  34. else if (methodName == "getData")
  35. {
  36. processGetData(message, reply);
  37. foundMethod = true;
  38. }
  39. else if (methodName == "releaseData")
  40. {
  41. processReleaseData(message, reply);
  42. foundMethod = true;
  43. }
  44. return foundMethod;
  45. }
  46. extern void DumpAll(const QtSoapType& type, int indent=0);
  47. void ctkExchangeSoapMessageProcessor::processNotifyDataAvailable(
  48. const QtSoapMessage &message, QtSoapMessage *reply) const
  49. {
  50. // extract arguments from input message
  51. DumpAll(message.method());
  52. const QtSoapType& inputType = message.method()["availableData"];
  53. if(inputType.isValid()==false)
  54. {
  55. qCritical() << " NotifyDataAvailable: availableData not valid. " << inputType.errorString();
  56. }
  57. CTK_SOAP_LOG_HIGHLEVEL( << inputType.toString());
  58. const ctkDicomAppHosting::AvailableData data = ctkDicomSoapAvailableData::getAvailableData(inputType);
  59. const QtSoapType& inputType2 = message.method()["lastData"];
  60. const bool lastData = ctkDicomSoapBool::getBool(inputType2);
  61. CTK_SOAP_LOG_HIGHLEVEL( << " NotifyDataAvailable: " << data.objectDescriptors.count());
  62. // query interface
  63. bool result = exchangeInterface->notifyDataAvailable(data, lastData);
  64. // set reply message
  65. reply->setMethod("notifyDataAvailable");
  66. QtSoapType* resultType = new ctkDicomSoapBool("dataAvailable",result);
  67. reply->addMethodArgument(resultType);
  68. }
  69. void ctkExchangeSoapMessageProcessor::processGetData(
  70. const QtSoapMessage &message, QtSoapMessage *reply) const
  71. {
  72. // extract arguments from input message
  73. const QtSoapType& inputType = message.method()["objectUUIDs"];
  74. const QList<QUuid> objectUUIDs = ctkDicomSoapArrayOfUUIDS::getArray(
  75. dynamic_cast<const QtSoapArray&>(inputType));
  76. const QtSoapType& inputType2 = message.method()["acceptableTransferSyntaxUIDs"];
  77. const QStringList acceptableTransferSyntaxUIDs = ctkDicomSoapArrayOfStringType::getArray(
  78. dynamic_cast<const QtSoapArray&>(inputType2));
  79. const QtSoapType& inputType3 = message.method()["includeBulkData"];
  80. const bool includeBulkData = ctkDicomSoapBool::getBool(inputType3);
  81. // query interface
  82. const QList<ctkDicomAppHosting::ObjectLocator> result = exchangeInterface->getData(
  83. objectUUIDs, acceptableTransferSyntaxUIDs, includeBulkData);
  84. // set reply message
  85. reply->setMethod("getData");
  86. QtSoapType* resultType = new ctkDicomSoapArrayOfObjectLocators("arrayOfObjectLocator", result);
  87. reply->addMethodArgument(resultType);
  88. }
  89. void ctkExchangeSoapMessageProcessor::processReleaseData(
  90. const QtSoapMessage &message, QtSoapMessage * /*reply*/) const
  91. {
  92. // extract arguments from input message
  93. const QtSoapType& inputType = message.method()["objectUUIDs"];
  94. const QList<QUuid> objectUUIDs = ctkDicomSoapArrayOfUUIDS::getArray(
  95. dynamic_cast<const QtSoapArray&>(inputType));
  96. // query interface
  97. exchangeInterface->releaseData(objectUUIDs);
  98. // set reply message: nothing to be done
  99. }