MCPcopy Create free account
hub / github.com/MITK/MITK / HandlePOST_reinit

Method HandlePOST_reinit

Modules/RESTAPI/src/mitkRenderingController.cpp:172–321  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

170}
171
172void RenderingController::HandlePOST_reinit(const httplib::Request& req, httplib::Response& res) const
173{
174 if (!m_Bridge.HasDataStorage())
175 {
176 const auto error = ErrorResponse::DataStorageNotAvailable(req.path);
177 this->SendErrorResponse(res, 503, error);
178 return;
179 }
180
181 // Parse optional body for node-scoped reinit.
182 std::vector<std::string> uids;
183
184 if (!req.body.empty())
185 {
186 try
187 {
188 const auto body = nlohmann::json::parse(req.body);
189 if (body.contains("uids"))
190 {
191 const auto& uidsJson = body["uids"];
192 if (!uidsJson.is_array() || uidsJson.empty())
193 {
194 const auto error = ErrorResponse::InvalidRequest(
195 "'uids' must be a non-empty array of strings.", req.path);
196 this->SendErrorResponse(res, 400, error);
197 return;
198 }
199 for (const auto& item : uidsJson)
200 {
201 if (!item.is_string())
202 {
203 const auto error = ErrorResponse::InvalidRequest(
204 "'uids' must be a non-empty array of strings.", req.path);
205 this->SendErrorResponse(res, 400, error);
206 return;
207 }
208 uids.push_back(item.get<std::string>());
209 }
210 }
211 }
212 catch (const nlohmann::json::exception&)
213 {
214 const auto error = ErrorResponse::InvalidRequest("Invalid JSON body.", req.path);
215 this->SendErrorResponse(res, 400, error);
216 return;
217 }
218 }
219
220 if (!uids.empty())
221 {
222 // Node-scoped reinit: fit views to the bounding geometry of the specified nodes.
223 // Pre-dispatch: validate all UIDs and capture node pointers (no cloning).
224 std::vector<DataNode::ConstPointer> nodes;
225 nodes.reserve(uids.size());
226 for (const auto& uid : uids)
227 {
228 const auto node = m_Bridge.FindDataNode(uid);
229 if (node == nullptr)

Calls 15

SendErrorResponseMethod · 0.95
DispatchMethod · 0.95
containsMethod · 0.80
FindDataNodeMethod · 0.80
whatMethod · 0.80
NewFunction · 0.50
HasDataStorageMethod · 0.45
emptyMethod · 0.45
sizeMethod · 0.45
GetDataStorageMethod · 0.45