From 6d7f082a6b7c5159725323d1c97030c7f7d21322 Mon Sep 17 00:00:00 2001 From: Mohamed Rashd Date: Tue, 1 Mar 2022 09:36:52 +0530 Subject: [PATCH 1/2] Fix grafana translation not working properly --- .../java/io/entgra/ui/request/interceptor/GrafanaHandler.java | 2 ++ .../io/entgra/ui/request/interceptor/util/HandlerConstants.java | 2 +- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/components/ui-request-interceptor/io.entgra.ui.request.interceptor/src/main/java/io/entgra/ui/request/interceptor/GrafanaHandler.java b/components/ui-request-interceptor/io.entgra.ui.request.interceptor/src/main/java/io/entgra/ui/request/interceptor/GrafanaHandler.java index 3ac99b10443..6cd8872eae0 100644 --- a/components/ui-request-interceptor/io.entgra.ui.request.interceptor/src/main/java/io/entgra/ui/request/interceptor/GrafanaHandler.java +++ b/components/ui-request-interceptor/io.entgra.ui.request.interceptor/src/main/java/io/entgra/ui/request/interceptor/GrafanaHandler.java @@ -48,6 +48,7 @@ import java.io.IOException; import java.io.InputStream; import java.io.OutputStream; import java.net.URI; +import java.nio.charset.StandardCharsets; @MultipartConfig @WebServlet( @@ -150,6 +151,7 @@ public class GrafanaHandler extends HttpServlet { resp.setContentType(contentType); resp.setStatus(grafanaAPIResponse.getCode()); addXFrameOptionsHeaders(resp); + resp.setCharacterEncoding(StandardCharsets.UTF_8.name()); resp.getWriter().print(grafanaAPIResponse.getData()); } diff --git a/components/ui-request-interceptor/io.entgra.ui.request.interceptor/src/main/java/io/entgra/ui/request/interceptor/util/HandlerConstants.java b/components/ui-request-interceptor/io.entgra.ui.request.interceptor/src/main/java/io/entgra/ui/request/interceptor/util/HandlerConstants.java index df0e085b0a5..153ace868a8 100644 --- a/components/ui-request-interceptor/io.entgra.ui.request.interceptor/src/main/java/io/entgra/ui/request/interceptor/util/HandlerConstants.java +++ b/components/ui-request-interceptor/io.entgra.ui.request.interceptor/src/main/java/io/entgra/ui/request/interceptor/util/HandlerConstants.java @@ -84,7 +84,7 @@ public class HandlerConstants { public static final String WSS_PROTOCOL = "wss"; public static final String WS_PROTOCOL = "ws"; public static final String REMOTE_SESSION_CONTEXT = "/remote/session/clients"; - public static final String GRAFANA_API = "/api/device-mgt/v1.0/reports/grafana"; + public static final String GRAFANA_API = "/api/grafana-mgt/v1.0"; public static final String IOT_CORE_HOST_ENV_VAR = "iot.core.host"; public static final String IOT_CORE_HTTP_PORT_ENV_VAR = "iot.core.http.port"; From b512ff054813a0419331a09cd7921eae6d987404 Mon Sep 17 00:00:00 2001 From: Mohamed Rashd Date: Fri, 4 Mar 2022 16:45:48 +0530 Subject: [PATCH 2/2] Fix grafana translation not working properly --- .../proxy/api/service/impl/util/GrafanaRequestHandlerUtil.java | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/components/analytics-mgt/grafana-mgt/io.entgra.analytics.mgt.grafana.proxy.api/src/main/java/io/entgra/analytics/mgt/grafana/proxy/api/service/impl/util/GrafanaRequestHandlerUtil.java b/components/analytics-mgt/grafana-mgt/io.entgra.analytics.mgt.grafana.proxy.api/src/main/java/io/entgra/analytics/mgt/grafana/proxy/api/service/impl/util/GrafanaRequestHandlerUtil.java index 064ea037f46..e4d17265a8c 100644 --- a/components/analytics-mgt/grafana-mgt/io.entgra.analytics.mgt.grafana.proxy.api/src/main/java/io/entgra/analytics/mgt/grafana/proxy/api/service/impl/util/GrafanaRequestHandlerUtil.java +++ b/components/analytics-mgt/grafana-mgt/io.entgra.analytics.mgt.grafana.proxy.api/src/main/java/io/entgra/analytics/mgt/grafana/proxy/api/service/impl/util/GrafanaRequestHandlerUtil.java @@ -46,6 +46,7 @@ import javax.ws.rs.core.UriInfo; import java.io.IOException; import java.io.UnsupportedEncodingException; import java.net.URI; +import java.nio.charset.StandardCharsets; import java.util.List; import java.util.Map; @@ -138,7 +139,7 @@ public class GrafanaRequestHandlerUtil { } public static void setRequestEntity(HttpPost postRequest, JsonObject body) throws UnsupportedEncodingException { - StringEntity bodyEntity = new StringEntity(body.toString()); + StringEntity bodyEntity = new StringEntity(body.toString(), StandardCharsets.UTF_8); bodyEntity.setContentType(MediaType.APPLICATION_JSON); postRequest.setEntity(bodyEntity); }