ctkExchangeSoapMessageProcessor.cpp 4.6 KB

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