You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ofbiz.apache.org by ja...@apache.org on 2007/03/30 04:06:07 UTC
svn commit: r523909 -
/ofbiz/trunk/framework/base/src/base/org/ofbiz/base/location/ComponentLocationResolver.java
Author: jaz
Date: Thu Mar 29 19:06:06 2007
New Revision: 523909
URL: http://svn.apache.org/viewvc?view=rev&rev=523909
Log:
small change to get information from other places
Modified:
ofbiz/trunk/framework/base/src/base/org/ofbiz/base/location/ComponentLocationResolver.java
Modified: ofbiz/trunk/framework/base/src/base/org/ofbiz/base/location/ComponentLocationResolver.java
URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/base/src/base/org/ofbiz/base/location/ComponentLocationResolver.java?view=diff&rev=523909&r1=523908&r2=523909
==============================================================================
--- ofbiz/trunk/framework/base/src/base/org/ofbiz/base/location/ComponentLocationResolver.java (original)
+++ ofbiz/trunk/framework/base/src/base/org/ofbiz/base/location/ComponentLocationResolver.java Thu Mar 29 19:06:06 2007
@@ -35,9 +35,20 @@
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 @@
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 @@
// 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;
}
}