From c82d370e32cc5e5082a950ae3916a2cb955c9c38 Mon Sep 17 00:00:00 2001 From: zubaira Date: Thu, 30 Nov 2023 11:36:25 +0100 Subject: [PATCH 1/4] redirect from old icon endpoint --- .../dhis/webapi/controller/icon/IconController.java | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/dhis-2/dhis-web-api/src/main/java/org/hisp/dhis/webapi/controller/icon/IconController.java b/dhis-2/dhis-web-api/src/main/java/org/hisp/dhis/webapi/controller/icon/IconController.java index e780fd525a1a..34e47edf28e3 100644 --- a/dhis-2/dhis-web-api/src/main/java/org/hisp/dhis/webapi/controller/icon/IconController.java +++ b/dhis-2/dhis-web-api/src/main/java/org/hisp/dhis/webapi/controller/icon/IconController.java @@ -34,6 +34,7 @@ import java.util.List; import java.util.Set; import java.util.concurrent.TimeUnit; +import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; import lombok.RequiredArgsConstructor; import lombok.extern.slf4j.Slf4j; @@ -56,6 +57,7 @@ import org.hisp.dhis.icon.IconService; import org.hisp.dhis.schema.descriptors.IconSchemaDescriptor; import org.hisp.dhis.webapi.mvc.annotation.ApiVersion; +import org.hisp.dhis.webapi.utils.ContextUtils; import org.hisp.dhis.webapi.utils.HeaderUtils; import org.springframework.core.io.Resource; import org.springframework.http.CacheControl; @@ -100,9 +102,11 @@ public class IconController { } @GetMapping("/{iconKey}/icon.svg") - public void getIconData(HttpServletResponse response, @PathVariable String iconKey) - throws IOException, NotFoundException { - downloadDefaultIcon(iconKey, response); + public void getIconData( + HttpServletResponse response, HttpServletRequest request, @PathVariable String iconKey) + throws IOException { + String location = response.encodeRedirectURL("/{key}/icon"); + response.sendRedirect(ContextUtils.getRootPath(request) + location); } @GetMapping(value = "/{key}/icon") From 9649386f964dde7479324f2d7f3379421c5a186e Mon Sep 17 00:00:00 2001 From: zubaira Date: Thu, 30 Nov 2023 11:40:23 +0100 Subject: [PATCH 2/4] iconkey --- .../org/hisp/dhis/webapi/controller/icon/IconController.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/dhis-2/dhis-web-api/src/main/java/org/hisp/dhis/webapi/controller/icon/IconController.java b/dhis-2/dhis-web-api/src/main/java/org/hisp/dhis/webapi/controller/icon/IconController.java index 34e47edf28e3..d1c8b5767925 100644 --- a/dhis-2/dhis-web-api/src/main/java/org/hisp/dhis/webapi/controller/icon/IconController.java +++ b/dhis-2/dhis-web-api/src/main/java/org/hisp/dhis/webapi/controller/icon/IconController.java @@ -105,7 +105,7 @@ public class IconController { public void getIconData( HttpServletResponse response, HttpServletRequest request, @PathVariable String iconKey) throws IOException { - String location = response.encodeRedirectURL("/{key}/icon"); + String location = response.encodeRedirectURL("/" + iconKey + "/icon"); response.sendRedirect(ContextUtils.getRootPath(request) + location); } From 5bfa1914216a69fe24c541fbb133df8e10a60aa7 Mon Sep 17 00:00:00 2001 From: zubaira Date: Mon, 4 Dec 2023 21:44:18 +0100 Subject: [PATCH 3/4] correct URL --- .../org/hisp/dhis/webapi/controller/icon/IconController.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/dhis-2/dhis-web-api/src/main/java/org/hisp/dhis/webapi/controller/icon/IconController.java b/dhis-2/dhis-web-api/src/main/java/org/hisp/dhis/webapi/controller/icon/IconController.java index d1c8b5767925..a2cfc6e42b12 100644 --- a/dhis-2/dhis-web-api/src/main/java/org/hisp/dhis/webapi/controller/icon/IconController.java +++ b/dhis-2/dhis-web-api/src/main/java/org/hisp/dhis/webapi/controller/icon/IconController.java @@ -105,7 +105,7 @@ public class IconController { public void getIconData( HttpServletResponse response, HttpServletRequest request, @PathVariable String iconKey) throws IOException { - String location = response.encodeRedirectURL("/" + iconKey + "/icon"); + String location = response.encodeRedirectURL("/icons/" + iconKey + "/icon"); response.sendRedirect(ContextUtils.getRootPath(request) + location); } From 18129798987721105f83c81305db6f023716ee91 Mon Sep 17 00:00:00 2001 From: zubaira Date: Tue, 5 Dec 2023 09:52:01 +0100 Subject: [PATCH 4/4] add deprecated --- .../org/hisp/dhis/webapi/controller/icon/IconController.java | 1 + 1 file changed, 1 insertion(+) diff --git a/dhis-2/dhis-web-api/src/main/java/org/hisp/dhis/webapi/controller/icon/IconController.java b/dhis-2/dhis-web-api/src/main/java/org/hisp/dhis/webapi/controller/icon/IconController.java index a2cfc6e42b12..431846cf09e1 100644 --- a/dhis-2/dhis-web-api/src/main/java/org/hisp/dhis/webapi/controller/icon/IconController.java +++ b/dhis-2/dhis-web-api/src/main/java/org/hisp/dhis/webapi/controller/icon/IconController.java @@ -102,6 +102,7 @@ public class IconController { } @GetMapping("/{iconKey}/icon.svg") + @Deprecated public void getIconData( HttpServletResponse response, HttpServletRequest request, @PathVariable String iconKey) throws IOException {