W3C home > Mailing lists > Public > www-validator-cvs@w3.org > July 2009

2006/unicorn/org/w3c/unicorn/util TemplateHelper.java,1.4,1.5 Property.java,1.5,1.6

From: Thomas Gambet via cvs-syncmail <cvsmail@w3.org>
Date: Wed, 29 Jul 2009 13:23:36 +0000
To: www-validator-cvs@w3.org
Message-Id: <E1MW984-0001bc-Cg@lionel-hutz.w3.org>
Update of /sources/public/2006/unicorn/org/w3c/unicorn/util
In directory hutz:/tmp/cvs-serv6091/org/w3c/unicorn/util

Modified Files:
	TemplateHelper.java Property.java 
Log Message:
Compatibility with Jigsaw is back

Index: Property.java
===================================================================
RCS file: /sources/public/2006/unicorn/org/w3c/unicorn/util/Property.java,v
retrieving revision 1.5
retrieving revision 1.6
diff -u -d -r1.5 -r1.6
--- Property.java	23 Jul 2009 13:00:40 -0000	1.5
+++ Property.java	29 Jul 2009 13:23:34 -0000	1.6
@@ -4,8 +4,8 @@
 // Please first read the full copyright statement in file COPYRIGHT.html
 package org.w3c.unicorn.util;
 
-import java.io.File;
 import java.io.IOException;
+import java.net.MalformedURLException;
 import java.net.URL;
 import java.util.ArrayList;
 import java.util.Enumeration;
@@ -198,10 +198,26 @@
 
 		return aStringBuffer.toString();
 	}
+	
+	public static URL getPropertyFileURL(String file) {
+		URL aURLPropFile;
+		try {
+			if (System.getProperty("unicorn.conf") != null)
+				aURLPropFile = new URL("file://" + System.getProperty("unicorn.conf") + "/" + file);
+			else
+				aURLPropFile = new URL(Property.class.getResource("/"), "org/w3c/unicorn/conf/" + file);
+			return aURLPropFile;
+		} catch (MalformedURLException e) {
+			Property.logger.error("Could not load property file :" + file + "||" + e.getMessage(), e);
+			e.printStackTrace();
+			return null;
+		}	
+	}
+	
 
 	static {
 		try {
-			URL aURLPropFile = new URL(Property.class.getResource("/"), "org/w3c/unicorn/conf/unicorn.properties");
+			URL aURLPropFile = getPropertyFileURL("unicorn.properties");
 			
 			final Properties aProperties = new Properties();
 			aProperties.load(aURLPropFile.openStream());

Index: TemplateHelper.java
===================================================================
RCS file: /sources/public/2006/unicorn/org/w3c/unicorn/util/TemplateHelper.java,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -d -r1.4 -r1.5
--- TemplateHelper.java	29 Jul 2009 09:49:15 -0000	1.4
+++ TemplateHelper.java	29 Jul 2009 13:23:34 -0000	1.5
@@ -9,7 +9,6 @@
 import java.io.IOException; 
 import java.io.OutputStreamWriter;
 import java.net.MalformedURLException;
-import java.net.URL;
 import java.util.Iterator; 
 import java.util.Properties; 
 import java.util.Set;
@@ -39,8 +38,9 @@
 		Properties aProperties = new Properties();
 		
 		try {
-			aProperties.load(new URL(Property.class.getResource("/"),
-					"org/w3c/unicorn/conf/velocity.properties").openStream());
+			aProperties.load(
+					Property.getPropertyFileURL("velocity.properties").openStream()
+			);
 
 			aProperties.put(Velocity.FILE_RESOURCE_LOADER_PATH, Property
 					.get("PATH_TO_TEMPLATES"));
Received on Wednesday, 29 July 2009 13:23:46 GMT

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