}
response.setContentType("application/json"); //$NON-NLS-1$
response.setCharacterEncoding("UTF-8"); //$NON-NLS-1$
final JSONConfigurationWriter jcw = new JSONConfigurationWriter(response.getWriter());
final Format format;
if (handler.supports(Format.JSON))
{
format = Format.JSON;
}
else
{
format = Format.TEXT;
jcw.startJSONWrapper();
}
printConfigurationInventory(jcw, format, handler);
jcw.endJSONWrapper();
jcw.flush();
}
else
{
if (handler == null)
{
response.sendError(HttpServletResponse.SC_NOT_FOUND);
return;
}
final HtmlConfigurationWriter pw = new HtmlConfigurationWriter(response.getWriter());
pw.println("<script type=\"text/javascript\">");
pw.println("// <![CDATA[");
pw.println("function pad(value) { if ( value < 10 ) { return '0' + value;} return '' + value;}");
pw.println("function downloadDump(ext, full) {");
pw.println(" if (full) {");
pw.println(" var now = new Date();");
pw.println(" var name = \"configuration-status-\" + now.getUTCFullYear() + pad(now.getUTCMonth() + 1) + pad(now.getUTCDate()) + \"-\" + pad(now.getUTCHours()) + pad(now.getUTCMinutes()) + pad(now.getUTCSeconds()) + \".\";");
pw.println(" location.href = location.href + \"/\" + name + ext;");
pw.println(" } else {");
pw.println(" location.href = location.href + '.' + ext;");
pw.println(" }");
pw.println("}");
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)});");
pw.println("});");
pw.println("// ]]>");
pw.println("</script>");
pw.println("<br/><p class=\"statline\">");
pw.print("Date: ");
pw.println(DateFormat.getDateTimeInstance(DateFormat.LONG, DateFormat.LONG, Locale.US).format(new Date()));
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(Format.JSON))
{
pw.print("<button type=\"button\" class=\"downloadJson\" style=\"float: right; margin-right: 30px; margin-top: 5px;\">Download As JSON</button>");
}
pw.print("<button type=\"button\" class=\"downloadZip\" style=\"float: right; margin-right: 30px; margin-top: 5px;\">Download As Zip</button>");
if (handler.supports(Format.TEXT))
{
pw.print("<button type=\"button\" class=\"downloadTxt\" style=\"float: right; margin-right: 30px; margin-top: 5px;\">Download As Text</button>");
}
pw.println("<br/> </p>"); // status line
pw.print("<div>");
final boolean filter;
final Format format;
if (handler.supports(Format.HTML))
{
filter = false;
format = Format.HTML;
}