You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@felix.apache.org by cz...@apache.org on 2013/01/29 20:35:19 UTC
svn commit: r1440074 -
/felix/trunk/status-printer/src/main/java/org/apache/felix/status/impl/AbstractWebConsolePlugin.java
Author: cziegeler
Date: Tue Jan 29 19:35:19 2013
New Revision: 1440074
URL: http://svn.apache.org/viewvc?rev=1440074&view=rev
Log:
FELIX-3874 : Create new status printer module
Modified:
felix/trunk/status-printer/src/main/java/org/apache/felix/status/impl/AbstractWebConsolePlugin.java
Modified: felix/trunk/status-printer/src/main/java/org/apache/felix/status/impl/AbstractWebConsolePlugin.java
URL: http://svn.apache.org/viewvc/felix/trunk/status-printer/src/main/java/org/apache/felix/status/impl/AbstractWebConsolePlugin.java?rev=1440074&r1=1440073&r2=1440074&view=diff
==============================================================================
--- felix/trunk/status-printer/src/main/java/org/apache/felix/status/impl/AbstractWebConsolePlugin.java (original)
+++ felix/trunk/status-printer/src/main/java/org/apache/felix/status/impl/AbstractWebConsolePlugin.java Tue Jan 29 19:35:19 2013
@@ -168,6 +168,16 @@ public abstract class AbstractWebConsole
}
pw.println( "</div></body></html>" );
return;
+ } else if ( request.getPathInfo().endsWith(".json") ) {
+ if ( handler == null ) {
+ response.sendError( HttpServletResponse.SC_NOT_FOUND);
+ return;
+ }
+ response.setContentType( "application/json" ); //$NON-NLS-1$
+ response.setCharacterEncoding( "UTF-8" ); //$NON-NLS-1$
+
+ final JSONConfigurationWriter jcw = new JSONConfigurationWriter(response.getWriter());
+ printConfigurationStatus( jcw, PrinterMode.JSON, handler );
} else {
if ( handler == null ) {
response.sendError( HttpServletResponse.SC_NOT_FOUND);
@@ -189,6 +199,7 @@ public abstract class AbstractWebConsole
pw.println("$(document).ready(function() {");
pw.println(" $('.downloadTxt').click(function() { downloadDump('txt', false)});");
+ pw.println(" $('.downloadJson').click(function() { downloadDump('json', false)});");
pw.println(" $('.downloadZip').click(function() { downloadDump('zip', false)});");
pw.println(" $('.downloadFullZip').click(function() { downloadDump('zip', true)});");
pw.println(" $('.downloadFullTxt').click(function() { downloadDump('txt', true)});");
@@ -206,6 +217,9 @@ public abstract class AbstractWebConsole
pw.print("<button type=\"button\" class=\"downloadFullZip\" style=\"float: right; margin-right: 30px; margin-top: 5px;\">Download Full Zip</button>");
pw.print("<button type=\"button\" class=\"downloadFullTxt\" style=\"float: right; margin-right: 30px; margin-top: 5px;\">Download Full Text</button>");
+ if ( handler.supports(PrinterMode.JSON) ) {
+ pw.print("<button type=\"button\" class=\"downloadJson\" style=\"float: right; margin-right: 30px; margin-top: 5px;\">Download As JSON</button>");
+ }
if ( handler.supports(PrinterMode.ZIP_FILE_BIN) || handler.supports(PrinterMode.ZIP_FILE_JSON) ) {
pw.print("<button type=\"button\" class=\"downloadZip\" style=\"float: right; margin-right: 30px; margin-top: 5px;\">Download As Zip</button>");
}
@@ -255,6 +269,16 @@ public abstract class AbstractWebConsole
}
/**
+ * The JSON configuration writer
+ */
+ private static class JSONConfigurationWriter extends ConfigurationWriter {
+
+ JSONConfigurationWriter( final Writer delegatee ) {
+ super( delegatee );
+ }
+ }
+
+ /**
* The HTML configuration writer outputs the status as an HTML snippet.
*/
private static class HtmlConfigurationWriter extends ConfigurationWriter {