| 1572 | } |
| 1573 | |
| 1574 | void RenderingController::HandleGET_mxnInfo(const httplib::Request& req, httplib::Response& res) const |
| 1575 | { |
| 1576 | // Mirrors the stdmulti editor-info handler: walk the editor list, locate |
| 1577 | // the mxn entry, 503 EDITOR_NOT_ACTIVE if the editor is not open, 200 with |
| 1578 | // the windows list otherwise. |
| 1579 | if (m_RenderWindowBridge == nullptr || !m_RenderWindowBridge->HasEditorListProvider()) |
| 1580 | { |
| 1581 | const auto error = ErrorResponse::RenderWindowNotAvailable(req.path); |
| 1582 | this->SendErrorResponse(res, 503, error); |
| 1583 | return; |
| 1584 | } |
| 1585 | |
| 1586 | std::vector<EditorInfo> editors; |
| 1587 | try |
| 1588 | { |
| 1589 | editors = m_RenderWindowBridge->ListEditors(); |
| 1590 | } |
| 1591 | catch (const mitk::Exception& e) |
| 1592 | { |
| 1593 | // mitk::Exception from the bridge layer signals a binding-contract |
| 1594 | // violation surfaced via mitkThrow (e.g. an MxN cell that violates the |
| 1595 | // v2 view_direction invariant when the editor info is materialised). |
| 1596 | // Map to 422 RENDERING_ERROR -- the request shape was valid; the |
| 1597 | // rendering backend reports an unrecoverable state. The generic |
| 1598 | // MapBridgeException below would otherwise emit 500 INTERNAL_ERROR, |
| 1599 | // which is the wrong status class for a downstream contract failure. |
| 1600 | const auto error = ErrorResponse::RenderingError(e.what(), req.path); |
| 1601 | this->SendErrorResponse(res, 422, error); |
| 1602 | return; |
| 1603 | } |
| 1604 | catch (const std::exception& e) |
| 1605 | { |
| 1606 | const auto [status, payload] = MapBridgeException(e, req.path); |
| 1607 | this->SendErrorResponse(res, status, payload); |
| 1608 | return; |
| 1609 | } |
| 1610 | |
| 1611 | for (const auto& ed : editors) |
| 1612 | { |
| 1613 | if (ed.alias == "mxn") |
| 1614 | { |
| 1615 | if (!ed.active) |
| 1616 | { |
| 1617 | const auto error = ErrorResponse::EditorNotActive( |
| 1618 | "MxNMultiWidgetEditor is not open", req.path); |
| 1619 | this->SendErrorResponse(res, 503, error); |
| 1620 | return; |
| 1621 | } |
| 1622 | const auto j = EditorInfoToJson(ed, /*includeWindowList=*/true); |
| 1623 | res.status = 200; |
| 1624 | res.set_content(j.dump(), "application/json"); |
| 1625 | return; |
| 1626 | } |
| 1627 | } |
| 1628 | |
| 1629 | // Provider returned a list that omits the "mxn" alias: the MxN editor |
| 1630 | // surface is unavailable from this workbench. Surface as 503 so clients |
| 1631 | // treat it the same as "no provider registered" (feature unavailable), |