From 485a83253e44ee16dfc94828dfd96d755ae73a24 Mon Sep 17 00:00:00 2001 From: Zubair Asghar Date: Tue, 5 Dec 2023 14:08:52 +0500 Subject: [PATCH] chore: add Redirect from old icon endpoint to the new one [DHIS2-16042] --- .../dhis/webapi/controller/icon/IconController.java | 11 ++++++++--- 1 file changed, 8 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..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 @@ -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,12 @@ public class IconController { } @GetMapping("/{iconKey}/icon.svg") - public void getIconData(HttpServletResponse response, @PathVariable String iconKey) - throws IOException, NotFoundException { - downloadDefaultIcon(iconKey, response); + @Deprecated + public void getIconData( + HttpServletResponse response, HttpServletRequest request, @PathVariable String iconKey) + throws IOException { + String location = response.encodeRedirectURL("/icons/" + iconKey + "/icon"); + response.sendRedirect(ContextUtils.getRootPath(request) + location); } @GetMapping(value = "/{key}/icon")