Mercurial > hg > orthanc
comparison OrthancServer/OrthancMoveRequestHandler.cpp @ 771:537837f50fbb
refactoring
author | Sebastien Jodogne <s.jodogne@gmail.com> |
---|---|
date | Wed, 30 Apr 2014 14:15:26 +0200 |
parents | 3596177682a9 |
children | 31cc399c7762 |
comparison
equal
deleted
inserted
replaced
769:3f946e5c3802 | 771:537837f50fbb |
---|---|
45 class OrthancMoveRequestIterator : public IMoveRequestIterator | 45 class OrthancMoveRequestIterator : public IMoveRequestIterator |
46 { | 46 { |
47 private: | 47 private: |
48 ServerContext& context_; | 48 ServerContext& context_; |
49 std::vector<std::string> instances_; | 49 std::vector<std::string> instances_; |
50 DicomUserConnection connection_; | |
51 size_t position_; | 50 size_t position_; |
51 | |
52 std::string aet_, address_; | |
53 int port_; | |
54 ModalityManufacturer manufacturer_; | |
52 | 55 |
53 public: | 56 public: |
54 OrthancMoveRequestIterator(ServerContext& context, | 57 OrthancMoveRequestIterator(ServerContext& context, |
55 const std::string& target, | 58 const std::string& aet, |
56 const std::string& publicId) : | 59 const std::string& publicId) : |
57 context_(context), | 60 context_(context), |
58 position_(0) | 61 position_(0), |
62 aet_(aet) | |
59 { | 63 { |
60 LOG(INFO) << "Sending resource " << publicId << " to modality \"" << target << "\""; | 64 LOG(INFO) << "Sending resource " << publicId << " to modality \"" << aet << "\""; |
61 | 65 |
62 std::list<std::string> tmp; | 66 std::list<std::string> tmp; |
63 context_.GetIndex().GetChildInstances(tmp, publicId); | 67 context_.GetIndex().GetChildInstances(tmp, publicId); |
64 | 68 |
65 instances_.reserve(tmp.size()); | 69 instances_.reserve(tmp.size()); |
66 for (std::list<std::string>::iterator it = tmp.begin(); it != tmp.end(); ++it) | 70 for (std::list<std::string>::iterator it = tmp.begin(); it != tmp.end(); ++it) |
67 { | 71 { |
68 instances_.push_back(*it); | 72 instances_.push_back(*it); |
69 } | 73 } |
70 | 74 |
71 ConnectToModalityUsingAETitle(connection_, target); | 75 std::string symbolicName; |
76 if (!LookupDicomModalityUsingAETitle(aet_, symbolicName, address_, port_, manufacturer_)) | |
77 { | |
78 throw OrthancException("Unknown modality: " + aet_); | |
79 } | |
72 } | 80 } |
73 | 81 |
74 virtual unsigned int GetSubOperationCount() const | 82 virtual unsigned int GetSubOperationCount() const |
75 { | 83 { |
76 return instances_.size(); | 84 return instances_.size(); |
85 | 93 |
86 const std::string& id = instances_[position_++]; | 94 const std::string& id = instances_[position_++]; |
87 | 95 |
88 std::string dicom; | 96 std::string dicom; |
89 context_.ReadFile(dicom, id, FileContentType_Dicom); | 97 context_.ReadFile(dicom, id, FileContentType_Dicom); |
90 connection_.Store(dicom); | 98 |
99 { | |
100 ReusableDicomUserConnection::Connection connection(context_.GetReusableDicomUserConnection(), | |
101 aet_, address_, port_, manufacturer_); | |
102 connection.GetConnection().Store(dicom); | |
103 } | |
91 | 104 |
92 return Status_Success; | 105 return Status_Success; |
93 } | 106 } |
94 }; | 107 }; |
95 } | 108 } |
119 return true; | 132 return true; |
120 } | 133 } |
121 } | 134 } |
122 | 135 |
123 | 136 |
124 IMoveRequestIterator* OrthancMoveRequestHandler::Handle(const std::string& target, | 137 IMoveRequestIterator* OrthancMoveRequestHandler::Handle(const std::string& aet, |
125 const DicomMap& input) | 138 const DicomMap& input) |
126 { | 139 { |
127 LOG(WARNING) << "Move-SCU request received for AET \"" << target << "\""; | 140 LOG(WARNING) << "Move-SCU request received for AET \"" << aet << "\""; |
128 | 141 |
129 | 142 |
130 /** | 143 /** |
131 * Retrieve the query level. | 144 * Retrieve the query level. |
132 **/ | 145 **/ |
171 if (!ok) | 184 if (!ok) |
172 { | 185 { |
173 throw OrthancException(ErrorCode_BadRequest); | 186 throw OrthancException(ErrorCode_BadRequest); |
174 } | 187 } |
175 | 188 |
176 return new OrthancMoveRequestIterator(context_, target, publicId); | 189 return new OrthancMoveRequestIterator(context_, aet, publicId); |
177 } | 190 } |
178 } | 191 } |