W3C home > Mailing lists > Public > www-validator-cvs@w3.org > March 2010

2006/unicorn/src/org/w3c/unicorn Framework.java,1.32,1.33

From: Thomas Gambet via cvs-syncmail <cvsmail@w3.org>
Date: Fri, 05 Mar 2010 14:28:10 +0000
To: www-validator-cvs@w3.org
Message-Id: <E1NnYVe-0006f8-CJ@lionel-hutz.w3.org>
Update of /sources/public/2006/unicorn/src/org/w3c/unicorn
In directory hutz:/tmp/cvs-serv25596/src/org/w3c/unicorn

Modified Files:
	Framework.java 
Log Message:
Removes unknown keys from tasklist properties files and logs a warning

Index: Framework.java
===================================================================
RCS file: /sources/public/2006/unicorn/src/org/w3c/unicorn/Framework.java,v
retrieving revision 1.32
retrieving revision 1.33
diff -u -d -r1.32 -r1.33
--- Framework.java	5 Mar 2010 13:48:42 -0000	1.32
+++ Framework.java	5 Mar 2010 14:28:08 -0000	1.33
@@ -14,6 +14,7 @@
 import java.net.MalformedURLException;
 import java.net.URI;
 import java.net.URL;
+import java.util.ArrayList;
 import java.util.Hashtable;
 import java.util.Iterator;
 import java.util.LinkedHashMap;
@@ -362,8 +363,9 @@
 		File defaultTaskFile = new File(Property.get("PATH_TO_TASK_LANGUAGE_FILES", "DEFAULT_LANGUAGE") + ".tasklist.properties");
 		String defaultLang = Property.get("DEFAULT_LANGUAGE");
 		
+		UCNProperties defaultProps = null;
 		try{
-			UCNProperties defaultProps = Language.load(defaultTaskFile);
+			defaultProps = Language.load(defaultTaskFile);
 			logger.debug("> Found default tasks metadata file: " + defaultTaskFile.getPath());
 			LanguageAction.setDefaultMetadatas(defaultProps);
 			for (String taskKey : mapOfTask.keySet()) {
@@ -417,6 +419,17 @@
 			try {
 				UCNProperties props = Language.load(taskFile);
 				logger.debug("> Found tasks metadata file: " + taskFile.getPath());
+				
+				ArrayList<Object> keys = new ArrayList<Object>();
+				for (Object key : props.keySet()) {
+					if (defaultProps != null && !defaultProps.containsKey(key)) {
+						keys.add(key);
+						logger.warn(">> Unknown key \"" + key + "\" found in " + taskFile.getPath() + ". Please remove this key manually from the tasklist properties file.");
+					}
+				}
+				for (Object key : keys)
+					props.remove(key);
+				
 				LanguageAction.addMetadatasProperties(lang, props);
 				
 				for (String taskKey : mapOfTask.keySet()) {
Received on Friday, 5 March 2010 14:28:12 GMT

This archive was generated by hypermail 2.2.0+W3C-0.50 : Thursday, 26 April 2012 12:55:19 GMT