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

Method HandleGET_nodes_uid

Modules/RESTAPI/src/mitkDataStorageController.cpp:1205–1238  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1203}
1204
1205void DataStorageController::HandleGET_nodes_uid(const httplib::Request& req, httplib::Response& res)
1206{
1207 if (!m_Bridge.HasDataStorage())
1208 {
1209 this->SendErrorResponse(res, 503, ErrorResponse::DataStorageNotAvailable(req.path));
1210 return;
1211 }
1212
1213 const std::string uid = req.path_params.at("uid");
1214 if (!ValidateUid(uid))
1215 {
1216 this->SendErrorResponse(res, 400, ErrorResponse::InvalidRequest("Invalid UID format", req.path));
1217 return;
1218 }
1219
1220 auto node = m_Bridge.GetNode(uid);
1221 if (!node.has_value())
1222 {
1223 this->SendErrorResponse(res, 404, ErrorResponse::NodeNotFound(uid, req.path));
1224 return;
1225 }
1226
1227 // Get available contexts for this node
1228 auto availableContexts = m_Bridge.GetNodeAvailableContexts(uid);
1229
1230 nlohmann::json response;
1231 response["data"] = node.value();
1232 if (availableContexts.has_value())
1233 {
1234 response["meta"]["available_contexts"] = availableContexts.value();
1235 }
1236
1237 this->SendJsonResponse(res, 200, response);
1238}
1239
1240void DataStorageController::HandlePATCH_nodes_uid(const httplib::Request& req, httplib::Response& res)
1241{

Callers 15

ValidUidAcceptedMethod · 0.80
EmptyUidRejectedMethod · 0.80
TooLongUidRejectedMethod · 0.80
GetNodeByUidMethod · 0.80
GetNodeNotFoundMethod · 0.80
BuildEndpointRegistryMethod · 0.80
NodeFieldTypesCorrectMethod · 0.80

Calls 8

SendErrorResponseMethod · 0.95
SendJsonResponseMethod · 0.95
ValidateUidFunction · 0.85
atMethod · 0.80
HasDataStorageMethod · 0.45
GetNodeMethod · 0.45
valueMethod · 0.45

Tested by 15

ValidUidAcceptedMethod · 0.64
EmptyUidRejectedMethod · 0.64
TooLongUidRejectedMethod · 0.64
GetNodeByUidMethod · 0.64
GetNodeNotFoundMethod · 0.64
BuildEndpointRegistryMethod · 0.64
NodeFieldTypesCorrectMethod · 0.64