Alexander Wels has uploaded a new change for review. Change subject: userportal,webadmin: brand 404 error pages. ......................................................................
userportal,webadmin: brand 404 error pages. - Fixed broken 404 error page style sheet links. - Used same styling for 404 error pages as the welcome page. Change-Id: I3b0406ab6dea4a2cacebd4ad6e62c8bb7a0d44c0 Signed-off-by: Alexander Wels <[email protected]> --- D backend/manager/modules/root/src/main/webapp/404.html A backend/manager/modules/root/src/main/webapp/WEB-INF/404.jsp M backend/manager/modules/root/src/main/webapp/WEB-INF/web.xml A backend/manager/modules/utils/src/main/java/org/ovirt/engine/core/utils/servlet/FileNotFoundServlet.java D frontend/webadmin/modules/userportal-gwtp/src/main/webapp/404.html A frontend/webadmin/modules/userportal-gwtp/src/main/webapp/WEB-INF/404.jsp M frontend/webadmin/modules/userportal-gwtp/src/main/webapp/WEB-INF/web.xml D frontend/webadmin/modules/webadmin/src/main/webapp/404.html A frontend/webadmin/modules/webadmin/src/main/webapp/WEB-INF/404.jsp M frontend/webadmin/modules/webadmin/src/main/webapp/WEB-INF/web.xml 10 files changed, 201 insertions(+), 66 deletions(-) git pull ssh://gerrit.ovirt.org:29418/ovirt-engine refs/changes/96/18196/1 diff --git a/backend/manager/modules/root/src/main/webapp/404.html b/backend/manager/modules/root/src/main/webapp/404.html deleted file mode 100644 index 1bb4782..0000000 --- a/backend/manager/modules/root/src/main/webapp/404.html +++ /dev/null @@ -1,22 +0,0 @@ -<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" - "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> -<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en"> -<head> -<meta http-equiv="refresh" content="0;URL='/ovirt-engine'" /> -<meta http-equiv="Content-type" content="text/html; charset=utf-8" /> -<title>oVirt-Engine</title> -<link rel="stylesheet" href="/ovirt-engine-style.css" type="text/css" media="screen, projection" charset="utf-8" /> -</head> -<body> - <div> - <div class="left"> - </div> - <div class="center"> - </div> - </div> - <div class="main"> - <h2><span class="fakeH2">Page not found.</span></h2> - Press <a href="/ovirt-engine">here</a> to continue. - </div> -</body> -</html> diff --git a/backend/manager/modules/root/src/main/webapp/WEB-INF/404.jsp b/backend/manager/modules/root/src/main/webapp/WEB-INF/404.jsp new file mode 100644 index 0000000..6e3bccc --- /dev/null +++ b/backend/manager/modules/root/src/main/webapp/WEB-INF/404.jsp @@ -0,0 +1,34 @@ +<%@ page pageEncoding="UTF-8" session="false" %> +<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %> +<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" + "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> +<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en"> +<head> +<!-- <meta http-equiv="refresh" content="0;URL='/ovirt-engine'" /> --> +<meta http-equiv="Content-type" content="text/html; charset=utf-8" /> +<title>Page not found</title> + <c:if test="${requestScope['brandingStyle'] != null}"> + <c:forEach items="${requestScope['brandingStyle']}" var="theme"> + <c:if test="${theme.getThemeStyleSheet(requestScope['applicationType']) != null}"> + <link rel="stylesheet" type="text/css" href="${pageContext.request.contextPath}/ovirt-engine-theme${theme.path}/${theme.getThemeStyleSheet(requestScope['applicationType'])}"> + </c:if> + </c:forEach> + </c:if> +</head> +<body> + <div> + <div class="obrand_left"> + <div class="obrand_header_nav"> + </div> + </div> + <div class="obrand_right"> + </div> + <div class="obrand_center"> + </div> + </div> + <div class="obrand_main"> + <h2><span class="obrand_section_header">Page not found.</span></h2> + Press <a href="/ovirt-engine">here</a> to continue. + </div> +</body> +</html> diff --git a/backend/manager/modules/root/src/main/webapp/WEB-INF/web.xml b/backend/manager/modules/root/src/main/webapp/WEB-INF/web.xml index b797367..77bbb60 100644 --- a/backend/manager/modules/root/src/main/webapp/WEB-INF/web.xml +++ b/backend/manager/modules/root/src/main/webapp/WEB-INF/web.xml @@ -245,6 +245,16 @@ <url-pattern>/ovirt-engine-theme/*</url-pattern> </servlet-mapping> + <!-- FileNotFound Servlet --> + <servlet> + <servlet-name>FileNotFoundServlet</servlet-name> + <servlet-class>org.ovirt.engine.core.utils.servlet.FileNotFoundServlet</servlet-class> + </servlet> + <servlet-mapping> + <servlet-name>FileNotFoundServlet</servlet-name> + <url-pattern>/404.html</url-pattern> + </servlet-mapping> + <!-- Filters --> <filter> <filter-name>LocaleFilter</filter-name> diff --git a/backend/manager/modules/utils/src/main/java/org/ovirt/engine/core/utils/servlet/FileNotFoundServlet.java b/backend/manager/modules/utils/src/main/java/org/ovirt/engine/core/utils/servlet/FileNotFoundServlet.java new file mode 100644 index 0000000..346cd20 --- /dev/null +++ b/backend/manager/modules/utils/src/main/java/org/ovirt/engine/core/utils/servlet/FileNotFoundServlet.java @@ -0,0 +1,68 @@ +/** + * + */ +package org.ovirt.engine.core.utils.servlet; + +import java.io.IOException; +import java.util.List; + +import javax.servlet.RequestDispatcher; +import javax.servlet.ServletException; +import javax.servlet.http.HttpServlet; +import javax.servlet.http.HttpServletRequest; +import javax.servlet.http.HttpServletResponse; + +import org.ovirt.engine.core.utils.branding.BrandingManager; +import org.ovirt.engine.core.utils.branding.BrandingTheme; + +/** + * This Servlet renders a branded 404 error page. + */ +public class FileNotFoundServlet extends HttpServlet { + /** + * serialVersionIUD. + */ + private static final long serialVersionUID = 854039610705171243L; + + /** + * Application type attribute key. + */ + private static final String APPLICATION_TYPE = "applicationType"; + + /** + * Branding theme attribute key. + */ + private static final String THEMES_KEY = "brandingStyle"; + + /** + * The branding manager used to look up the style sheet. + */ + private BrandingManager brandingManager; + + @Override + public void init() { + init(BrandingManager.getInstance()); + } + + /** + * Init that takes a branding manager as parameter. + * @param initBrandingManager the branding manager to use with the initialization of the servlet. + */ + void init(final BrandingManager initBrandingManager) { + this.brandingManager = initBrandingManager; + } + + @Override + public void doGet(final HttpServletRequest request, final HttpServletResponse response) throws IOException, + ServletException { + request.setAttribute(APPLICATION_TYPE, BrandingTheme.ApplicationType.WELCOME); + List<BrandingTheme> brandingThemes = brandingManager.getBrandingThemes(); + request.setAttribute(THEMES_KEY, brandingThemes); + RequestDispatcher dispatcher = request.getRequestDispatcher("/WEB-INF/404.jsp"); + response.setContentType("text/html;charset=UTF-8"); + if (dispatcher != null) { + dispatcher.include(request, response); + } + } + +} diff --git a/frontend/webadmin/modules/userportal-gwtp/src/main/webapp/404.html b/frontend/webadmin/modules/userportal-gwtp/src/main/webapp/404.html deleted file mode 100644 index 1bb4782..0000000 --- a/frontend/webadmin/modules/userportal-gwtp/src/main/webapp/404.html +++ /dev/null @@ -1,22 +0,0 @@ -<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" - "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> -<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en"> -<head> -<meta http-equiv="refresh" content="0;URL='/ovirt-engine'" /> -<meta http-equiv="Content-type" content="text/html; charset=utf-8" /> -<title>oVirt-Engine</title> -<link rel="stylesheet" href="/ovirt-engine-style.css" type="text/css" media="screen, projection" charset="utf-8" /> -</head> -<body> - <div> - <div class="left"> - </div> - <div class="center"> - </div> - </div> - <div class="main"> - <h2><span class="fakeH2">Page not found.</span></h2> - Press <a href="/ovirt-engine">here</a> to continue. - </div> -</body> -</html> diff --git a/frontend/webadmin/modules/userportal-gwtp/src/main/webapp/WEB-INF/404.jsp b/frontend/webadmin/modules/userportal-gwtp/src/main/webapp/WEB-INF/404.jsp new file mode 100644 index 0000000..1cf3dff --- /dev/null +++ b/frontend/webadmin/modules/userportal-gwtp/src/main/webapp/WEB-INF/404.jsp @@ -0,0 +1,34 @@ +<%@ page pageEncoding="UTF-8" session="false" %> +<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %> +<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" + "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> +<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en"> +<head> +<!-- <meta http-equiv="refresh" content="0;URL='/ovirt-engine'" /> --> +<meta http-equiv="Content-type" content="text/html; charset=utf-8" /> +<title>Page not found</title> + <c:if test="${requestScope['brandingStyle'] != null}"> + <c:forEach items="${requestScope['brandingStyle']}" var="theme"> + <c:if test="${theme.getThemeStyleSheet(requestScope['applicationType']) != null}"> + <link rel="stylesheet" type="text/css" href="${pageContext.request.contextPath}/theme${theme.path}/${theme.getThemeStyleSheet(requestScope['applicationType'])}"> + </c:if> + </c:forEach> + </c:if> +</head> +<body> + <div> + <div class="obrand_left"> + <div class="obrand_header_nav"> + </div> + </div> + <div class="obrand_right"> + </div> + <div class="obrand_center"> + </div> + </div> + <div class="obrand_main"> + <h2><span class="obrand_section_header">Page not found.</span></h2> + Press <a href="/ovirt-engine">here</a> to continue. + </div> +</body> +</html> diff --git a/frontend/webadmin/modules/userportal-gwtp/src/main/webapp/WEB-INF/web.xml b/frontend/webadmin/modules/userportal-gwtp/src/main/webapp/WEB-INF/web.xml index 44a0f17..ef47e79 100644 --- a/frontend/webadmin/modules/userportal-gwtp/src/main/webapp/WEB-INF/web.xml +++ b/frontend/webadmin/modules/userportal-gwtp/src/main/webapp/WEB-INF/web.xml @@ -30,6 +30,16 @@ <url-pattern>/theme/*</url-pattern> </servlet-mapping> + <!-- FileNotFound Servlet --> + <servlet> + <servlet-name>FileNotFoundServlet</servlet-name> + <servlet-class>org.ovirt.engine.core.utils.servlet.FileNotFoundServlet</servlet-class> + </servlet> + <servlet-mapping> + <servlet-name>FileNotFoundServlet</servlet-name> + <url-pattern>/404.html</url-pattern> + </servlet-mapping> + <!-- Default page to serve --> <welcome-file-list> <welcome-file>index.html</welcome-file> diff --git a/frontend/webadmin/modules/webadmin/src/main/webapp/404.html b/frontend/webadmin/modules/webadmin/src/main/webapp/404.html deleted file mode 100644 index 1bb4782..0000000 --- a/frontend/webadmin/modules/webadmin/src/main/webapp/404.html +++ /dev/null @@ -1,22 +0,0 @@ -<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" - "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> -<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en"> -<head> -<meta http-equiv="refresh" content="0;URL='/ovirt-engine'" /> -<meta http-equiv="Content-type" content="text/html; charset=utf-8" /> -<title>oVirt-Engine</title> -<link rel="stylesheet" href="/ovirt-engine-style.css" type="text/css" media="screen, projection" charset="utf-8" /> -</head> -<body> - <div> - <div class="left"> - </div> - <div class="center"> - </div> - </div> - <div class="main"> - <h2><span class="fakeH2">Page not found.</span></h2> - Press <a href="/ovirt-engine">here</a> to continue. - </div> -</body> -</html> diff --git a/frontend/webadmin/modules/webadmin/src/main/webapp/WEB-INF/404.jsp b/frontend/webadmin/modules/webadmin/src/main/webapp/WEB-INF/404.jsp new file mode 100644 index 0000000..1cf3dff --- /dev/null +++ b/frontend/webadmin/modules/webadmin/src/main/webapp/WEB-INF/404.jsp @@ -0,0 +1,34 @@ +<%@ page pageEncoding="UTF-8" session="false" %> +<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %> +<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" + "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> +<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en"> +<head> +<!-- <meta http-equiv="refresh" content="0;URL='/ovirt-engine'" /> --> +<meta http-equiv="Content-type" content="text/html; charset=utf-8" /> +<title>Page not found</title> + <c:if test="${requestScope['brandingStyle'] != null}"> + <c:forEach items="${requestScope['brandingStyle']}" var="theme"> + <c:if test="${theme.getThemeStyleSheet(requestScope['applicationType']) != null}"> + <link rel="stylesheet" type="text/css" href="${pageContext.request.contextPath}/theme${theme.path}/${theme.getThemeStyleSheet(requestScope['applicationType'])}"> + </c:if> + </c:forEach> + </c:if> +</head> +<body> + <div> + <div class="obrand_left"> + <div class="obrand_header_nav"> + </div> + </div> + <div class="obrand_right"> + </div> + <div class="obrand_center"> + </div> + </div> + <div class="obrand_main"> + <h2><span class="obrand_section_header">Page not found.</span></h2> + Press <a href="/ovirt-engine">here</a> to continue. + </div> +</body> +</html> diff --git a/frontend/webadmin/modules/webadmin/src/main/webapp/WEB-INF/web.xml b/frontend/webadmin/modules/webadmin/src/main/webapp/WEB-INF/web.xml index eb8167a..5d3adc4 100644 --- a/frontend/webadmin/modules/webadmin/src/main/webapp/WEB-INF/web.xml +++ b/frontend/webadmin/modules/webadmin/src/main/webapp/WEB-INF/web.xml @@ -34,6 +34,17 @@ <servlet-name>BrandingServlet</servlet-name> <url-pattern>/theme/*</url-pattern> </servlet-mapping> + + <!-- FileNotFound Servlet --> + <servlet> + <servlet-name>FileNotFoundServlet</servlet-name> + <servlet-class>org.ovirt.engine.core.utils.servlet.FileNotFoundServlet</servlet-class> + </servlet> + <servlet-mapping> + <servlet-name>FileNotFoundServlet</servlet-name> + <url-pattern>/404.html</url-pattern> + </servlet-mapping> + <!-- Default page to serve --> <welcome-file-list> <welcome-file>index.html</welcome-file> -- To view, visit http://gerrit.ovirt.org/18196 To unsubscribe, visit http://gerrit.ovirt.org/settings Gerrit-MessageType: newchange Gerrit-Change-Id: I3b0406ab6dea4a2cacebd4ad6e62c8bb7a0d44c0 Gerrit-PatchSet: 1 Gerrit-Project: ovirt-engine Gerrit-Branch: master Gerrit-Owner: Alexander Wels <[email protected]> _______________________________________________ Engine-patches mailing list [email protected] http://lists.ovirt.org/mailman/listinfo/engine-patches
