ctkExchangeSoapMessageProcessor.cpp 3.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109
  1. /*=============================================================================
  2. Library: CTK
  3. Copyright (c) 2010 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 <ctkDicomWG23TypesHelper.h>
  17. ctkExchangeSoapMessageProcessor::ctkExchangeSoapMessageProcessor(ctkDicomExchangeInterface* inter)
  18. : exchangeInterface(inter)
  19. {}
  20. bool ctkExchangeSoapMessageProcessor::process(
  21. const QtSoapMessage& message,
  22. 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()["data"];
  51. const ctkDicomWG23::AvailableData data = ctkDicomSoapAvailableData::getAvailableData(inputType);
  52. const QtSoapType& inputType2 = message.method()["lastData"];
  53. const bool lastData = ctkDicomSoapBool::getBool(inputType2);
  54. // query interface
  55. bool result = exchangeInterface->notifyDataAvailable(data, lastData);
  56. // set reply message
  57. reply->setMethod("notifyDataAvailable");
  58. QtSoapType* resultType = new ctkDicomSoapBool("dataAvailable",result);
  59. reply->addMethodArgument(resultType);
  60. }
  61. void ctkExchangeSoapMessageProcessor::processGetData(
  62. const QtSoapMessage &message, QtSoapMessage *reply) const
  63. {
  64. // extract arguments from input message
  65. const QtSoapType& inputType = message.method()["objectUUIDs"];
  66. const QList<QUuid>* objectUUIDs = ctkDicomSoapArrayOfUUIDS::getArray(
  67. dynamic_cast<const QtSoapArray&>(inputType));
  68. const QtSoapType& inputType2 = message.method()["acceptableTransferSyntaxUIDs"];
  69. const QStringList* acceptableTransferSyntaxUIDs = ctkDicomSoapArrayOfStringType::getArray(
  70. dynamic_cast<const QtSoapArray&>(inputType2));
  71. const QtSoapType& inputType3 = message.method()["includeBulkData"];
  72. const bool includeBulkData = ctkDicomSoapBool::getBool(inputType3);
  73. // query interface
  74. const QList<ctkDicomWG23::ObjectLocator>* result = exchangeInterface->getData(
  75. *objectUUIDs, *acceptableTransferSyntaxUIDs, includeBulkData);
  76. // set reply message
  77. reply->setMethod("getData");
  78. QtSoapType* resultType = new ctkDicomSoapArrayOfObjectLocators("arrayOfObjectLocator", *result);
  79. reply->addMethodArgument(resultType);
  80. }
  81. void ctkExchangeSoapMessageProcessor::processReleaseData(
  82. const QtSoapMessage &message, QtSoapMessage *reply) const
  83. {
  84. // extract arguments from input message
  85. const QtSoapType& inputType = message.method()["objectUUIDs"];
  86. const QList<QUuid> objectUUIDs;
  87. // query interface
  88. exchangeInterface->releaseData(objectUUIDs);
  89. // set reply message: nothing to be done
  90. }