Package org.apache.felix.inventory

Examples of org.apache.felix.inventory.Format


            }
            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/>&nbsp;</p>"); // status line
            pw.print("<div>");

            final boolean filter;
            final Format format;
            if (handler.supports(Format.HTML))
            {
                filter = false;
                format = Format.HTML;
            }
View Full Code Here


        // check formats
        Format[] formats = null;
        final Object formatsCfg = ref.getProperty(InventoryPrinter.FORMAT);
        if (formatsCfg instanceof String)
        {
            final Format format = Format.valueOf((String) formatsCfg);
            if (format != null)
            {
                formats = new Format[]
                    { format };
            }
        }
        else if (formatsCfg instanceof String[])
        {
            final String[] formatsCfgArray = (String[]) formatsCfg;
            final ArrayList formatList = new ArrayList();
            for (int i = 0; i < formatsCfgArray.length; i++)
            {
                final Format format = Format.valueOf(formatsCfgArray[i]);
                if (format != null)
                {
                    formatList.add(format);
                }
            }
View Full Code Here

TOP

Related Classes of org.apache.felix.inventory.Format

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.