Ravi Nori has uploaded a new change for review. Change subject: core : Don't display link to the Reports portal if reports are not installed ......................................................................
core : Don't display link to the Reports portal if reports are not installed When reports is not installed the link from /ovirt-engine/ page takes you to 404 page when user clicks on reports link. A custom error page is displayed that shows the message that reports is not installed Change-Id: Idaed902328695e2d448ac49c414ddfbde8d3fd25 Bug-Url: https://bugzilla.redhat.com/1143998 Signed-off-by: Ravi Nori <rn...@redhat.com> --- M backend/manager/modules/services/src/main/webapp/WEB-INF/web.xml M backend/manager/modules/utils/src/main/java/org/ovirt/engine/core/utils/servlet/RedirectServlet.java M backend/manager/modules/welcome/src/main/resources/messages.properties A backend/manager/modules/welcome/src/main/webapp/WEB-INF/ReportsNotInstalled.jsp M backend/manager/modules/welcome/src/main/webapp/WEB-INF/web.xml M packaging/services/ovirt-engine/ovirt-engine.conf.in 6 files changed, 77 insertions(+), 9 deletions(-) git pull ssh://gerrit.ovirt.org:29418/ovirt-engine refs/changes/18/33218/1 diff --git a/backend/manager/modules/services/src/main/webapp/WEB-INF/web.xml b/backend/manager/modules/services/src/main/webapp/WEB-INF/web.xml index 7aad30f..7b5c676 100644 --- a/backend/manager/modules/services/src/main/webapp/WEB-INF/web.xml +++ b/backend/manager/modules/services/src/main/webapp/WEB-INF/web.xml @@ -62,6 +62,10 @@ <param-name>url</param-name> <param-value>%{ENGINE_REPORTS_DASHBOARD_URL}</param-value> </init-param> + <init-param> + <param-name>url404</param-name> + <param-value>%{ENGINE_REPORTS_NOT_INSTALLED_URL}</param-value> + </init-param> </servlet> <servlet-mapping> <servlet-name>reports-redirect</servlet-name> diff --git a/backend/manager/modules/utils/src/main/java/org/ovirt/engine/core/utils/servlet/RedirectServlet.java b/backend/manager/modules/utils/src/main/java/org/ovirt/engine/core/utils/servlet/RedirectServlet.java index 51285b1..a714319 100644 --- a/backend/manager/modules/utils/src/main/java/org/ovirt/engine/core/utils/servlet/RedirectServlet.java +++ b/backend/manager/modules/utils/src/main/java/org/ovirt/engine/core/utils/servlet/RedirectServlet.java @@ -27,8 +27,10 @@ private static final long serialVersionUID = -1794616863361241804L; private static final String URL = "url"; + private static final String URL404 = "url404"; private String url; + private String url404; @Override public void init(ServletConfig config) throws ServletException { @@ -36,19 +38,24 @@ // we use %{x} convention to avoid conflict with jboss properties url = EngineLocalConfig.getInstance().expandString(config.getInitParameter(URL).replaceAll("%\\{", "\\${")); + url404 = EngineLocalConfig.getInstance().expandString(config.getInitParameter(URL404).replaceAll("%\\{", "\\${")); } @Override protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { String redirectUrl = url; - String queryString = request.getQueryString(); - if (StringUtils.isNotEmpty(queryString)) { - if (redirectUrl.indexOf("?") == -1) { - redirectUrl += "?"; - } else { - redirectUrl += "&"; + if (StringUtils.isNotEmpty(redirectUrl)) { + String queryString = request.getQueryString(); + if (StringUtils.isNotEmpty(queryString)) { + if (redirectUrl.indexOf("?") == -1) { + redirectUrl += "?"; + } else { + redirectUrl += "&"; + } + redirectUrl += queryString; } - redirectUrl += queryString; + } else { + redirectUrl = url404; } response.sendRedirect(redirectUrl); } diff --git a/backend/manager/modules/welcome/src/main/resources/messages.properties b/backend/manager/modules/welcome/src/main/resources/messages.properties index ab2a054..35d4da1 100644 --- a/backend/manager/modules/welcome/src/main/resources/messages.properties +++ b/backend/manager/modules/welcome/src/main/resources/messages.properties @@ -4,3 +4,6 @@ #405 error page methodnotallowed.method_not_allowed=405 - Method not allowed methodnotallowed.link=Click here to continue. +#reports not installed error page +reportsnotinstalled.reports_not_installed=Reports not installed +reportsnotinstalled.link=Click here to continue. diff --git a/backend/manager/modules/welcome/src/main/webapp/WEB-INF/ReportsNotInstalled.jsp b/backend/manager/modules/welcome/src/main/webapp/WEB-INF/ReportsNotInstalled.jsp new file mode 100644 index 0000000..d2f48d7 --- /dev/null +++ b/backend/manager/modules/welcome/src/main/webapp/WEB-INF/ReportsNotInstalled.jsp @@ -0,0 +1,43 @@ +<%@ page pageEncoding="UTF-8" session="false" %> +<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %> +<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt" %> +<%@ taglib prefix="obrand" uri="obrand" %> +<fmt:setLocale value="${locale}" /> +<fmt:setBundle basename="messages" var="reportsnotinstalled" /> +<!DOCTYPE html> +<html> +<head> + <meta http-equiv="Content-type" content="text/html; charset=utf-8" /> + <obrand:favicon /> + <title><fmt:message key="reportsnotinstalled.reports_not_installed" bundle="${reportsnotinstalled}" /></title> + <obrand:stylesheets /> +</head> +<body> +<div class="obrand_loginPageBackground"> + <a href="<obrand:messages key="obrand.common.vendor_url"/>" class="obrand_loginPageLogoImageLink"> + <span class="obrand_loginPageLogoImage"></span> + </a> + <div class="login-pf"> + <div class="container"> + <div class="row"> + + <div class="col-sm-12"> + <div id="brand"> + <div class="obrand_loginFormLogoImage"></div> + </div> + </div> + + <div class="col-sm-12 welcome-title-wrapper"> + <span class="welcome-title"><fmt:message key="reportsnotinstalled.reports_not_installed" bundle="${reportsnotinstalled}" /></span> + </div> + + <div class="col-sm-12"> + <a id="link-not-installed" href="${pageContext.request.contextPath}/"><fmt:message key="reportsnotinstalled.link" bundle="${reportsnotinstalled}" /></a> + </div> + + </div> + </div> + </div> + </div> +</body> +</html> diff --git a/backend/manager/modules/welcome/src/main/webapp/WEB-INF/web.xml b/backend/manager/modules/welcome/src/main/webapp/WEB-INF/web.xml index ea806a8..13e4d3f 100644 --- a/backend/manager/modules/welcome/src/main/webapp/WEB-INF/web.xml +++ b/backend/manager/modules/welcome/src/main/webapp/WEB-INF/web.xml @@ -61,7 +61,18 @@ <url-pattern>/405.html</url-pattern> </servlet-mapping> - <!-- Welcome page --> + <!-- PageNotFound Servlet --> + <servlet> + <servlet-name>ReportsNotInstalledServlet</servlet-name> + <jsp-file>/WEB-INF/ReportsNotInstalled.jsp</jsp-file> + </servlet> + + <servlet-mapping> + <servlet-name>ReportsNotInstalledServlet</servlet-name> + <url-pattern>/ReportsNotInstalled.html</url-pattern> + </servlet-mapping> + + <!-- Welcome page --> <servlet> <servlet-name>WelcomeServlet</servlet-name> <servlet-class>org.ovirt.engine.core.WelcomeServlet</servlet-class> diff --git a/packaging/services/ovirt-engine/ovirt-engine.conf.in b/packaging/services/ovirt-engine/ovirt-engine.conf.in index b8f396c..94c8517 100644 --- a/packaging/services/ovirt-engine/ovirt-engine.conf.in +++ b/packaging/services/ovirt-engine/ovirt-engine.conf.in @@ -220,6 +220,6 @@ ENGINE_REPORTS_VERIFY_HOST=true ENGINE_REPORTS_VERIFY_CHAIN=true ENGINE_REPORTS_READ_TIMEOUT= - +ENGINE_REPORTS_NOT_INSTALLED_URL=/ovirt-engine/ReportsNotInstalled.html ENGINE_EXTENSION_PATH="${ENGINE_USR}/extensions.d:${ENGINE_ETC}/extensions.d" -- To view, visit http://gerrit.ovirt.org/33218 To unsubscribe, visit http://gerrit.ovirt.org/settings Gerrit-MessageType: newchange Gerrit-Change-Id: Idaed902328695e2d448ac49c414ddfbde8d3fd25 Gerrit-PatchSet: 1 Gerrit-Project: ovirt-engine Gerrit-Branch: master Gerrit-Owner: Ravi Nori <rn...@redhat.com> _______________________________________________ Engine-patches mailing list Engine-patches@ovirt.org http://lists.ovirt.org/mailman/listinfo/engine-patches