From 03750cd669feae8bd37a31b91abcef98faa667bb Mon Sep 17 00:00:00 2001 From: j2blake Date: Tue, 10 Dec 2013 11:37:47 -0500 Subject: [PATCH] VIVO-581 Add a diagnostic page --- .../controller/admin/ShowConfiguration.java | 50 +++++++++++++++++++ webapp/web/WEB-INF/web.xml | 9 ++++ .../body/admin/admin-showConfiguration.ftl | 28 +++++++++++ .../page/partials/developerPanel.ftl | 2 + 4 files changed, 89 insertions(+) create mode 100644 webapp/src/edu/cornell/mannlib/vitro/webapp/controller/admin/ShowConfiguration.java create mode 100644 webapp/web/templates/freemarker/body/admin/admin-showConfiguration.ftl diff --git a/webapp/src/edu/cornell/mannlib/vitro/webapp/controller/admin/ShowConfiguration.java b/webapp/src/edu/cornell/mannlib/vitro/webapp/controller/admin/ShowConfiguration.java new file mode 100644 index 000000000..7a8a2322c --- /dev/null +++ b/webapp/src/edu/cornell/mannlib/vitro/webapp/controller/admin/ShowConfiguration.java @@ -0,0 +1,50 @@ +/* $This file is distributed under the terms of the license in /doc/license.txt$ */ + +package edu.cornell.mannlib.vitro.webapp.controller.admin; + +import java.util.HashMap; +import java.util.Map; +import java.util.Properties; +import java.util.SortedMap; +import java.util.TreeMap; + +import edu.cornell.mannlib.vitro.webapp.auth.requestedAction.Actions; +import edu.cornell.mannlib.vitro.webapp.config.ConfigurationProperties; +import edu.cornell.mannlib.vitro.webapp.controller.VitroRequest; +import edu.cornell.mannlib.vitro.webapp.controller.freemarker.FreemarkerHttpServlet; +import edu.cornell.mannlib.vitro.webapp.controller.freemarker.responsevalues.ResponseValues; +import edu.cornell.mannlib.vitro.webapp.controller.freemarker.responsevalues.TemplateResponseValues; + +/** + * Show the current ConfigurationProperties and the Java system properties. + */ +public class ShowConfiguration extends FreemarkerHttpServlet { + @Override + protected Actions requiredActions(VitroRequest vreq) { + return Actions.AUTHORIZED; + } + + @Override + protected ResponseValues processRequest(VitroRequest vreq) { + Map body = new HashMap(); + body.put("configurationProperties", getConfigurationProperties(vreq)); + body.put("javaSystemProperties", getSystemProperties()); + return new TemplateResponseValues("admin-showConfiguration.ftl", body); + } + + private SortedMap getConfigurationProperties( + VitroRequest vreq) { + return new TreeMap<>(ConfigurationProperties.getBean(vreq) + .getPropertyMap()); + } + + private SortedMap getSystemProperties() { + Properties props = System.getProperties(); + SortedMap map = new TreeMap<>(); + for (String key : props.stringPropertyNames()) { + map.put(key, props.getProperty(key)); + } + return map; + } + +} diff --git a/webapp/web/WEB-INF/web.xml b/webapp/web/WEB-INF/web.xml index 1d393a7b9..08612be19 100644 --- a/webapp/web/WEB-INF/web.xml +++ b/webapp/web/WEB-INF/web.xml @@ -660,6 +660,15 @@ /admin/showAuth + + ShowConfiguration + edu.cornell.mannlib.vitro.webapp.controller.admin.ShowConfiguration + + + ShowConfiguration + /admin/showConfiguration + + StartupStatus edu.cornell.mannlib.vitro.webapp.controller.admin.StartupStatusController diff --git a/webapp/web/templates/freemarker/body/admin/admin-showConfiguration.ftl b/webapp/web/templates/freemarker/body/admin/admin-showConfiguration.ftl new file mode 100644 index 000000000..f77e0d518 --- /dev/null +++ b/webapp/web/templates/freemarker/body/admin/admin-showConfiguration.ftl @@ -0,0 +1,28 @@ +<#-- $This file is distributed under the terms of the license in /doc/license.txt$ --> + +<#-- Template viewing the authorization mechanisms: current identifiers, factories, policies, etc. --> + +${stylesheets.add('')} + +

Configuration settings

+ +
+

Build and runtime properties:

+ + <#list configurationProperties?keys as key> + + + + + +
${key}${configurationProperties[key]}
+

Java system properties:

+ + <#list javaSystemProperties?keys as key> + + + + + +
${key}${javaSystemProperties[key]}
+
diff --git a/webapp/web/templates/freemarker/page/partials/developerPanel.ftl b/webapp/web/templates/freemarker/page/partials/developerPanel.ftl index 82b2a0c80..a9437a3d8 100644 --- a/webapp/web/templates/freemarker/page/partials/developerPanel.ftl +++ b/webapp/web/templates/freemarker/page/partials/developerPanel.ftl @@ -56,6 +56,8 @@ Links
Set log levels + Show Configuration +
Show authorization info Show background threads