Author: doogie
Date: Fri Mar 27 16:55:57 2009 New Revision: 759228 URL: http://svn.apache.org/viewvc?rev=759228&view=rev Log: Fix lines that *only* have whitespace. Modified: ofbiz/trunk/framework/base/src/org/ofbiz/base/component/ComponentConfig.java ofbiz/trunk/framework/base/src/org/ofbiz/base/component/ComponentException.java ofbiz/trunk/framework/base/src/org/ofbiz/base/component/ComponentLoaderConfig.java ofbiz/trunk/framework/base/src/org/ofbiz/base/config/ClasspathLoader.java ofbiz/trunk/framework/base/src/org/ofbiz/base/config/FileLoader.java ofbiz/trunk/framework/base/src/org/ofbiz/base/config/GenericConfigException.java ofbiz/trunk/framework/base/src/org/ofbiz/base/config/JNDIConfigUtil.java ofbiz/trunk/framework/base/src/org/ofbiz/base/config/ResourceHandler.java ofbiz/trunk/framework/base/src/org/ofbiz/base/config/ResourceLoader.java ofbiz/trunk/framework/base/src/org/ofbiz/base/config/SecurityConfigUtil.java ofbiz/trunk/framework/base/src/org/ofbiz/base/config/UrlLoader.java ofbiz/trunk/framework/base/src/org/ofbiz/base/container/BeanShellContainer.java ofbiz/trunk/framework/base/src/org/ofbiz/base/container/Container.java ofbiz/trunk/framework/base/src/org/ofbiz/base/container/ContainerConfig.java ofbiz/trunk/framework/base/src/org/ofbiz/base/container/ContainerException.java ofbiz/trunk/framework/base/src/org/ofbiz/base/container/ContainerLoader.java ofbiz/trunk/framework/base/src/org/ofbiz/base/crypto/BlowFishCrypt.java ofbiz/trunk/framework/base/src/org/ofbiz/base/crypto/HashCrypt.java ofbiz/trunk/framework/base/src/org/ofbiz/base/location/ClasspathLocationResolver.java ofbiz/trunk/framework/base/src/org/ofbiz/base/location/ComponentLocationResolver.java ofbiz/trunk/framework/base/src/org/ofbiz/base/location/FlexibleLocation.java ofbiz/trunk/framework/base/src/org/ofbiz/base/location/OFBizHomeLocationResolver.java ofbiz/trunk/framework/base/src/org/ofbiz/base/splash/SplashScreen.java ofbiz/trunk/framework/base/src/org/ofbiz/base/util/Base64.java ofbiz/trunk/framework/base/src/org/ofbiz/base/util/BshUtil.java ofbiz/trunk/framework/base/src/org/ofbiz/base/util/CachedClassLoader.java ofbiz/trunk/framework/base/src/org/ofbiz/base/util/Debug.java ofbiz/trunk/framework/base/src/org/ofbiz/base/util/FileUtil.java ofbiz/trunk/framework/base/src/org/ofbiz/base/util/GroovyUtil.java ofbiz/trunk/framework/base/src/org/ofbiz/base/util/HttpClient.java ofbiz/trunk/framework/base/src/org/ofbiz/base/util/JNDIContextFactory.java ofbiz/trunk/framework/base/src/org/ofbiz/base/util/KeyStoreUtil.java ofbiz/trunk/framework/base/src/org/ofbiz/base/util/MessageString.java ofbiz/trunk/framework/base/src/org/ofbiz/base/util/NotifyLevel.java ofbiz/trunk/framework/base/src/org/ofbiz/base/util/ObjectType.java ofbiz/trunk/framework/base/src/org/ofbiz/base/util/OfbizBshBsfEngine.java ofbiz/trunk/framework/base/src/org/ofbiz/base/util/OutputStreamByteCount.java ofbiz/trunk/framework/base/src/org/ofbiz/base/util/SSLUtil.java ofbiz/trunk/framework/base/src/org/ofbiz/base/util/StringUtil.java ofbiz/trunk/framework/base/src/org/ofbiz/base/util/TimeDuration.java ofbiz/trunk/framework/base/src/org/ofbiz/base/util/URLConnector.java ofbiz/trunk/framework/base/src/org/ofbiz/base/util/UtilDateTime.java ofbiz/trunk/framework/base/src/org/ofbiz/base/util/UtilFormatOut.java ofbiz/trunk/framework/base/src/org/ofbiz/base/util/UtilHttp.java ofbiz/trunk/framework/base/src/org/ofbiz/base/util/UtilJ2eeCompat.java ofbiz/trunk/framework/base/src/org/ofbiz/base/util/UtilJavaParse.java ofbiz/trunk/framework/base/src/org/ofbiz/base/util/UtilMisc.java ofbiz/trunk/framework/base/src/org/ofbiz/base/util/UtilName.java ofbiz/trunk/framework/base/src/org/ofbiz/base/util/UtilNumber.java ofbiz/trunk/framework/base/src/org/ofbiz/base/util/UtilObject.java ofbiz/trunk/framework/base/src/org/ofbiz/base/util/UtilPlist.java ofbiz/trunk/framework/base/src/org/ofbiz/base/util/UtilProperties.java ofbiz/trunk/framework/base/src/org/ofbiz/base/util/UtilTimer.java ofbiz/trunk/framework/base/src/org/ofbiz/base/util/UtilURL.java ofbiz/trunk/framework/base/src/org/ofbiz/base/util/UtilValidate.java ofbiz/trunk/framework/base/src/org/ofbiz/base/util/UtilXml.java ofbiz/trunk/framework/base/src/org/ofbiz/base/util/cache/UtilCache.java ofbiz/trunk/framework/base/src/org/ofbiz/base/util/collections/FlexibleMapAccessor.java ofbiz/trunk/framework/base/src/org/ofbiz/base/util/collections/FlexibleProperties.java ofbiz/trunk/framework/base/src/org/ofbiz/base/util/collections/FlexibleServletAccessor.java ofbiz/trunk/framework/base/src/org/ofbiz/base/util/collections/MapComparator.java ofbiz/trunk/framework/base/src/org/ofbiz/base/util/collections/MapStack.java ofbiz/trunk/framework/base/src/org/ofbiz/base/util/collections/OrderedMap.java ofbiz/trunk/framework/base/src/org/ofbiz/base/util/collections/ResourceBundleMapWrapper.java ofbiz/trunk/framework/base/src/org/ofbiz/base/util/string/FlexibleStringExpander.java ofbiz/trunk/framework/base/src/org/ofbiz/base/util/string/JuelConnector.java ofbiz/trunk/framework/base/src/org/ofbiz/base/util/string/UelUtil.java ofbiz/trunk/framework/base/src/org/ofbiz/base/util/template/FreeMarkerWorker.java ofbiz/trunk/framework/base/src/org/ofbiz/base/util/template/XslTransform.java Modified: ofbiz/trunk/framework/base/src/org/ofbiz/base/component/ComponentConfig.java URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/base/src/org/ofbiz/base/component/ComponentConfig.java?rev=759228&r1=759227&r2=759228&view=diff ============================================================================== --- ofbiz/trunk/framework/base/src/org/ofbiz/base/component/ComponentConfig.java (original) +++ ofbiz/trunk/framework/base/src/org/ofbiz/base/component/ComponentConfig.java Fri Mar 27 16:55:57 2009 @@ -255,11 +255,11 @@ public static List getAppBarWebInfos(String serverName) { return ComponentConfig.getAppBarWebInfos(serverName, null, null); } - + public static List getAppBarWebInfos(String serverName, String menuName) { return ComponentConfig.getAppBarWebInfos(serverName, null, menuName); } - + public static List<WebappInfo> getAppBarWebInfos(String serverName, Comparator<? super String> comp, String menuName) { List<WebappInfo> webInfos = serverWebApps.get(serverName + menuName); if (webInfos == null) { @@ -535,7 +535,7 @@ public List<KeystoreInfo> getKeystoreInfos() { return this.keystoreInfos; } - + public List<WebappInfo> getWebappInfos() { return this.webappInfos; } @@ -647,7 +647,7 @@ public String getName() { return name; } - + public String getType() { return type; } @@ -713,20 +713,20 @@ if (UtilValidate.isEmpty(this.title)) { this.title = Character.toUpperCase(name.charAt(0)) + name.substring(1).toLowerCase(); } - + if (UtilValidate.isEmpty(this.description)) { this.description = this.title; } - + String menuNameStr = element.getAttribute("menu-name"); if (UtilValidate.isNotEmpty(menuNameStr)) { this.menuName = menuNameStr; } else { this.menuName = "main"; } - + this.position = element.getAttribute("position"); - + // default mount point is name if none specified if (UtilValidate.isEmpty(this.mountPoint)) { this.mountPoint = this.name; @@ -784,7 +784,7 @@ public String getTitle() { return title; } - + public String getDescription() { return description; } @@ -796,7 +796,7 @@ public Map<String, String> getInitParameters() { return initParameters; } - + public boolean isSessionCookieAccepted() { return sessionCookieAccepted; } Modified: ofbiz/trunk/framework/base/src/org/ofbiz/base/component/ComponentException.java URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/base/src/org/ofbiz/base/component/ComponentException.java?rev=759228&r1=759227&r2=759228&view=diff ============================================================================== --- ofbiz/trunk/framework/base/src/org/ofbiz/base/component/ComponentException.java (original) +++ ofbiz/trunk/framework/base/src/org/ofbiz/base/component/ComponentException.java Fri Mar 27 16:55:57 2009 @@ -33,7 +33,7 @@ public ComponentException(String str) { super(str); } - + public ComponentException(Throwable nested) { super(nested); } Modified: ofbiz/trunk/framework/base/src/org/ofbiz/base/component/ComponentLoaderConfig.java URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/base/src/org/ofbiz/base/component/ComponentLoaderConfig.java?rev=759228&r1=759227&r2=759228&view=diff ============================================================================== --- ofbiz/trunk/framework/base/src/org/ofbiz/base/component/ComponentLoaderConfig.java (original) +++ ofbiz/trunk/framework/base/src/org/ofbiz/base/component/ComponentLoaderConfig.java Fri Mar 27 16:55:57 2009 @@ -40,15 +40,15 @@ * */ public class ComponentLoaderConfig { - + public static final String module = ComponentLoaderConfig.class.getName(); public static final String COMPONENT_LOAD_XML_FILENAME = "component-load.xml"; - + public static final int SINGLE_COMPONENT = 0; public static final int COMPONENT_DIRECTORY = 1; - + protected static List<ComponentDef> componentsToLoad = null; - + public static List<ComponentDef> getRootComponents(String configFile) throws ComponentException { if (componentsToLoad == null) { synchronized (ComponentLoaderConfig.class) { @@ -96,7 +96,7 @@ public String name; public String location; public int type = -1; - + public ComponentDef(Element element) { Properties systemProps = System.getProperties(); if ("load-component".equals(element.getNodeName())) { Modified: ofbiz/trunk/framework/base/src/org/ofbiz/base/config/ClasspathLoader.java URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/base/src/org/ofbiz/base/config/ClasspathLoader.java?rev=759228&r1=759227&r2=759228&view=diff ============================================================================== --- ofbiz/trunk/framework/base/src/org/ofbiz/base/config/ClasspathLoader.java (original) +++ ofbiz/trunk/framework/base/src/org/ofbiz/base/config/ClasspathLoader.java Fri Mar 27 16:55:57 2009 @@ -36,7 +36,7 @@ } return url; } - + public InputStream loadResource(String location) throws GenericConfigException { URL url = getURL(location); try { Modified: ofbiz/trunk/framework/base/src/org/ofbiz/base/config/FileLoader.java URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/base/src/org/ofbiz/base/config/FileLoader.java?rev=759228&r1=759227&r2=759228&view=diff ============================================================================== --- ofbiz/trunk/framework/base/src/org/ofbiz/base/config/FileLoader.java (original) +++ ofbiz/trunk/framework/base/src/org/ofbiz/base/config/FileLoader.java Fri Mar 27 16:55:57 2009 @@ -38,7 +38,7 @@ } return fileUrl; } - + public InputStream loadResource(String location) throws GenericConfigException { URL fileUrl = getURL(location); try { Modified: ofbiz/trunk/framework/base/src/org/ofbiz/base/config/GenericConfigException.java URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/base/src/org/ofbiz/base/config/GenericConfigException.java?rev=759228&r1=759227&r2=759228&view=diff ============================================================================== --- ofbiz/trunk/framework/base/src/org/ofbiz/base/config/GenericConfigException.java (original) +++ ofbiz/trunk/framework/base/src/org/ofbiz/base/config/GenericConfigException.java Fri Mar 27 16:55:57 2009 @@ -33,7 +33,7 @@ public GenericConfigException(String str) { super(str); } - + public GenericConfigException(Throwable nested) { super(nested); } Modified: ofbiz/trunk/framework/base/src/org/ofbiz/base/config/JNDIConfigUtil.java URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/base/src/org/ofbiz/base/config/JNDIConfigUtil.java?rev=759228&r1=759227&r2=759228&view=diff ============================================================================== --- ofbiz/trunk/framework/base/src/org/ofbiz/base/config/JNDIConfigUtil.java (original) +++ ofbiz/trunk/framework/base/src/org/ofbiz/base/config/JNDIConfigUtil.java Fri Mar 27 16:55:57 2009 @@ -30,7 +30,7 @@ * */ public class JNDIConfigUtil { - + public static final String module = JNDIConfigUtil.class.getName(); public static final String JNDI_CONFIG_XML_FILENAME = "jndiservers.xml"; protected static Map<String, JndiServerInfo> jndiServerInfos = FastMap.newInstance(); Modified: ofbiz/trunk/framework/base/src/org/ofbiz/base/config/ResourceHandler.java URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/base/src/org/ofbiz/base/config/ResourceHandler.java?rev=759228&r1=759227&r2=759228&view=diff ============================================================================== --- ofbiz/trunk/framework/base/src/org/ofbiz/base/config/ResourceHandler.java (original) +++ ofbiz/trunk/framework/base/src/org/ofbiz/base/config/ResourceHandler.java Fri Mar 27 16:55:57 2009 @@ -29,18 +29,18 @@ * */ public interface ResourceHandler extends Serializable { - + public String getLoaderName(); - + public String getLocation(); - + public Document getDocument() throws GenericConfigException; - + public InputStream getStream() throws GenericConfigException; - + public URL getURL() throws GenericConfigException; - + public boolean isFileResource() throws GenericConfigException; - + public String getFullLocation() throws GenericConfigException; } Modified: ofbiz/trunk/framework/base/src/org/ofbiz/base/config/ResourceLoader.java URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/base/src/org/ofbiz/base/config/ResourceLoader.java?rev=759228&r1=759227&r2=759228&view=diff ============================================================================== --- ofbiz/trunk/framework/base/src/org/ofbiz/base/config/ResourceLoader.java (original) +++ ofbiz/trunk/framework/base/src/org/ofbiz/base/config/ResourceLoader.java Fri Mar 27 16:55:57 2009 @@ -32,7 +32,7 @@ * Loads resources using dynamically specified resource loader classes. */ public abstract class ResourceLoader { - + public static final String module = ResourceLoader.class.getName(); protected static UtilCache<String, Object> loaderCache = new UtilCache<String, Object>("resource.ResourceLoaders", 0, 0); Modified: ofbiz/trunk/framework/base/src/org/ofbiz/base/config/SecurityConfigUtil.java URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/base/src/org/ofbiz/base/config/SecurityConfigUtil.java?rev=759228&r1=759227&r2=759228&view=diff ============================================================================== --- ofbiz/trunk/framework/base/src/org/ofbiz/base/config/SecurityConfigUtil.java (original) +++ ofbiz/trunk/framework/base/src/org/ofbiz/base/config/SecurityConfigUtil.java Fri Mar 27 16:55:57 2009 @@ -34,7 +34,7 @@ * */ public class SecurityConfigUtil { - + public static final String module = SecurityConfigUtil.class.getName(); /** The security config filename */ Modified: ofbiz/trunk/framework/base/src/org/ofbiz/base/config/UrlLoader.java URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/base/src/org/ofbiz/base/config/UrlLoader.java?rev=759228&r1=759227&r2=759228&view=diff ============================================================================== --- ofbiz/trunk/framework/base/src/org/ofbiz/base/config/UrlLoader.java (original) +++ ofbiz/trunk/framework/base/src/org/ofbiz/base/config/UrlLoader.java Fri Mar 27 16:55:57 2009 @@ -26,7 +26,7 @@ * */ public class UrlLoader extends ResourceLoader implements java.io.Serializable { - + public URL getURL(String location) throws GenericConfigException { String fullLocation = fullLocation(location); @@ -40,10 +40,10 @@ if (url == null) { throw new GenericConfigException("URL Resource not found: " + fullLocation); } - + return url; } - + public InputStream loadResource(String location) throws GenericConfigException { URL url = getURL(location); Modified: ofbiz/trunk/framework/base/src/org/ofbiz/base/container/BeanShellContainer.java URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/base/src/org/ofbiz/base/container/BeanShellContainer.java?rev=759228&r1=759227&r2=759228&view=diff ============================================================================== --- ofbiz/trunk/framework/base/src/org/ofbiz/base/container/BeanShellContainer.java (original) +++ ofbiz/trunk/framework/base/src/org/ofbiz/base/container/BeanShellContainer.java Fri Mar 27 16:55:57 2009 @@ -42,7 +42,7 @@ public void init(String[] args, String configFile) { this.configFileLocation = configFile; } - + /** * @see org.ofbiz.base.container.Container#init(java.lang.String[], java.lang.String) */ Modified: ofbiz/trunk/framework/base/src/org/ofbiz/base/container/Container.java URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/base/src/org/ofbiz/base/container/Container.java?rev=759228&r1=759227&r2=759228&view=diff ============================================================================== --- ofbiz/trunk/framework/base/src/org/ofbiz/base/container/Container.java (original) +++ ofbiz/trunk/framework/base/src/org/ofbiz/base/container/Container.java Fri Mar 27 16:55:57 2009 @@ -30,7 +30,7 @@ * @throws ContainerException */ public void init(String[] args, String configFile) throws ContainerException; - + /** * Start the container * Modified: ofbiz/trunk/framework/base/src/org/ofbiz/base/container/ContainerConfig.java URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/base/src/org/ofbiz/base/container/ContainerConfig.java?rev=759228&r1=759227&r2=759228&view=diff ============================================================================== --- ofbiz/trunk/framework/base/src/org/ofbiz/base/container/ContainerConfig.java (original) +++ ofbiz/trunk/framework/base/src/org/ofbiz/base/container/ContainerConfig.java Fri Mar 27 16:55:57 2009 @@ -41,11 +41,11 @@ * */ public class ContainerConfig { - + public static final String module = ContainerConfig.class.getName(); - + protected static Map<String, Container> containers = new LinkedHashMap<String, Container>(); - + public static Container getContainer(String containerName, String configFile) throws ContainerException { Container container = containers.get(containerName); if (container == null) { @@ -65,7 +65,7 @@ } return container; } - + public static Collection<Container> getContainers(String configFile) throws ContainerException { if (containers.size() == 0) { synchronized (ContainerConfig.class) { @@ -150,14 +150,14 @@ } protected ContainerConfig() {} - + protected ContainerConfig(String configFileLocation) throws ContainerException { // load the config file URL xmlUrl = UtilURL.fromResource(configFileLocation); if (xmlUrl == null) { throw new ContainerException("Could not find " + configFileLocation + " master OFBiz container configuration"); } - + // read the document Document containerDocument = null; try { @@ -169,33 +169,33 @@ } catch (IOException e) { throw new ContainerException("Error reading the container config file: " + xmlUrl, e); } - + // root element Element root = containerDocument.getDocumentElement(); - + // containers for (Element curElement: UtilXml.childElementList(root, "container")) { Container container = new Container(curElement); containers.put(container.name, container); } } - + public static class Container { public String name; public String className; public Map<String, Property> properties; - + public Container(Element element) { this.name = element.getAttribute("name"); this.className = element.getAttribute("class"); - + properties = new LinkedHashMap<String, Property>(); for (Element curElement: UtilXml.childElementList(element, "property")) { Property property = new Property(curElement); properties.put(property.name, property); } } - + public Property getProperty(String name) { return properties.get(name); } @@ -216,7 +216,7 @@ public String name; public String value; public Map<String, Property> properties; - + public Property(Element element) { this.name = element.getAttribute("name"); this.value = element.getAttribute("value"); @@ -230,7 +230,7 @@ properties.put(property.name, property); } } - + public Property getProperty(String name) { return properties.get(name); } Modified: ofbiz/trunk/framework/base/src/org/ofbiz/base/container/ContainerException.java URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/base/src/org/ofbiz/base/container/ContainerException.java?rev=759228&r1=759227&r2=759228&view=diff ============================================================================== --- ofbiz/trunk/framework/base/src/org/ofbiz/base/container/ContainerException.java (original) +++ ofbiz/trunk/framework/base/src/org/ofbiz/base/container/ContainerException.java Fri Mar 27 16:55:57 2009 @@ -24,7 +24,7 @@ * ContainerException */ public class ContainerException extends GenericConfigException { - + public ContainerException() { super(); } @@ -32,7 +32,7 @@ public ContainerException(String str) { super(str); } - + public ContainerException(Throwable t) { super(t); } Modified: ofbiz/trunk/framework/base/src/org/ofbiz/base/container/ContainerLoader.java URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/base/src/org/ofbiz/base/container/ContainerLoader.java?rev=759228&r1=759227&r2=759228&view=diff ============================================================================== --- ofbiz/trunk/framework/base/src/org/ofbiz/base/container/ContainerLoader.java (original) +++ ofbiz/trunk/framework/base/src/org/ofbiz/base/container/ContainerLoader.java Fri Mar 27 16:55:57 2009 @@ -35,7 +35,7 @@ * */ public class ContainerLoader implements StartupLoader { - + public static final String module = ContainerLoader.class.getName(); public static final String CONTAINER_CONFIG = "ofbiz-containers.xml"; private static boolean loaded = false; @@ -50,10 +50,10 @@ public void load(Start.Config config, String args[]) throws StartupException { Debug.logInfo("[Startup] Loading containers...", module); loaded = true; - + // get the master container configuration file this.configFile = config.containerConfig; - + Collection<ContainerConfig.Container> containers = null; try { containers = ContainerConfig.getContainers(configFile); @@ -114,7 +114,7 @@ Debug.logInfo("Shutting down containers", module); if (Debug.verboseOn()) printThreadDump(); - + // shutting down in reverse order for (int i = loadedContainers.size(); i > 0; i--) { Container container = loadedContainers.get(i-1); @@ -180,7 +180,7 @@ } catch (ClassCastException e) { throw new StartupException("Cannot create " + containerCfg.name, e); } - + if (containerObj == null) { throw new StartupException("Unable to create instance of component container"); } Modified: ofbiz/trunk/framework/base/src/org/ofbiz/base/crypto/BlowFishCrypt.java URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/base/src/org/ofbiz/base/crypto/BlowFishCrypt.java?rev=759228&r1=759227&r2=759228&view=diff ============================================================================== --- ofbiz/trunk/framework/base/src/org/ofbiz/base/crypto/BlowFishCrypt.java (original) +++ ofbiz/trunk/framework/base/src/org/ofbiz/base/crypto/BlowFishCrypt.java Fri Mar 27 16:55:57 2009 @@ -128,30 +128,30 @@ cipher.init(mode, secretKeySpec); return cipher.doFinal(bytes); } - + public static byte[] generateKey() throws NoSuchAlgorithmException { KeyGenerator keyGen = KeyGenerator.getInstance("Blowfish"); keyGen.init(448); - + SecretKey secretKey = keyGen.generateKey(); byte[] keyBytes = secretKey.getEncoded(); - + return keyBytes; } - + public static boolean testKey(byte[] key) { String testString = "1234567890ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstufwxyz"; BlowFishCrypt c = new BlowFishCrypt(key); byte[] encryptedBytes = c.encrypt(testString); String encryptedMessage = new String(encryptedBytes); - + byte[] decryptedBytes = c.decrypt(encryptedMessage); String decryptedMessage = new String(decryptedBytes); - + if (testString.equals(decryptedMessage)) { return true; } - + return false; } @@ -159,7 +159,7 @@ if (args[0] == null) { args[0] = "ofbkey"; } - + byte[] key = generateKey(); if (testKey(key)) { FileOutputStream fos = new FileOutputStream(args[0]); Modified: ofbiz/trunk/framework/base/src/org/ofbiz/base/crypto/HashCrypt.java URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/base/src/org/ofbiz/base/crypto/HashCrypt.java?rev=759228&r1=759227&r2=759228&view=diff ============================================================================== --- ofbiz/trunk/framework/base/src/org/ofbiz/base/crypto/HashCrypt.java (original) +++ ofbiz/trunk/framework/base/src/org/ofbiz/base/crypto/HashCrypt.java Fri Mar 27 16:55:57 2009 @@ -47,7 +47,7 @@ messagedigest.update(strBytes); byte[] digestBytes = messagedigest.digest(); char[] digestChars = Hex.encodeHex(digestBytes); - + return "{" + hashType + "}" + new String(digestChars, 0, digestChars.length); } catch (Exception e) { throw new GeneralRuntimeException("Error while computing hash of type " + hashType, e); @@ -71,23 +71,23 @@ throw new GeneralRuntimeException("Error while computing hash of type " + hashType, e); } } - + public static String getHashTypeFromPrefix(String hashString) { if (UtilValidate.isEmpty(hashString) || hashString.charAt(0) != '{') { return null; } - + return hashString.substring(1, hashString.indexOf('}')); } - + public static String removeHashTypePrefix(String hashString) { if (UtilValidate.isEmpty(hashString) || hashString.charAt(0) != '{') { return hashString; } - + return hashString.substring(hashString.indexOf('}') + 1); } - + public static String getDigestHashOldFunnyHexEncode(String str, String hashType) { if (UtilValidate.isEmpty(hashType)) hashType = "SHA"; if (str == null) return null; Modified: ofbiz/trunk/framework/base/src/org/ofbiz/base/location/ClasspathLocationResolver.java URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/base/src/org/ofbiz/base/location/ClasspathLocationResolver.java?rev=759228&r1=759227&r2=759228&view=diff ============================================================================== --- ofbiz/trunk/framework/base/src/org/ofbiz/base/location/ClasspathLocationResolver.java (original) +++ ofbiz/trunk/framework/base/src/org/ofbiz/base/location/ClasspathLocationResolver.java Fri Mar 27 16:55:57 2009 @@ -32,7 +32,7 @@ public URL resolveLocation(String location) throws MalformedURLException { return resolveLocation(location, null); } - + public URL resolveLocation(String location, ClassLoader loader) throws MalformedURLException { String baseLocation = FlexibleLocation.stripLocationType(location); // if there is a leading forward slash, remove it Modified: ofbiz/trunk/framework/base/src/org/ofbiz/base/location/ComponentLocationResolver.java URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/base/src/org/ofbiz/base/location/ComponentLocationResolver.java?rev=759228&r1=759227&r2=759228&view=diff ============================================================================== --- ofbiz/trunk/framework/base/src/org/ofbiz/base/location/ComponentLocationResolver.java (original) +++ ofbiz/trunk/framework/base/src/org/ofbiz/base/location/ComponentLocationResolver.java Fri Mar 27 16:55:57 2009 @@ -38,11 +38,11 @@ public URL resolveLocation(String location) throws MalformedURLException { StringBuffer baseLocation = ComponentLocationResolver.getBaseLocation(location); URL fileUrl = UtilURL.fromFilename(baseLocation.toString()); - + if (fileUrl == null) { Debug.logWarning("Unable to get file URL for component location; expanded location was [" + baseLocation + "], original location was [" + location + "]", module); } - + return fileUrl; } Modified: ofbiz/trunk/framework/base/src/org/ofbiz/base/location/FlexibleLocation.java URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/base/src/org/ofbiz/base/location/FlexibleLocation.java?rev=759228&r1=759227&r2=759228&view=diff ============================================================================== --- ofbiz/trunk/framework/base/src/org/ofbiz/base/location/FlexibleLocation.java (original) +++ ofbiz/trunk/framework/base/src/org/ofbiz/base/location/FlexibleLocation.java Fri Mar 27 16:55:57 2009 @@ -32,16 +32,16 @@ */ public class FlexibleLocation { - + protected static Map<String, LocationResolver> locationResolvers = FastMap.newInstance(); - + protected static Map<String, String> defaultResolvers = FastMap.newInstance(); - + protected static String standardUrlResolverName = StandardUrlLocationResolver.class.getName(); protected static String classpathResolverName = ClasspathLocationResolver.class.getName(); protected static String ofbizHomeResolverName = OFBizHomeLocationResolver.class.getName(); protected static String componentResolverName = ComponentLocationResolver.class.getName(); - + static { defaultResolvers.put("http", standardUrlResolverName); defaultResolvers.put("https", standardUrlResolverName); @@ -53,7 +53,7 @@ defaultResolvers.put("ofbizhome", ofbizHomeResolverName); defaultResolvers.put("component", componentResolverName); } - + /** * Resolves the gives location into a URL object for use in various ways. * @@ -71,13 +71,13 @@ public static URL resolveLocation(String location) throws MalformedURLException { return resolveLocation(location, null); } - + public static URL resolveLocation(String location, ClassLoader loader) throws MalformedURLException { if (location == null || location.length() == 0) { return null; } String locationType = getLocationType(location); - + LocationResolver resolver = locationResolvers.get(locationType); if (resolver == null) { synchronized (FlexibleLocation.class) { @@ -115,14 +115,14 @@ } catch (SecurityException e) { throw new MalformedURLException("Error loading Location Resolver class \"" + locationResolverName + "\": " + e.toString()); } - + if (resolver != null) { locationResolvers.put(locationType, resolver); } } } } - + if (resolver != null) { if (loader != null && resolver instanceof ClasspathLocationResolver) { ClasspathLocationResolver cplResolver = (ClasspathLocationResolver) resolver; @@ -134,7 +134,7 @@ throw new MalformedURLException("Could not find a LocationResolver for the location type: " + locationType); } } - + /** * Find the location type descriptor for the passed location String; * generally is all text before the first ":" character. @@ -144,7 +144,7 @@ if (location == null || location.length() == 0) { return null; } - + int colonIndex = location.indexOf(":"); if (colonIndex > 0) { return location.substring(0, colonIndex); @@ -152,14 +152,14 @@ return "classpath"; } } - + public static String stripLocationType(String location) { if (location == null || location.length() == 0) { return ""; } - + StringBuffer strippedSoFar = new StringBuffer(location); - + // first take care of the colon and everything before it int colonIndex = strippedSoFar.indexOf(":"); if (colonIndex == 0) { @@ -167,12 +167,12 @@ } else if (colonIndex > 0) { strippedSoFar.delete(0, colonIndex + 1); } - + // now remove any extra forward slashes, ie as long as the first two are forward slashes remove the first one while (strippedSoFar.charAt(0) == '/' && strippedSoFar.charAt(1) == '/') { strippedSoFar.deleteCharAt(0); } - + return strippedSoFar.toString(); } } Modified: ofbiz/trunk/framework/base/src/org/ofbiz/base/location/OFBizHomeLocationResolver.java URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/base/src/org/ofbiz/base/location/OFBizHomeLocationResolver.java?rev=759228&r1=759227&r2=759228&view=diff ============================================================================== --- ofbiz/trunk/framework/base/src/org/ofbiz/base/location/OFBizHomeLocationResolver.java (original) +++ ofbiz/trunk/framework/base/src/org/ofbiz/base/location/OFBizHomeLocationResolver.java Fri Mar 27 16:55:57 2009 @@ -29,9 +29,9 @@ */ public class OFBizHomeLocationResolver implements LocationResolver { - + public static final String envName = "ofbiz.home"; - + public URL resolveLocation(String location) throws MalformedURLException { String propValue = System.getProperty(envName); if (propValue == null) { @@ -40,14 +40,14 @@ } StringBuilder baseLocation = new StringBuilder(FlexibleLocation.stripLocationType(location)); - + // if there is not a forward slash between the two, add it if (baseLocation.charAt(0) != '/' && propValue.charAt(propValue.length() - 1) != '/') { baseLocation.insert(0, '/'); } - + baseLocation.insert(0, propValue); - + return UtilURL.fromFilename(baseLocation.toString()); } } Modified: ofbiz/trunk/framework/base/src/org/ofbiz/base/splash/SplashScreen.java URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/base/src/org/ofbiz/base/splash/SplashScreen.java?rev=759228&r1=759227&r2=759228&view=diff ============================================================================== --- ofbiz/trunk/framework/base/src/org/ofbiz/base/splash/SplashScreen.java (original) +++ ofbiz/trunk/framework/base/src/org/ofbiz/base/splash/SplashScreen.java Fri Mar 27 16:55:57 2009 @@ -66,7 +66,7 @@ fMediaTracker = new MediaTracker(this); fImage = Toolkit.getDefaultToolkit().getImage(fImageId); } - + private void center() { Dimension screen = Toolkit.getDefaultToolkit().getScreenSize(); Rectangle frame = getBounds(); Modified: ofbiz/trunk/framework/base/src/org/ofbiz/base/util/Base64.java URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/base/src/org/ofbiz/base/util/Base64.java?rev=759228&r1=759227&r2=759228&view=diff ============================================================================== --- ofbiz/trunk/framework/base/src/org/ofbiz/base/util/Base64.java (original) +++ ofbiz/trunk/framework/base/src/org/ofbiz/base/util/Base64.java Fri Mar 27 16:55:57 2009 @@ -100,7 +100,7 @@ Base64DecMap[Base64EncMap[idx]] = (byte) idx; } } - + /** * This method decodes the given byte[] using the base64-encoding * specified in RFC-2045 (Section 6.8). @@ -141,7 +141,7 @@ return dest; } - + /** * This method decodes the given string using the base64-encoding * specified in RFC-2045 (Section 6.8). @@ -153,12 +153,12 @@ if (str == null) { return null; } - + byte data[] = new byte[str.length()]; data = str.getBytes(); return new String(base64Decode(data)); } - + /** * This method encodes the given byte[] using the base64-encoding * specified in RFC-2045 (Section 6.8). @@ -197,7 +197,7 @@ return dest; } - + /** * This method encodes the given string using the base64-encoding * specified in RFC-2045 (Section 6.8). Modified: ofbiz/trunk/framework/base/src/org/ofbiz/base/util/BshUtil.java URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/base/src/org/ofbiz/base/util/BshUtil.java?rev=759228&r1=759227&r2=759228&view=diff ============================================================================== --- ofbiz/trunk/framework/base/src/org/ofbiz/base/util/BshUtil.java (original) +++ ofbiz/trunk/framework/base/src/org/ofbiz/base/util/BshUtil.java Fri Mar 27 16:55:57 2009 @@ -48,7 +48,7 @@ protected static Map<ClassLoader, BshClassManager> masterClassManagers = new HashMap<ClassLoader, BshClassManager>(); public static UtilCache<String, Interpreter.ParsedScript> parsedScripts = new UtilCache<String, Interpreter.ParsedScript>("script.BshLocationParsedCache", 0, 0, false); - + /** * Evaluate a BSH condition or expression * @param expression The expression to evaluate @@ -87,7 +87,7 @@ } return o; } - + public static Interpreter makeInterpreter(Map<String, ? extends Object> context) throws EvalError { Interpreter bsh = getMasterInterpreter(null); // Set the context for the condition @@ -95,11 +95,11 @@ for (Map.Entry<String, ? extends Object> entry: context.entrySet()) { bsh.set(entry.getKey(), entry.getValue()); } - + // include the context itself in for easier access in the scripts bsh.set("context", context); } - + return bsh; } @@ -120,7 +120,7 @@ } } } - + if (master != null) { Interpreter interpreter = new Interpreter(new StringReader(""), System.out, System.err, false, new NameSpace(master, "global"), null, null); @@ -131,11 +131,11 @@ return interpreter; } } - + public static Object runBshAtLocation(String location, Map<String, ? extends Object> context) throws GeneralException { try { Interpreter interpreter = makeInterpreter(context); - + Interpreter.ParsedScript script = null; script = parsedScripts.get(location); if (script == null) { @@ -153,7 +153,7 @@ } } } - + return interpreter.evalParsedScript(script); } catch (MalformedURLException e) { String errMsg = "Error loading BSH script at [" + location + "]: " + e.toString(); @@ -175,7 +175,7 @@ } else { Debug.logError(t, "ERROR: Got cause (from getCause) for BSH EvalError: " + ee.toString(), module); } - + String errMsg = "Error running BSH script at [" + location + "], line [" + ee.getErrorLineNumber() + "]: " + t.toString(); // don't log the full exception, just the main message; more detail logged later throw new GeneralException(errMsg, t); Modified: ofbiz/trunk/framework/base/src/org/ofbiz/base/util/CachedClassLoader.java URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/base/src/org/ofbiz/base/util/CachedClassLoader.java?rev=759228&r1=759227&r2=759228&view=diff ============================================================================== --- ofbiz/trunk/framework/base/src/org/ofbiz/base/util/CachedClassLoader.java (original) +++ ofbiz/trunk/framework/base/src/org/ofbiz/base/util/CachedClassLoader.java Fri Mar 27 16:55:57 2009 @@ -31,13 +31,13 @@ * */ public class CachedClassLoader extends URLClassLoader { - + public interface Init { void loadClasses(ClassLoader loader, Map<String, Class<?>> classNameMap) throws ClassNotFoundException; } public static final String module = CachedClassLoader.class.getName(); - + private String contextName; public static Map<String, Class<?>> globalClassNameClassMap = new HashMap<String, Class<?>>(); @@ -59,7 +59,7 @@ globalClassNameClassMap.put("String", java.lang.String.class); globalClassNameClassMap.put("java.lang.String", java.lang.String.class); - + globalClassNameClassMap.put("Boolean", java.lang.Boolean.class); globalClassNameClassMap.put("java.lang.Boolean", java.lang.Boolean.class); @@ -80,7 +80,7 @@ globalClassNameClassMap.put("java.lang.Byte", java.lang.Byte.class); globalClassNameClassMap.put("Character", java.lang.Character.class); globalClassNameClassMap.put("java.lang.Character", java.lang.Character.class); - + globalClassNameClassMap.put("Timestamp", java.sql.Timestamp.class); globalClassNameClassMap.put("java.sql.Timestamp", java.sql.Timestamp.class); globalClassNameClassMap.put("Time", java.sql.Time.class); @@ -90,7 +90,7 @@ globalClassNameClassMap.put("Locale", java.util.Locale.class); globalClassNameClassMap.put("java.util.Locale", java.util.Locale.class); - + globalClassNameClassMap.put("java.util.Date", java.util.Date.class); globalClassNameClassMap.put("Collection", java.util.Collection.class); globalClassNameClassMap.put("java.util.Collection", java.util.Collection.class); @@ -125,7 +125,7 @@ } } } - + public CachedClassLoader(URL[] url, ClassLoader parent, String contextName) { super(url, parent); this.contextName = contextName; @@ -141,27 +141,27 @@ Debug.logVerbose("Cached ClassLoader Packages : " + pakList.toString(), module); } } - + public CachedClassLoader(ClassLoader parent, String contextName) { this(new URL[0], parent, contextName); } - + public CachedClassLoader(URL[] url, ClassLoader parent) { this(url, parent, "__globalContext"); } - + public String toString() { return "org.ofbiz.base.util.CachedClassLoader(" + contextName + ") / " + getParent().toString(); } - + public Class<?> loadClass(String name) throws ClassNotFoundException { return loadClass(name, false); } - + protected Class<?> loadClass(String name, boolean resolve) throws ClassNotFoundException { //check glocal common classes, ie for all instances Class<?> theClass = globalClassNameClassMap.get(name); - + //check local classes, ie for this instance if (theClass == null) theClass = localClassNameClassMap.get(name); @@ -172,10 +172,10 @@ throw new ClassNotFoundException("Cached loader got a known bad class name: " + name); } } - + if (theClass == null) { if (Debug.verboseOn()) Debug.logVerbose("Cached loader cache miss for class name: [" + name + "]", module); - + synchronized (this) { theClass = localClassNameClassMap.get(name); if (theClass == null) { @@ -201,11 +201,11 @@ } return theClass; } - + public URL getResource(String name) { //check glocal common resources, ie for all instances URL theResource = globalResourceMap.get(name); - + //check local resources, ie for this instance if (theResource == null) theResource = localResourceMap.get(name); @@ -216,11 +216,11 @@ return null; } } - + if (theResource == null) { if (Debug.verboseOn()) Debug.logVerbose("Cached loader cache miss for resource name: [" + name + "]", module); //Debug.logInfo("Cached loader cache miss for resource name: [" + name + "]", module); - + synchronized (this) { theResource = localResourceMap.get(name); if (theResource == null) { @@ -245,7 +245,7 @@ } return theResource; } - + protected boolean isGlobalPath(String name) { if (name.startsWith("java.") || name.startsWith("java/") || name.startsWith("/java/")) return true; if (name.startsWith("javax.") || name.startsWith("javax/") || name.startsWith("/javax/")) return true; Modified: ofbiz/trunk/framework/base/src/org/ofbiz/base/util/Debug.java URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/base/src/org/ofbiz/base/util/Debug.java?rev=759228&r1=759227&r2=759228&view=diff ============================================================================== --- ofbiz/trunk/framework/base/src/org/ofbiz/base/util/Debug.java (original) +++ ofbiz/trunk/framework/base/src/org/ofbiz/base/util/Debug.java Fri Mar 27 16:55:57 2009 @@ -42,7 +42,7 @@ public static final boolean useLog4J = true; public static final String noModuleModule = "NoModule"; // set to null for previous behavior - + static DateFormat dateFormat = DateFormat.getDateTimeInstance(DateFormat.SHORT, DateFormat.MEDIUM); public static final String SYS_DEBUG = System.getProperty("DEBUG"); @@ -61,14 +61,14 @@ public static final Level[] levelObjs = {Level.INFO, Level.DEBUG, Level.INFO, Level.INFO, Level.INFO, Level.WARN, Level.ERROR, Level.FATAL, NotifyLevel.NOTIFY}; protected static Map<String, Integer> levelStringMap = new HashMap<String, Integer>(); - + protected static PrintStream printStream = System.out; protected static PrintWriter printWriter = new PrintWriter(printStream); protected static boolean levelOnCache[] = new boolean[9]; protected static boolean packException = true; protected static final boolean useLevelOnCache = true; - + protected static Logger root = Logger.getRootLogger(); static { @@ -81,7 +81,7 @@ levelStringMap.put("fatal", Debug.FATAL); levelStringMap.put("always", Debug.ALWAYS); levelStringMap.put("notify", Debug.NOTIFY); - + // initialize Log4J if (!UtilProperties.propertyValueEqualsIgnoreCase("debug.properties", "disable.log4j.config", "true")) { org.apache.log4j.xml.DOMConfigurator.configure(UtilURL.fromResource("log4j.xml")); @@ -91,7 +91,7 @@ for (int i = 0; i < 9; i++) { levelOnCache[i] = (i == Debug.ALWAYS || UtilProperties.propertyValueEqualsIgnoreCase("debug.properties", levelProps[i], "true")); } - + if (SYS_DEBUG != null) { for (int x = 0; x < 8; x++) { levelOnCache[x] = true; @@ -107,7 +107,7 @@ // configure exception packing packException = UtilProperties.propertyValueEqualsIgnoreCase("debug.properties", "pack.exception", "true"); } - + public static PrintStream getPrintStream() { return printStream; } @@ -134,7 +134,7 @@ if (levelName == null) return null; return levelStringMap.get(levelName.toLowerCase()); } - + /** Gets an int representing the level number from a String representing the level name; if level not found defaults to Debug.INFO */ public static int getLevelFromStringWithDefault(String levelName) { Integer levelInt = getLevelFromString(levelName); @@ -144,7 +144,7 @@ return levelInt; } } - + public static void log(int level, Throwable t, String msg, String module) { log(level, t, msg, module, "org.ofbiz.base.util.Debug"); } @@ -196,7 +196,7 @@ return (level == Debug.ALWAYS || UtilProperties.propertyValueEqualsIgnoreCase("debug", levelProps[level], "true")); } } - + // leaving these here public static void log(String msg) { log(Debug.ALWAYS, null, msg, noModuleModule); @@ -209,7 +209,7 @@ log(Debug.ALWAYS, null, msg, module); } - + public static void log(Throwable t, String module) { log(Debug.ALWAYS, t, null, module); } @@ -221,11 +221,11 @@ public static boolean verboseOn() { return isOn(Debug.VERBOSE); } - + public static void logVerbose(String msg, String module) { log(Debug.VERBOSE, null, msg, module); } - + public static void logVerbose(Throwable t, String module) { log(Debug.VERBOSE, t, null, module); } @@ -237,7 +237,7 @@ public static boolean timingOn() { return isOn(Debug.TIMING); } - + public static void logTiming(String msg, String module) { log(Debug.TIMING, null, msg, module); } @@ -253,7 +253,7 @@ public static boolean infoOn() { return isOn(Debug.INFO); } - + public static void logInfo(String msg, String module) { log(Debug.INFO, null, msg, module); } Modified: ofbiz/trunk/framework/base/src/org/ofbiz/base/util/FileUtil.java URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/base/src/org/ofbiz/base/util/FileUtil.java?rev=759228&r1=759227&r2=759228&view=diff ============================================================================== --- ofbiz/trunk/framework/base/src/org/ofbiz/base/util/FileUtil.java (original) +++ ofbiz/trunk/framework/base/src/org/ofbiz/base/util/FileUtil.java Fri Mar 27 16:55:57 2009 @@ -77,7 +77,7 @@ } } } - + /** * Writes a file from a string with a specified encoding. * @@ -100,7 +100,7 @@ throw e; } } - + public static void writeString(String encoding, String s, File outFile) throws IOException { try { FileUtils.writeStringToFile(outFile, s, encoding); @@ -109,7 +109,7 @@ throw e; } } - + public static Writer getBufferedWriter(String path, String name) throws IOException { String fileName = getPatchedFileName(path, name); if (UtilValidate.isEmpty(fileName)) { @@ -181,14 +181,14 @@ } } } - + return buf; } public static StringBuffer readTextFile(String fileName, boolean newline) throws FileNotFoundException, IOException { File file = new File(fileName); return readTextFile(file, newline); } - + public static String readString(String encoding, File inFile) throws IOException { String readString = ""; try { @@ -199,11 +199,11 @@ } return readString; } - + public static void searchFiles(List<File> fileList, File path, FilenameFilter filter, boolean includeSubfolders) throws IOException { // Get filtered files in the current path File[] files = path.listFiles(filter); - + // Process each filtered entry for (int i = 0; i < files.length; i++) { // recurse if the entry is a directory @@ -215,50 +215,50 @@ } } } - + public static List<File> findFiles(String fileExt, String basePath, String partialPath, String stringToFind) throws IOException { if (basePath == null) { basePath = System.getProperty("ofbiz.home"); } - + Set<String> stringsToFindInPath = FastSet.newInstance(); Set<String> stringsToFindInFile = FastSet.newInstance(); - + if (partialPath != null) { stringsToFindInPath.add(partialPath); } if (stringToFind != null) { stringsToFindInFile.add(stringToFind); } - + List<File> fileList = FastList.newInstance(); FileUtil.searchFiles(fileList, new File(basePath), new SearchTextFilesFilter(fileExt, stringsToFindInPath, stringsToFindInFile), true); - + return fileList; } - + public static List<File> findXmlFiles(String basePath, String partialPath, String rootElementName, String xsdOrDtdName) throws IOException { if (basePath == null) { basePath = System.getProperty("ofbiz.home"); } - + Set<String> stringsToFindInPath = FastSet.newInstance(); Set<String> stringsToFindInFile = FastSet.newInstance(); - + if (partialPath != null) stringsToFindInPath.add(partialPath); if (rootElementName != null) stringsToFindInFile.add("<" + rootElementName + " "); if (xsdOrDtdName != null) stringsToFindInFile.add(xsdOrDtdName); - + List<File> fileList = FastList.newInstance(); FileUtil.searchFiles(fileList, new File(basePath), new SearchTextFilesFilter("xml", stringsToFindInPath, stringsToFindInFile), true); return fileList; } - + public static class SearchTextFilesFilter implements FilenameFilter { String fileExtension; Set<String> stringsToFindInFile = FastSet.newInstance(); Set<String> stringsToFindInPath = FastSet.newInstance(); - + public SearchTextFilesFilter(String fileExtension, Set<String> stringsToFindInPath, Set<String> stringsToFindInFile) { this.fileExtension = fileExtension; if (stringsToFindInPath != null) { @@ -268,7 +268,7 @@ this.stringsToFindInFile.addAll(stringsToFindInFile); } } - + public boolean accept(File dir, String name) { File file = new File(dir, name); if (file.getName().startsWith(".")) { @@ -277,7 +277,7 @@ if (file.isDirectory()) { return true; } - + boolean hasAllPathStrings = true; String fullPath = dir.getPath().replace('\\', '/'); for (String pathString: stringsToFindInPath) { @@ -286,7 +286,7 @@ break; } } - + if (hasAllPathStrings && name.endsWith("." + fileExtension)) { StringBuffer xmlFileBuffer = null; try { Modified: ofbiz/trunk/framework/base/src/org/ofbiz/base/util/GroovyUtil.java URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/base/src/org/ofbiz/base/util/GroovyUtil.java?rev=759228&r1=759227&r2=759228&view=diff ============================================================================== --- ofbiz/trunk/framework/base/src/org/ofbiz/base/util/GroovyUtil.java (original) +++ ofbiz/trunk/framework/base/src/org/ofbiz/base/util/GroovyUtil.java Fri Mar 27 16:55:57 2009 @@ -43,7 +43,7 @@ public static final String module = GroovyUtil.class.getName(); public static UtilCache<String, Class> parsedScripts = new UtilCache<String, Class>("script.GroovyLocationParsedCache", 0, 0, false); - + public static GroovyClassLoader groovyClassLoader = new GroovyClassLoader(); private static Binding getBinding(Map<String, Object> context) { @@ -69,7 +69,7 @@ if (scriptUrl == null) { throw new GeneralException("Script not found at location [" + location + "]"); } - + scriptClass = groovyClassLoader.parseClass(scriptUrl.openStream(), scriptUrl.getFile()); if (Debug.verboseOn()) Debug.logVerbose("Caching Groovy script at: " + location, module); parsedScripts.put(location, scriptClass); @@ -82,7 +82,7 @@ InvokerHelper.createScript(scriptClass, getBinding(context)).run(); if (Debug.timingOn()) Debug.logTiming("Ran parsed groovy script in [" + (System.currentTimeMillis() - startTimeParsed) + "]ms at: " + location, module); */ - + /* NOTE DEJ20080526: this approach uses a pre-parsed script but it is not thread safe * * the groovy Script object contains both the parsed script AND the context, which is weird when trying to run a cached Script @@ -93,19 +93,19 @@ if (scriptUrl == null) { throw new GeneralException("Script not found at location [" + location + "]"); } - + script = emptyGroovyShell.parse(scriptUrl.openStream(), scriptUrl.getFile()); if (Debug.verboseOn()) Debug.logVerbose("Caching Groovy script at: " + location, module); parsedScripts.put(location, script); } - + script.setBinding(getBinding(context)); return script.run(); */ /* NOTE DEJ20080527: this approach works but only caches script text, not the parsed script public static UtilCache<String, String> sourceScripts = new UtilCache<String, String>("script.GroovyLocationSourceCache", 0, 0, false); - + public static GroovyShell emptyGroovyShell = new GroovyShell(); String scriptString = sourceScripts.get(location); if (scriptString == null) { @@ -113,9 +113,9 @@ if (scriptUrl == null) { throw new GeneralException("Script not found at location [" + location + "]"); } - + scriptString = UtilURL.readUrlText(scriptUrl); - + if (Debug.verboseOn()) Debug.logVerbose("Caching Groovy script source at: " + location, module); sourceScripts.put(location, scriptString); } @@ -125,7 +125,7 @@ script.setBinding(getBinding(context)); Object scriptResult = script.run(); if (Debug.timingOn()) Debug.logTiming("Parsed and ran groovy script in [" + (System.currentTimeMillis() - startTime) + "]ms at: " + location, module); - + return scriptResult; */ } catch (MalformedURLException e) { Modified: ofbiz/trunk/framework/base/src/org/ofbiz/base/util/HttpClient.java URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/base/src/org/ofbiz/base/util/HttpClient.java?rev=759228&r1=759227&r2=759228&view=diff ============================================================================== --- ofbiz/trunk/framework/base/src/org/ofbiz/base/util/HttpClient.java (original) +++ ofbiz/trunk/framework/base/src/org/ofbiz/base/util/HttpClient.java Fri Mar 27 16:55:57 2009 @@ -35,7 +35,7 @@ * */ public class HttpClient { - + public static final String module = HttpClient.class.getName(); private int hostVerification = SSLUtil.HOSTCERT_NORMAL_CHECK; @@ -55,7 +55,7 @@ private Map<String, Object> parameters = null; private Map<String, String> headers = null; - + private URL requestUrl = null; private URLConnection con = null; @@ -107,22 +107,22 @@ public void setTimeout(int timeout) { this.timeout = timeout; } - + /** Enables this request to follow redirect 3xx codes (default true) */ public void followRedirects(boolean followRedirects) { this.followRedirects = followRedirects; } - + /** Turns on or off line feeds in the request. (default is on) */ public void setLineFeed(boolean lineFeed) { this.lineFeed = lineFeed; } - + /** Set the raw stream for posts. */ public void setRawStream(String stream) { this.rawStream = stream; } - + /** Set the URL for this request. */ public void setUrl(URL url) { this.url = url.toExternalForm(); @@ -196,7 +196,7 @@ public void setClientCertificateAlias(String alias) { this.clientCertAlias = alias; } - + /** Returns the alias of the client certificate to be used for this SSL connection. */ public String getClientCertificateAlias() { return this.clientCertAlias; @@ -221,12 +221,12 @@ public boolean getAllowUntrusted() { return this.trustAny; } - + public void setBasicAuthInfo(String basicAuthUsername, String basicAuthPassword) { this.basicAuthUsername = basicAuthUsername; this.basicAuthPassword = basicAuthPassword; } - + /** Invoke HTTP request GET. */ public String get() throws HttpClientException { return sendHttpRequest("get"); @@ -241,7 +241,7 @@ public String post() throws HttpClientException { return sendHttpRequest("post"); } - + /** Invoke HTTP request POST and pass raw stream. */ public String post(String stream) throws HttpClientException { this.rawStream = stream; @@ -338,7 +338,7 @@ Debug.logWarning(ioe, "Caught exception printing content debugging information", module); } } - + String charset = null; String contentType = con.getContentType(); if (contentType == null) { @@ -348,9 +348,9 @@ Debug.logWarning(ioe, "Problems guessing content type from steam", module); } } - + if (Debug.verboseOn() || debug) Debug.log("Content-Type: " + contentType, module); - + if (contentType != null) { contentType = contentType.toUpperCase(); int charsetEqualsLoc = contentType.indexOf("=", contentType.indexOf("CHARSET")); @@ -360,11 +360,11 @@ } else if (charsetEqualsLoc >= 0) { charset = contentType.substring(charsetEqualsLoc + 1); } - + if (charset != null) charset = charset.trim(); if (Debug.verboseOn() || debug) Debug.log("Getting text from HttpClient with charset: " + charset, module); } - + BufferedReader post = new BufferedReader(charset == null ? new InputStreamReader(in) : new InputStreamReader(in, charset)); String line = new String(); @@ -389,7 +389,7 @@ private InputStream sendHttpRequestStream(String method, boolean overrideTrust) throws HttpClientException { // setup some SSL variables SSLUtil.loadJsseProperties(); - + String arguments = null; InputStream in = null; @@ -445,14 +445,14 @@ } con.setDoInput(true); } - + // if there is basicAuth info set the request property for it if (basicAuthUsername != null) { String basicAuthString = "Basic " + Base64.base64Encode(basicAuthUsername + ":" + (basicAuthPassword == null ? "" : basicAuthPassword)); con.setRequestProperty("Authorization", basicAuthString); if (Debug.verboseOn() || debug) Debug.log("Header - Authorization: " + basicAuthString, module); } - + if (UtilValidate.isNotEmpty(headers)) { for (Map.Entry<String, String> entry: headers.entrySet()) { String headerName = entry.getKey(); Modified: ofbiz/trunk/framework/base/src/org/ofbiz/base/util/JNDIContextFactory.java URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/base/src/org/ofbiz/base/util/JNDIContextFactory.java?rev=759228&r1=759227&r2=759228&view=diff ============================================================================== --- ofbiz/trunk/framework/base/src/org/ofbiz/base/util/JNDIContextFactory.java (original) +++ ofbiz/trunk/framework/base/src/org/ofbiz/base/util/JNDIContextFactory.java Fri Mar 27 16:55:57 2009 @@ -32,7 +32,7 @@ * */ public class JNDIContextFactory { - + public static final String module = JNDIContextFactory.class.getName(); static UtilCache<String, InitialContext> contexts = new UtilCache<String, InitialContext>("entity.JNDIContexts", 0, 0); Modified: ofbiz/trunk/framework/base/src/org/ofbiz/base/util/KeyStoreUtil.java URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/base/src/org/ofbiz/base/util/KeyStoreUtil.java?rev=759228&r1=759227&r2=759228&view=diff ============================================================================== --- ofbiz/trunk/framework/base/src/org/ofbiz/base/util/KeyStoreUtil.java (original) +++ ofbiz/trunk/framework/base/src/org/ofbiz/base/util/KeyStoreUtil.java Fri Mar 27 16:55:57 2009 @@ -94,7 +94,7 @@ if (password == null) { password = "changeit"; } - + KeyStore ks = KeyStore.getInstance("jks"); File keyFile = null; if (fileName != null) { @@ -130,7 +130,7 @@ public static Map<String, String> getX500Map(Principal x500) { Map<String, String> x500Map = FastMap.newInstance(); - + String name = x500.getName().replaceAll("\\\\,", "&com;"); String[] x500Opts = name.split("\\,"); for (String opt: x500Opts) { @@ -142,7 +142,7 @@ return x500Map; } - + public static void importPKCS8CertChain(KeyStore ks, String alias, byte[] keyBytes, String keyPass, byte[] certChain) throws InvalidKeySpecException, NoSuchAlgorithmException, CertificateException, KeyStoreException { // load the private key KeyFactory kf = KeyFactory.getInstance("RSA"); Modified: ofbiz/trunk/framework/base/src/org/ofbiz/base/util/MessageString.java URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/base/src/org/ofbiz/base/util/MessageString.java?rev=759228&r1=759227&r2=759228&view=diff ============================================================================== --- ofbiz/trunk/framework/base/src/org/ofbiz/base/util/MessageString.java (original) +++ ofbiz/trunk/framework/base/src/org/ofbiz/base/util/MessageString.java Fri Mar 27 16:55:57 2009 @@ -32,9 +32,9 @@ */ @SuppressWarnings("serial") public class MessageString implements Serializable { - + public static final String module = MessageString.class.getName(); - + protected String message; protected String fieldName; protected String toFieldName; @@ -43,7 +43,7 @@ protected String propertyResource; protected String propertyName; protected boolean isError = true; - + public static List<Object> getMessagesForField(String fieldName, boolean convertToStrings, List<Object> messageStringList) { if (fieldName == null) { return Collections.emptyList(); @@ -82,7 +82,7 @@ } return outList; } - + /** * @param message * @param fieldName @@ -129,7 +129,7 @@ this.sourceError = sourceError; this.isError = true; } - + /** * @return Returns the fieldName. */ @@ -159,7 +159,7 @@ return this.fieldName.equals(fieldName); } } - + /** * @return Returns the message. */ @@ -233,7 +233,7 @@ public void setPropertyResource(String propertyResource) { this.propertyResource = propertyResource; } - + /** * @return Returns the isError. */ Modified: ofbiz/trunk/framework/base/src/org/ofbiz/base/util/NotifyLevel.java URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/base/src/org/ofbiz/base/util/NotifyLevel.java?rev=759228&r1=759227&r2=759228&view=diff ============================================================================== --- ofbiz/trunk/framework/base/src/org/ofbiz/base/util/NotifyLevel.java (original) +++ ofbiz/trunk/framework/base/src/org/ofbiz/base/util/NotifyLevel.java Fri Mar 27 16:55:57 2009 @@ -15,7 +15,7 @@ public static final int NOTIFY_INT = FATAL_INT + 10000; public static final Level NOTIFY = new NotifyLevel(NOTIFY_INT, "NOTIFY", SyslogAppender.LOG_LOCAL0); public static final Level notify = new NotifyLevel(NOTIFY_INT, "notify", SyslogAppender.LOG_LOCAL0); - + public NotifyLevel(int level, String levelStr, int syslogEquivalent) { super(level, levelStr, syslogEquivalent); } Modified: ofbiz/trunk/framework/base/src/org/ofbiz/base/util/ObjectType.java URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/base/src/org/ofbiz/base/util/ObjectType.java?rev=759228&r1=759227&r2=759228&view=diff ============================================================================== --- ofbiz/trunk/framework/base/src/org/ofbiz/base/util/ObjectType.java (original) +++ ofbiz/trunk/framework/base/src/org/ofbiz/base/util/ObjectType.java Fri Mar 27 16:55:57 2009 @@ -37,11 +37,11 @@ * Takes advantage of reflection */ public class ObjectType { - + public static final String module = ObjectType.class.getName(); public static final Object NULL = new NullObject(); - + protected static Map<String, Class<?>> classCache = FastMap.newInstance(); public static final String LANG_PACKAGE = "java.lang."; // We will test both the raw value and this + raw value @@ -86,7 +86,7 @@ className = "[L" + arrayClass.getName().replace("[]", "") + ";"; } } - + // small block to speed things up by putting using preloaded classes for common objects, this turns out to help quite a bit... Class<?> theClass = CachedClassLoader.globalClassNameClassMap.get(className); @@ -502,7 +502,7 @@ if (str.length() == 0) { return null; } - + if ("Boolean".equals(type) || "java.lang.Boolean".equals(type)) { str = StringUtil.removeSpaces(str); return str.equalsIgnoreCase("TRUE") ? Boolean.TRUE : Boolean.FALSE; @@ -985,7 +985,7 @@ Debug.logWarning("No special conversion available for " + obj.getClass().getName() + " to String, returning object.toString().", module); return obj.toString(); } - + if (noTypeFail) { throw new GeneralException("Conversion from " + obj.getClass().getName() + " to " + type + " not currently supported"); } else { @@ -1026,7 +1026,7 @@ } else if ("contains".equals(operator) && value1 == null) { return Boolean.FALSE; } - + int result = 0; Object convertedValue2 = null; @@ -1110,7 +1110,7 @@ return Boolean.FALSE; return Boolean.TRUE; } - + if ("java.lang.String".equals(type) || "PlainString".equals(type)) { String str1 = (String) convertedValue1; String str2 = (String) convertedValue2; @@ -1206,10 +1206,10 @@ if (verboseOn) Debug.logVerbose("Returning true", module); return Boolean.TRUE; } - + public static boolean isEmpty(Object value) { if (value == null) return true; - + if (value instanceof String) { if (((String) value).length() == 0) { return true; @@ -1225,14 +1225,14 @@ } return false; } - + public static final class NullObject { public NullObject() { } - + public String toString() { return "ObjectType.NullObject"; } - + public boolean equals(Object other) { if (other instanceof NullObject) { // should do equality of object? don't think so, just same type Modified: ofbiz/trunk/framework/base/src/org/ofbiz/base/util/OfbizBshBsfEngine.java URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/base/src/org/ofbiz/base/util/OfbizBshBsfEngine.java?rev=759228&r1=759227&r2=759228&view=diff ============================================================================== --- ofbiz/trunk/framework/base/src/org/ofbiz/base/util/OfbizBshBsfEngine.java (original) +++ ofbiz/trunk/framework/base/src/org/ofbiz/base/util/OfbizBshBsfEngine.java Fri Mar 27 16:55:57 2009 @@ -22,10 +22,10 @@ * Based on code that started with this header/license: This file is associated with the BeanShell Java Scripting language distribution (http://www.beanshell.org/). - + This file is hereby placed into the public domain... You may copy, modify, and redistribute it without restriction. - + */ import java.io.StringReader; @@ -55,36 +55,36 @@ * */ public class OfbizBshBsfEngine extends BSFEngineImpl { - + public static final String module = OfbizBshBsfEngine.class.getName(); - + protected Interpreter interpreter; protected boolean installedApplyMethod; - + public static UtilCache<String, Interpreter.ParsedScript> parsedScripts = new UtilCache<String, Interpreter.ParsedScript>("script.BshBsfParsedCache", 0, 0, false); - + public void initialize(BSFManager mgr, String lang, Vector declaredBeans) throws BSFException { super.initialize(mgr, lang, declaredBeans); - + interpreter = BshUtil.getMasterInterpreter(null); - + // declare the bsf manager for callbacks, etc. try { interpreter.set("bsf", mgr); } catch (EvalError e) { throw new BSFException("bsh internal error: "+e.toString()); } - + for(int i=0; i<declaredBeans.size(); i++) { BSFDeclaredBean bean = (BSFDeclaredBean)declaredBeans.get(i); declareBean(bean); } } - + public void setDebug(boolean debug) { Interpreter.DEBUG=debug; } - + /** * Invoke method name on the specified bsh scripted object. * The object may be null to indicate the global namespace of the @@ -99,7 +99,7 @@ throw new BSFException("bsh internal error: "+e.toString()); } } - + if (object instanceof bsh.This) { try { return ((bsh.This)object).invokeMethod(name, args); @@ -115,8 +115,8 @@ ". Object: "+object +" is not a BeanShell scripted object."); } } - - + + /** * A helper BeanShell method that implements the anonymous method apply * proposed by BSF. Note that the script below could use the standard @@ -129,7 +129,7 @@ +"this.namespace.setVariable(_bsfNames[i], _bsfArgs[i]);" +"return this.interpreter.eval(_bsfText, this.namespace);" +"}"; - + /** * This is an implementation of the BSF apply() method. * It exectutes the funcBody text in an "anonymous" method call with @@ -138,21 +138,21 @@ public Object apply(String source, int lineNo, int columnNo, Object funcBody, Vector namesVec, Vector argsVec) throws BSFException { if (namesVec.size() != argsVec.size()) throw new BSFException("number of params/names mismatch"); if (!(funcBody instanceof String)) throw new BSFException("apply: function body must be a string"); - + String [] names = new String [ namesVec.size() ]; namesVec.copyInto(names); Object [] args = new String [ argsVec.size() ]; argsVec.copyInto(args); - + try { if (!installedApplyMethod) { interpreter.eval(bsfApplyMethod); installedApplyMethod = true; } - + bsh.This global = (bsh.This)interpreter.get("global"); return global.invokeMethod("_bsfApply", new Object [] { names, args, (String)funcBody }); - + } catch (InterpreterError e) { throw new BSFException("BeanShell interpreter internal error: " + e + sourceInfo(source,lineNo,columnNo)); } catch (TargetError e2) { @@ -161,15 +161,15 @@ throw new BSFException("BeanShell script error: " + e3 + sourceInfo(source,lineNo,columnNo)); } } - + public Object eval(String source, int lineNo, int columnNo, Object expr) throws BSFException { if (!(expr instanceof String)) throw new BSFException("BeanShell expression must be a string"); - + try { //return interpreter.eval(((String) expr)); - + Interpreter.ParsedScript script = null; - + if (source != null && source.length() > 0) { script = parsedScripts.get(source); if (script == null) { @@ -185,7 +185,7 @@ } else { script = interpreter.parseScript(source, new StringReader((String) expr)); } - + return interpreter.evalParsedScript(script); } catch (InterpreterError e) { throw new BSFException("BeanShell interpreter internal error: "+ e + sourceInfo(source,lineNo,columnNo)); @@ -197,25 +197,25 @@ throw new BSFException("BeanShell script error: " + e3 + sourceInfo(source,lineNo,columnNo)); } } - - + + public void exec(String source, int lineNo, int columnNo, Object script) throws BSFException { eval(source, lineNo, columnNo, script); } - - + + /* public void compileApply (String source, int lineNo, int columnNo, Object funcBody, Vector paramNames, Vector arguments, CodeBuffer cb) throws BSFException; - + public void compileExpr (String source, int lineNo, int columnNo, Object expr, CodeBuffer cb) throws BSFException; - + public void compileScript (String source, int lineNo, int columnNo, Object script, CodeBuffer cb) throws BSFException; */ - + public void declareBean(BSFDeclaredBean bean) throws BSFException { try { interpreter.set(bean.name, bean.bean); @@ -223,7 +223,7 @@ throw new BSFException("error declaring bean: " + bean.name + " : " + e.toString()); } } - + public void undeclareBean(BSFDeclaredBean bean) throws BSFException { try { interpreter.unset(bean.name); @@ -231,9 +231,9 @@ throw new BSFException("bsh internal error: " + e.toString()); } } - + public void terminate() { } - + private String sourceInfo(String source, int lineNo, int columnNo) { return "BSF info: " + source + " at line: " + lineNo +" column: " + columnNo; } Modified: ofbiz/trunk/framework/base/src/org/ofbiz/base/util/OutputStreamByteCount.java URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/base/src/org/ofbiz/base/util/OutputStreamByteCount.java?rev=759228&r1=759227&r2=759228&view=diff ============================================================================== --- ofbiz/trunk/framework/base/src/org/ofbiz/base/util/OutputStreamByteCount.java (original) +++ ofbiz/trunk/framework/base/src/org/ofbiz/base/util/OutputStreamByteCount.java Fri Mar 27 16:55:57 2009 @@ -46,7 +46,7 @@ public void write(byte[] b, int off, int len) throws IOException { byteCount += len; } - + public long getByteCount() { return this.byteCount; } Modified: ofbiz/trunk/framework/base/src/org/ofbiz/base/util/SSLUtil.java URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/base/src/org/ofbiz/base/util/SSLUtil.java?rev=759228&r1=759227&r2=759228&view=diff ============================================================================== --- ofbiz/trunk/framework/base/src/org/ofbiz/base/util/SSLUtil.java (original) +++ ofbiz/trunk/framework/base/src/org/ofbiz/base/util/SSLUtil.java Fri Mar 27 16:55:57 2009 @@ -107,7 +107,7 @@ if (tm.getNumberOfKeyStores() < 1) { Debug.logWarning("System truststore not found!", module); } - + for (ComponentConfig.KeystoreInfo ksi: ComponentConfig.getAllKeystoreInfos()) { if (ksi.isTrustStore()) { KeyStore ks = ksi.getKeyStore(); @@ -212,7 +212,7 @@ if (Debug.infoOn()) Debug.logInfo(peerCert.getSerialNumber().toString(16) + " :: " + subjectMap.get("CN"), module); - + try { peerCert.checkValidity(); } catch (Exception e) { Modified: ofbiz/trunk/framework/base/src/org/ofbiz/base/util/StringUtil.java URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/base/src/org/ofbiz/base/util/StringUtil.java?rev=759228&r1=759227&r2=759228&view=diff ============================================================================== --- ofbiz/trunk/framework/base/src/org/ofbiz/base/util/StringUtil.java (original) +++ ofbiz/trunk/framework/base/src/org/ofbiz/base/util/StringUtil.java Fri Mar 27 16:55:57 2009 @@ -54,7 +54,7 @@ * */ public class StringUtil { - + public static final String module = StringUtil.class.getName(); /** OWASP ESAPI canonicalize strict flag; setting false so we only get warnings about double encoding, etc; can be set to true for exceptions and more security */ @@ -67,28 +67,28 @@ defaultWebEncoder = new DefaultEncoder(codecList); defaultWebValidator = new DefaultValidator(); } - + public static final SimpleEncoder htmlEncoder = new HtmlEncoder(); public static final SimpleEncoder xmlEncoder = new XmlEncoder(); - + public static interface SimpleEncoder { public String encode(String original); } - + public static class HtmlEncoder implements SimpleEncoder { public String encode(String original) { return StringUtil.defaultWebEncoder.encodeForHTML(original); } } - + public static class XmlEncoder implements SimpleEncoder { public String encode(String original) { return StringUtil.defaultWebEncoder.encodeForXML(original); } } - + // ================== Begin General Functions ================== - + public static String internString(String value) { return value != null ? value.intern() : null; } @@ -260,7 +260,7 @@ } catch (UnsupportedEncodingException e) { Debug.logError(e, module); } - + if (first) first = false; else @@ -369,7 +369,7 @@ } return cppBuff.toString(); } - + /** Removes all spaces from a string */ public static String removeSpaces(String str) { return removeRegex(str,"[\\ ]"); @@ -397,7 +397,7 @@ throw new GeneralRuntimeException(e); } } - + private static char[] hexChar = { '0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'a', 'b', 'c', 'd', 'e', 'f' }; public static int convertChar(char c) { if ( '0' <= c && c <= '9' ) { @@ -427,7 +427,7 @@ public static String removeNonNumeric(String str) { return removeRegex(str,"[\\D]"); } - + /** Removes all numbers from str */ public static String removeNumeric(String str) { return removeRegex(str,"[\\d]"); @@ -443,7 +443,7 @@ Matcher matcher = pattern.matcher(str); return matcher.replaceAll(""); } - + /** * Add the number to the string, keeping (padding to min of original length) * @@ -451,12 +451,12 @@ */ public static String addToNumberString(String numberString, long addAmount) { if (numberString == null) return null; - + int origLength = numberString.length(); long number = Long.parseLong(numberString); return padNumberString(Long.toString(number + addAmount), origLength); } - + public static String padNumberString(String numberString, int targetMinLength) { StringBuilder outStrBfr = new StringBuilder(numberString); while (targetMinLength > outStrBfr.length()) { @@ -474,7 +474,7 @@ */ public static String checkStringForHtmlStrictNone(String valueName, String value, List<String> errorMessageList) { if (UtilValidate.isEmpty(value)) return value; - + // canonicalize, strict (error on double-encoding) try { value = defaultWebEncoder.canonicalize(value, true); @@ -483,12 +483,12 @@ Debug.logError("Canonicalization (format consistency, character escaping that is mixed or double, etc) error for attribute named [" + valueName + "], String [" + value + "]: " + e.toString(), module); errorMessageList.add("In field [" + valueName + "] found character espacing (mixed or double) that is not allowed or other format consistency error: " + e.toString()); } - + // check for "<", ">" if (value.indexOf("<") >= 0 || value.indexOf(">") >= 0) { errorMessageList.add("In field [" + valueName + "] less-than (<) and greater-than (>) symbols are not allowed."); } - + /* NOTE DEJ 20090311: After playing with this more this doesn't seem to be necessary; the canonicalize will convert all such characters into actual text before this check is done, including other illegal chars like < which will canonicalize to < and then get caught // check for & followed a semicolon within 7 characters, no spaces in-between (and perhaps other things sometime?) int curAmpIndex = value.indexOf("&"); @@ -503,7 +503,7 @@ curAmpIndex = value.indexOf("&", curAmpIndex + 1); } */ - + /* NOTE DEJ 20090311: After playing with this more this doesn't seem to be necessary; the canonicalize will convert all such characters into actual text before this check is done, including other illegal chars like %3C which will canonicalize to < and then get caught // check for % followed by 2 hex characters int curPercIndex = value.indexOf("%"); @@ -516,9 +516,9 @@ curPercIndex = value.indexOf("%", curPercIndex + 1); } */ - + // TODO: anything else to check for that can be used to get HTML or JavaScript going without these characters? - + return value; } @@ -536,7 +536,7 @@ errorMessageList.addAll(UtilGenerics.checkList(vel.errors(), String.class)); return value; } - + /** * Translates various HTML characters in a string so that the string can be displayed in a browser safely * <p> @@ -571,11 +571,11 @@ return html; } - + public static String htmlSpecialChars(String html) { return htmlSpecialChars(html, true, true, true); } - + public static String fromHtmlToSpecialChars(String html, boolean doubleQuotes, boolean singleQuotes, boolean insertBR) { html = StringUtil.replaceString(html, "&", "&"); html = StringUtil.replaceString(html, "<", "<"); @@ -649,13 +649,13 @@ */ public static class StringWrapper { public static final StringWrapper EMPTY_STRING_WRAPPER = new StringWrapper(""); - + protected String theString; protected StringWrapper() { } public StringWrapper(String theString) { this.theString = theString; } - + /** * Fairly simple method used for the plus (+) base concatenation in Groovy. * @@ -686,7 +686,7 @@ }; public static <K> HtmlEncodingMapWrapper<K> getHtmlEncodingMapWrapper(Map<K, Object> mapToWrap, SimpleEncoder encoder) { if (mapToWrap == null) return null; - + HtmlEncodingMapWrapper<K> mapWrapper = (HtmlEncodingMapWrapper<K>) UtilGenerics.<K, Object>checkMap(mapStackFactory.object()); mapWrapper.setup(mapToWrap, encoder); return mapWrapper; @@ -695,7 +695,7 @@ protected Map<K, Object> internalMap = null; protected SimpleEncoder encoder = null; protected HtmlEncodingMapWrapper() { } - + public void setup(Map<K, Object> mapToWrap, SimpleEncoder encoder) { this.internalMap = mapToWrap; this.encoder = encoder; @@ -704,7 +704,7 @@ this.internalMap = null; this.encoder = null; } - + public int size() { return this.internalMap.size(); } public boolean isEmpty() { return this.internalMap.isEmpty(); } public boolean containsKey(Object key) { return this.internalMap.containsKey(key); } |
Free forum by Nabble | Edit this page |