From 31e29fdc5c77c600fd7e3b43ee2c19c49cc38b4a Mon Sep 17 00:00:00 2001 From: Andrew Zeneski Date: Fri, 30 Mar 2007 02:06:06 +0000 Subject: [PATCH] small change to get information from other places git-svn-id: https://svn.apache.org/repos/asf/ofbiz/trunk@523909 13f79535-47bb-0310-9956-ffa450edef68 --- .../location/ComponentLocationResolver.java | 29 +++++++++++-------- 1 file changed, 17 insertions(+), 12 deletions(-) diff --git a/framework/base/src/base/org/ofbiz/base/location/ComponentLocationResolver.java b/framework/base/src/base/org/ofbiz/base/location/ComponentLocationResolver.java index f89053b677..38e9d03f74 100644 --- a/framework/base/src/base/org/ofbiz/base/location/ComponentLocationResolver.java +++ b/framework/base/src/base/org/ofbiz/base/location/ComponentLocationResolver.java @@ -35,9 +35,20 @@ public class ComponentLocationResolver implements LocationResolver { public static final String module = ComponentLocationResolver.class.getName(); - public URL resolveLocation(String location) throws MalformedURLException { - StringBuffer baseLocation = new StringBuffer(FlexibleLocation.stripLocationType(location)); + 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; + } + + public static StringBuffer getBaseLocation(String location) throws MalformedURLException { + StringBuffer baseLocation = new StringBuffer(FlexibleLocation.stripLocationType(location)); + // componentName is between the first slash and the second int firstSlash = baseLocation.indexOf("/"); int secondSlash = baseLocation.indexOf("/", firstSlash + 1); @@ -45,15 +56,15 @@ public class ComponentLocationResolver implements LocationResolver { throw new MalformedURLException("Bad component location [" + location + "]: base location missing slashes [" + baseLocation + "], first=" + firstSlash + ", second=" + secondSlash + "; should be like: component://{component-name}/relative/path"); } String componentName = baseLocation.substring(firstSlash + 1, secondSlash); - + // got the componentName, now remove it from the baseLocation, removing the second slash too (just in case the rootLocation has one) baseLocation.delete(0, secondSlash + 1); - String rootLocation = null; + String rootLocation; try { rootLocation = ComponentConfig.getRootLocation(componentName); } catch (ComponentException e) { - String errMsg = "Could not get root location for component with name [" + componentName + "], error was: " + e.toString(); + String errMsg = "Could not get root location for component with name [" + componentName + "], error was: " + e.toString(); Debug.logError(e, errMsg, module); throw new MalformedURLException(errMsg); } @@ -66,12 +77,6 @@ public class ComponentLocationResolver implements LocationResolver { // insert the root location and we're done baseLocation.insert(0, rootLocation); - 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; + return baseLocation; } }