unicorn commit: added task messages to reload default messages

changeset:   1279:9d44d4533347
tag:         tip
user:        Thomas Gambet <tgambet@w3.org>
date:        Fri Jun 18 17:39:03 2010 -0400
files:       WebContent/WEB-INF/resources/templates/init.vm src/org/w3c/unicorn/action/InitAction.java
description:
added task messages to reload default messages


diff -r 3374c09c0899 -r 9d44d4533347 WebContent/WEB-INF/resources/templates/init.vm
--- a/WebContent/WEB-INF/resources/templates/init.vm	Fri Jun 18 17:31:44 2010 -0400
+++ b/WebContent/WEB-INF/resources/templates/init.vm	Fri Jun 18 17:39:03 2010 -0400
@@ -9,7 +9,8 @@
 		<li><a href="init?task=all" class="init">Initialize all</a></li>
 		<li><a href="init?task=languages" class="init">Reload languages</a></li>
 		<li><a href="init?task=observers" class="init">Reload observers</a></li>
-		<li><a href="init?task=tasklist" class="init">Reload tasklist</a></li>
+		<li><a href="init?task=tasklist" class="init">Reload tasklist</a></li>
+		<li><a href="init?task=messages" class="init">Reload messages</a></li>
 	</ul>
 	<textarea name="result" id="result" rows="15" cols="32" disabled="disabled"></textarea>
 </div>
diff -r 3374c09c0899 -r 9d44d4533347 src/org/w3c/unicorn/action/InitAction.java
--- a/src/org/w3c/unicorn/action/InitAction.java	Fri Jun 18 17:31:44 2010 -0400
+++ b/src/org/w3c/unicorn/action/InitAction.java	Fri Jun 18 17:39:03 2010 -0400
@@ -14,6 +14,7 @@
 import org.w3c.unicorn.Framework;
 import org.w3c.unicorn.exceptions.InitializationFailedException;
 import org.w3c.unicorn.util.Language;
+import org.w3c.unicorn.util.MessageList;
 import org.w3c.unicorn.util.Templates;
 
 import com.ibm.icu.util.ULocale;
@@ -170,18 +171,26 @@
 				}
 			}
 				
-			out.write("Initializing Velocity: ");
-			response.flushBuffer();
-			try {
-				Framework.initVelocity();
+			if (task.equals("all") || task.equals("messages")) {
+				out.write("Loading default messages: ");
+				Framework.initDefaultMessages();
 				out.write("OK\n");
-			} catch (InitializationFailedException e) {
-				Framework.logger.fatal(e.getMessage(), e);
-				out.write("FAILED\n" + e);
-				Framework.isUcnInitialized = false;
-				return;
+				out.write("\t" + MessageList.getDefaultMessages().size() + " message(s) loaded.\n");
 			}
 			
+			if (!task.equals("messages")) {
+				out.write("Initializing Velocity: ");
+				response.flushBuffer();
+				try {
+					Framework.initVelocity();
+					out.write("OK\n");
+				} catch (InitializationFailedException e) {
+					Framework.logger.fatal(e.getMessage(), e);
+					out.write("FAILED\n" + e);
+					Framework.isUcnInitialized = false;
+					return;
+				}
+			}
 			out.close();
 		}
 	}

Received on Friday, 18 June 2010 21:39:31 UTC