ctkExchangeSoapMessageProcessor.cpp 4.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116
  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. void ctkExchangeSoapMessageProcessor::processNotifyDataAvailable(
  47. const QtSoapMessage &message, QtSoapMessage *reply) const
  48. {
  49. // extract arguments from input message
  50. const QtSoapType& inputType = message.method()["availableData"];
  51. if(inputType.isValid()==false)
  52. {
  53. qCritical() << " NotifyDataAvailable: availableData not valid. " << inputType.errorString();
  54. }
  55. CTK_SOAP_LOG( << inputType.toString());
  56. const ctkDicomAppHosting::AvailableData data = ctkDicomSoapAvailableData::getAvailableData(inputType);
  57. const QtSoapType& inputType2 = message.method()["lastData"];
  58. const bool lastData = ctkDicomSoapBool::getBool(inputType2);
  59. CTK_SOAP_LOG_HIGHLEVEL( << " NotifyDataAvailable: patients.count: " << data.patients.count());
  60. // query interface
  61. bool result = exchangeInterface->notifyDataAvailable(data, lastData);
  62. // set reply message
  63. reply->setMethod("notifyDataAvailable");
  64. QtSoapType* resultType = new ctkDicomSoapBool("dataAvailable",result);
  65. reply->addMethodArgument(resultType);
  66. }
  67. void ctkExchangeSoapMessageProcessor::processGetData(
  68. const QtSoapMessage &message, QtSoapMessage *reply) const
  69. {
  70. // extract arguments from input message
  71. const QtSoapType& inputType = message.method()["objectUUIDs"];
  72. const QList<QUuid> objectUUIDs = ctkDicomSoapArrayOfUUIDS::getArray(
  73. dynamic_cast<const QtSoapArray&>(inputType));
  74. const QtSoapType& inputType2 = message.method()["acceptableTransferSyntaxUIDs"];
  75. const QStringList acceptableTransferSyntaxUIDs = ctkDicomSoapArrayOfStringType::getArray(
  76. dynamic_cast<const QtSoapArray&>(inputType2));
  77. const QtSoapType& inputType3 = message.method()["includeBulkData"];
  78. const bool includeBulkData = ctkDicomSoapBool::getBool(inputType3);
  79. // query interface
  80. const QList<ctkDicomAppHosting::ObjectLocator> result = exchangeInterface->getData(
  81. objectUUIDs, acceptableTransferSyntaxUIDs, includeBulkData);
  82. // set reply message
  83. reply->setMethod("getData");
  84. QtSoapType* resultType = new ctkDicomSoapArrayOfObjectLocators("arrayOfObjectLocator", result);
  85. reply->addMethodArgument(resultType);
  86. }
  87. void ctkExchangeSoapMessageProcessor::processReleaseData(
  88. const QtSoapMessage &message, QtSoapMessage * /*reply*/) const
  89. {
  90. // extract arguments from input message
  91. const QtSoapType& inputType = message.method()["objectUUIDs"];
  92. const QList<QUuid> objectUUIDs = ctkDicomSoapArrayOfUUIDS::getArray(
  93. dynamic_cast<const QtSoapArray&>(inputType));
  94. // query interface
  95. exchangeInterface->releaseData(objectUUIDs);
  96. // set reply message: nothing to be done
  97. }