From b5362533d09d330611880083b8e0a4165df875eb Mon Sep 17 00:00:00 2001 From: JordenReuter <149687553+JordenReuter@users.noreply.github.com> Date: Wed, 29 May 2024 10:46:53 +0200 Subject: [PATCH] Fix/p002271 7326 exception mapper (#32) * feat: added product base paths to routes * fix: exception mapper --- .../tkit/onecx/shell/bff/rs/mappers/ExceptionMapper.java | 2 +- .../shell/bff/rs/mappers/WorkspaceConfigMapper.java | 9 +++++---- 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/src/main/java/org/tkit/onecx/shell/bff/rs/mappers/ExceptionMapper.java b/src/main/java/org/tkit/onecx/shell/bff/rs/mappers/ExceptionMapper.java index cccc928..87251b1 100644 --- a/src/main/java/org/tkit/onecx/shell/bff/rs/mappers/ExceptionMapper.java +++ b/src/main/java/org/tkit/onecx/shell/bff/rs/mappers/ExceptionMapper.java @@ -36,7 +36,7 @@ default Response clientException(ClientWebApplicationException ex) { return Response.status(400).build(); } else { if (ex.getResponse().getMediaType() != null - && ex.getResponse().getMediaType().toString().equals(APPLICATION_JSON)) { + && ex.getResponse().getMediaType().toString().contains(APPLICATION_JSON)) { return Response.status(ex.getResponse().getStatus()) .entity(map(ex.getResponse().readEntity(ProblemDetailResponse.class))).build(); } else { diff --git a/src/main/java/org/tkit/onecx/shell/bff/rs/mappers/WorkspaceConfigMapper.java b/src/main/java/org/tkit/onecx/shell/bff/rs/mappers/WorkspaceConfigMapper.java index ed19c84..360593e 100644 --- a/src/main/java/org/tkit/onecx/shell/bff/rs/mappers/WorkspaceConfigMapper.java +++ b/src/main/java/org/tkit/onecx/shell/bff/rs/mappers/WorkspaceConfigMapper.java @@ -94,13 +94,14 @@ default String componentName(String productName, String appId, String exposedMod @Mapping(target = "endpoints", source = "mfe.endpoints") @Mapping(target = "elementName", source = "mfe.tagName") RouteDTO createRoute(LoadProductItemPSV1 product, LoadProductMicrofrontendPSV1 mfe, Map pathMapping, - WorkspaceWrapper workspace); + WorkspaceWrapper workspace, String productBaseUrl); @AfterMapping - default void createRouteAfter(@MappingTarget RouteDTO target, Map pathMapping, WorkspaceWrapper workspace) { + default void createRouteAfter(@MappingTarget RouteDTO target, Map pathMapping, WorkspaceWrapper workspace, + String productBaseUrl) { var modulePath = pathMapping.get(target.getAppId()); if (modulePath != null) { - target.setBaseUrl(workspace.getBaseUrl() + modulePath); + target.setBaseUrl(workspace.getBaseUrl() + productBaseUrl + modulePath); } } @@ -159,7 +160,7 @@ default void createMfeAndComponents(LoadWorkspaceConfigResponseDTO result, Works if (product.getMicrofrontends() != null) { product.getMicrofrontends().forEach(mfe -> { if (mfe.getType() == MODULE) { - result.addRoutesItem(createRoute(product, mfe, pathMapping, wrapper)); + result.addRoutesItem(createRoute(product, mfe, pathMapping, wrapper, workspaceProduct.getBaseUrl())); } else if (mfe.getType() == MicrofrontendTypePSV1.COMPONENT) { result.addComponentsItem(createComponent(product, mfe)); }