From c5c657c449b751d52d1864b770a35e3a5535d7c2 Mon Sep 17 00:00:00 2001 From: Jens Pelzetter Date: Mon, 11 Jan 2021 21:30:40 +0100 Subject: [PATCH] Some small improvements concerning some URLs --- .../ui/ContentSectionsController.java | 35 +++++++++++++++---- .../content-sections/content-sections.xhtml | 6 ++-- .../librecms/ui/content-sections/list.xhtml | 2 +- 3 files changed, 33 insertions(+), 10 deletions(-) diff --git a/ccm-cms/src/main/java/org/librecms/ui/ContentSectionsController.java b/ccm-cms/src/main/java/org/librecms/ui/ContentSectionsController.java index 833138d28..6ad132aed 100644 --- a/ccm-cms/src/main/java/org/librecms/ui/ContentSectionsController.java +++ b/ccm-cms/src/main/java/org/librecms/ui/ContentSectionsController.java @@ -7,12 +7,17 @@ package org.librecms.ui; import org.libreccm.security.AuthorizationRequired; +import java.net.URI; +import java.net.URISyntaxException; + import javax.enterprise.context.RequestScoped; import javax.inject.Inject; import javax.mvc.Controller; +import javax.servlet.ServletContext; import javax.servlet.http.HttpServletRequest; import javax.ws.rs.GET; import javax.ws.rs.Path; +import javax.ws.rs.WebApplicationException; import javax.ws.rs.core.Response; /** @@ -26,17 +31,35 @@ public class ContentSectionsController { @Inject private HttpServletRequest request; + + @Inject + private ServletContext servletContext; @GET @Path("/") @AuthorizationRequired public Response getRoot() { - return Response - .status(Response.Status.MOVED_PERMANENTLY) - .entity( - String.format("%s/@content-sections/list", request - .getContextPath()) + try { + return Response.seeOther( + new URI( + request.getScheme(), + "", + request.getServerName(), + request.getServerPort(), + String.format( + "%s/@content-sections/list", + request.getContextPath() + ), + "", + "" + ) ).build(); + } catch (URISyntaxException ex) { + throw new WebApplicationException(ex); + } +// return String.format( +// "redirect:/%s/@content-sections/list", request.getContextPath() +// ); } @GET @@ -57,7 +80,7 @@ public class ContentSectionsController { @Path("/search") @AuthorizationRequired public String getSearch() { - return "org/librecms/ui/content-sections/pages.xhtml"; + return "org/librecms/ui/content-sections/search.xhtml"; } } diff --git a/ccm-cms/src/main/resources/WEB-INF/views/org/librecms/ui/content-sections/content-sections.xhtml b/ccm-cms/src/main/resources/WEB-INF/views/org/librecms/ui/content-sections/content-sections.xhtml index 7703dba93..124fa8acb 100644 --- a/ccm-cms/src/main/resources/WEB-INF/views/org/librecms/ui/content-sections/content-sections.xhtml +++ b/ccm-cms/src/main/resources/WEB-INF/views/org/librecms/ui/content-sections/content-sections.xhtml @@ -28,21 +28,21 @@