ctkExchangeSoapMessageProcessor.cpp 3.9 KB

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