felix-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From cziege...@apache.org
Subject svn commit: r1440027 - in /felix/trunk/status-printer/src/main/java/org/apache/felix/status: ./ impl/ impl/webconsole/
Date Tue, 29 Jan 2013 17:42:46 GMT
Author: cziegeler
Date: Tue Jan 29 17:42:46 2013
New Revision: 1440027

URL: http://svn.apache.org/viewvc?rev=1440027&view=rev
Log:
FELIX-3874 :  Create new status printer module

Modified:
    felix/trunk/status-printer/src/main/java/org/apache/felix/status/PrinterMode.java
    felix/trunk/status-printer/src/main/java/org/apache/felix/status/ZipAttachmentProvider.java
    felix/trunk/status-printer/src/main/java/org/apache/felix/status/impl/AbstractWebConsolePlugin.java
    felix/trunk/status-printer/src/main/java/org/apache/felix/status/impl/Activator.java
    felix/trunk/status-printer/src/main/java/org/apache/felix/status/impl/webconsole/ConfigurationPrinterAdapter.java
    felix/trunk/status-printer/src/main/java/org/apache/felix/status/impl/webconsole/WebConsoleAdapter.java

Modified: felix/trunk/status-printer/src/main/java/org/apache/felix/status/PrinterMode.java
URL: http://svn.apache.org/viewvc/felix/trunk/status-printer/src/main/java/org/apache/felix/status/PrinterMode.java?rev=1440027&r1=1440026&r2=1440027&view=diff
==============================================================================
--- felix/trunk/status-printer/src/main/java/org/apache/felix/status/PrinterMode.java (original)
+++ felix/trunk/status-printer/src/main/java/org/apache/felix/status/PrinterMode.java Tue
Jan 29 17:42:46 2013
@@ -23,8 +23,9 @@ package org.apache.felix.status;
  */
 public enum PrinterMode {
 
-    TEXT,       // plain text
-    HTML_BODY,  // HTML which can be placed inside a HTML body element (no external references)
-    JSON,       // JSON output
-    ZIP_FILE    // file content for a zip
+    TEXT,          // plain text
+    HTML_BODY,     // HTML which can be placed inside a HTML body element (no external references)
+    JSON,          // JSON output
+    ZIP_FILE_BIN,  // file content for a zip
+    ZIP_FILE_JSON  // json file content for a zip
 }

Modified: felix/trunk/status-printer/src/main/java/org/apache/felix/status/ZipAttachmentProvider.java
URL: http://svn.apache.org/viewvc/felix/trunk/status-printer/src/main/java/org/apache/felix/status/ZipAttachmentProvider.java?rev=1440027&r1=1440026&r2=1440027&view=diff
==============================================================================
--- felix/trunk/status-printer/src/main/java/org/apache/felix/status/ZipAttachmentProvider.java
(original)
+++ felix/trunk/status-printer/src/main/java/org/apache/felix/status/ZipAttachmentProvider.java
Tue Jan 29 17:42:46 2013
@@ -29,7 +29,9 @@ import java.util.zip.ZipOutputStream;
  *
  * A service implementing this method must still register itself
  * as a {@link StatusPrinter} but not as a
- * {@link ZipAttachmentProvider} service.
+ * {@link ZipAttachmentProvider} service and the provider
+ * should either support {@link PrinterMode.ZIP_FILE_JSON}
+ * or {@link PrinterMode.ZIP_FILE_BIN}
  */
 public interface ZipAttachmentProvider extends StatusPrinter {
 

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=1440027&r1=1440026&r2=1440027&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 17:42:46 2013
@@ -141,7 +141,9 @@ public abstract class AbstractWebConsole
             zip.closeEntry();
 
             final ZipConfigurationWriter pw = new ZipConfigurationWriter( zip );
-            printConfigurationStatus( pw, PrinterMode.ZIP_FILE, handler );
+            printConfigurationStatus( pw, PrinterMode.ZIP_FILE_BIN, handler );
+            pw.counter = 0;
+            printConfigurationStatus( pw, PrinterMode.ZIP_FILE_JSON, handler );
 
             zip.finish();
         } else if ( request.getPathInfo().endsWith( ".nfo" ) ) {
@@ -204,7 +206,7 @@ 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.ZIP_FILE) ) {
+            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>");
             }
             if ( handler.supports(PrinterMode.TEXT ) ) {
@@ -429,18 +431,23 @@ public abstract class AbstractWebConsole
                 final PrinterMode mode,
                 final StatusPrinterHandler handler)
         throws IOException {
-            super.printStatus(mode, handler);
             final String title = getFormattedTitle(handler.getTitle());
-            handler.addAttachments(title.concat("/"), this.zip);
-            if ( handler.supports(PrinterMode.JSON) ) {
+            if ( mode == PrinterMode.ZIP_FILE_BIN ) {
+                super.printStatus(mode, handler);
+                handler.addAttachments(title.concat("/"), this.zip);
+            } else {
+                counter++;
                 final String name = "json/".concat(title).concat(".json");
 
                 final ZipEntry entry = new ZipEntry( name );
                 zip.putNextEntry( entry );
-                handler.print(PrinterMode.JSON, this);
+                handler.print(PrinterMode.ZIP_FILE_JSON, this);
                 flush();
 
                 zip.closeEntry();
+                if ( !handler.supports(PrinterMode.ZIP_FILE_BIN) ) {
+                    handler.addAttachments(title.concat("/"), this.zip);
+                }
             }
         }
     }

Modified: felix/trunk/status-printer/src/main/java/org/apache/felix/status/impl/Activator.java
URL: http://svn.apache.org/viewvc/felix/trunk/status-printer/src/main/java/org/apache/felix/status/impl/Activator.java?rev=1440027&r1=1440026&r2=1440027&view=diff
==============================================================================
--- felix/trunk/status-printer/src/main/java/org/apache/felix/status/impl/Activator.java (original)
+++ felix/trunk/status-printer/src/main/java/org/apache/felix/status/impl/Activator.java Tue
Jan 29 17:42:46 2013
@@ -49,8 +49,7 @@ public class Activator implements Bundle
         this.managerRegistration = context.registerService(
                 StatusPrinterManager.class.getName(),
                 this.printerManager, props);
-
-    }
+}
 
     /**
      * @see org.osgi.framework.BundleActivator#stop(org.osgi.framework.BundleContext)

Modified: felix/trunk/status-printer/src/main/java/org/apache/felix/status/impl/webconsole/ConfigurationPrinterAdapter.java
URL: http://svn.apache.org/viewvc/felix/trunk/status-printer/src/main/java/org/apache/felix/status/impl/webconsole/ConfigurationPrinterAdapter.java?rev=1440027&r1=1440026&r2=1440027&view=diff
==============================================================================
--- felix/trunk/status-printer/src/main/java/org/apache/felix/status/impl/webconsole/ConfigurationPrinterAdapter.java
(original)
+++ felix/trunk/status-printer/src/main/java/org/apache/felix/status/impl/webconsole/ConfigurationPrinterAdapter.java
Tue Jan 29 17:42:46 2013
@@ -183,7 +183,7 @@ public class ConfigurationPrinterAdapter
     public String[] getPrinterModes() {
         final Set<String> list = new HashSet<String>();
         if ( this.match(ConsoleConstants.MODE_TXT) || this.match(ConsoleConstants.MODE_ZIP)
) {
-            list.add(PrinterMode.ZIP_FILE.name());
+            list.add(PrinterMode.ZIP_FILE_BIN.name());
         }
         if ( this.match(ConsoleConstants.MODE_WEB) ) {
             if ( !escapeHtml ) {

Modified: felix/trunk/status-printer/src/main/java/org/apache/felix/status/impl/webconsole/WebConsoleAdapter.java
URL: http://svn.apache.org/viewvc/felix/trunk/status-printer/src/main/java/org/apache/felix/status/impl/webconsole/WebConsoleAdapter.java?rev=1440027&r1=1440026&r2=1440027&view=diff
==============================================================================
--- felix/trunk/status-printer/src/main/java/org/apache/felix/status/impl/webconsole/WebConsoleAdapter.java
(original)
+++ felix/trunk/status-printer/src/main/java/org/apache/felix/status/impl/webconsole/WebConsoleAdapter.java
Tue Jan 29 17:42:46 2013
@@ -113,7 +113,7 @@ public class WebConsoleAdapter implement
                         m = ConsoleConstants.MODE_WEB;
                     } else if ( mode == PrinterMode.TEXT ) {
                         m = ConsoleConstants.MODE_TXT;
-                    } else if ( mode == PrinterMode.ZIP_FILE ) {
+                    } else if ( mode == PrinterMode.ZIP_FILE_BIN ) {
                         m = ConsoleConstants.MODE_ZIP;
                     } else {
                         m = null;



Mime
View raw message