cxf-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From tomek...@apache.org
Subject svn commit: r979671 - in /cxf/sandbox/logbrowser/distribution/src/main/release/samples/logbrowser: src/demo/logbrowser/servlet/Generate.java webapp/generate.html
Date Tue, 27 Jul 2010 12:37:37 GMT
Author: tomekopo
Date: Tue Jul 27 12:37:37 2010
New Revision: 979671

URL: http://svn.apache.org/viewvc?rev=979671&view=rev
Log:
Added additional input in generating page for define number of copies

Modified:
    cxf/sandbox/logbrowser/distribution/src/main/release/samples/logbrowser/src/demo/logbrowser/servlet/Generate.java
    cxf/sandbox/logbrowser/distribution/src/main/release/samples/logbrowser/webapp/generate.html

Modified: cxf/sandbox/logbrowser/distribution/src/main/release/samples/logbrowser/src/demo/logbrowser/servlet/Generate.java
URL: http://svn.apache.org/viewvc/cxf/sandbox/logbrowser/distribution/src/main/release/samples/logbrowser/src/demo/logbrowser/servlet/Generate.java?rev=979671&r1=979670&r2=979671&view=diff
==============================================================================
--- cxf/sandbox/logbrowser/distribution/src/main/release/samples/logbrowser/src/demo/logbrowser/servlet/Generate.java
(original)
+++ cxf/sandbox/logbrowser/distribution/src/main/release/samples/logbrowser/src/demo/logbrowser/servlet/Generate.java
Tue Jul 27 12:37:37 2010
@@ -38,6 +38,7 @@ public class Generate extends HttpServle
 
     private static final String LEVEL = "level";
     private static final String MESSAGE = "message";
+    private static final String COPIES = "copies";
     private static final String EXCEPTION_MESSAGE = "exceptionMessage";
     private static final String FORM_URL = "./generate.html";
 
@@ -56,16 +57,27 @@ public class Generate extends HttpServle
         final String message = request.getParameter(MESSAGE);
         final String exceptionMessage = request.getParameter(EXCEPTION_MESSAGE);
 
+        int copies;
+        try {
+            copies = Integer.valueOf(request.getParameter(COPIES));
+            if (copies < 0) {
+                copies = 1;
+            }
+        } catch (NumberFormatException e) {
+            copies = 1;
+        }
+
+        assert copies >= 1;
         assert level != null && !"".equals(level);
 
         if (name(Levels.DEBUG).equals(level)) {
-            log(Level.FINE, message, exceptionMessage);
+            log(Level.FINE, message, exceptionMessage, copies);
         } else if (name(Levels.INFO).equals(level)) {
-            log(Level.INFO, message, exceptionMessage);
+            log(Level.INFO, message, exceptionMessage, copies);
         } else if (name(Levels.WARNING).equals(level)) {
-            log(Level.WARNING, message, exceptionMessage);
+            log(Level.WARNING, message, exceptionMessage, copies);
         } else if (name(Levels.ERROR).equals(level)) {
-            log(Level.SEVERE, message, exceptionMessage);
+            log(Level.SEVERE, message, exceptionMessage, copies);
         }
 
         response.setStatus(HttpServletResponse.SC_MOVED_TEMPORARILY);
@@ -73,12 +85,15 @@ public class Generate extends HttpServle
         response.setContentType("text/html");
     }
 
-    private static void log(final Level level, final String message, final String exceptionMessage)
{
+    private static void log(final Level level, final String message,
+                            final String exceptionMessage, final int copies) {
         if (message != null && !"".equals(message)) {
-            if (exceptionMessage != null && !"".equals(exceptionMessage)) {
-                LOGGER.log(level, message, new Exception(exceptionMessage));
-            } else {
-                LOGGER.log(level, message);
+            for (int i = 0; i < copies; i++) {
+                if (exceptionMessage != null && !"".equals(exceptionMessage)) {
+                    LOGGER.log(level, message, new Exception(exceptionMessage));
+                } else {
+                    LOGGER.log(level, message);
+                }
             }
         }
     }

Modified: cxf/sandbox/logbrowser/distribution/src/main/release/samples/logbrowser/webapp/generate.html
URL: http://svn.apache.org/viewvc/cxf/sandbox/logbrowser/distribution/src/main/release/samples/logbrowser/webapp/generate.html?rev=979671&r1=979670&r2=979671&view=diff
==============================================================================
--- cxf/sandbox/logbrowser/distribution/src/main/release/samples/logbrowser/webapp/generate.html
(original)
+++ cxf/sandbox/logbrowser/distribution/src/main/release/samples/logbrowser/webapp/generate.html
Tue Jul 27 12:37:37 2010
@@ -45,7 +45,12 @@
             <option value="error">ERROR</option>
         </select>
     </p>
-    
+
+    <p>
+        <label for="copies">Copies:</label>
+        <input id="copies" name="copies" type="text" size="2" value="1"/>
+    </p>
+
     <p>
         <label for="message">Message:</label>
         <textarea id="message" name="message" rows="10" cols="80"></textarea>



Mime
View raw message