You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@uima.apache.org by al...@apache.org on 2007/03/16 23:17:40 UTC
svn commit: r519162 -
/incubator/uima/uimaj/trunk/uimaj-cpe/src/main/java/org/apache/uima/collection/impl/metadata/cpe/CpeComponentDescriptorImpl.java
Author: alally
Date: Fri Mar 16 15:17:40 2007
New Revision: 519162
URL: http://svn.apache.org/viewvc?view=rev&rev=519162
Log:
Better fix for problem with URLs in CPE descriptor <include> elements,
apparently introduced in adding support for imports.
UIMA-343: https://issues.apache.org/jira/browse/UIMA-343
Modified:
incubator/uima/uimaj/trunk/uimaj-cpe/src/main/java/org/apache/uima/collection/impl/metadata/cpe/CpeComponentDescriptorImpl.java
Modified: incubator/uima/uimaj/trunk/uimaj-cpe/src/main/java/org/apache/uima/collection/impl/metadata/cpe/CpeComponentDescriptorImpl.java
URL: http://svn.apache.org/viewvc/incubator/uima/uimaj/trunk/uimaj-cpe/src/main/java/org/apache/uima/collection/impl/metadata/cpe/CpeComponentDescriptorImpl.java?view=diff&rev=519162&r1=519161&r2=519162
==============================================================================
--- incubator/uima/uimaj/trunk/uimaj-cpe/src/main/java/org/apache/uima/collection/impl/metadata/cpe/CpeComponentDescriptorImpl.java (original)
+++ incubator/uima/uimaj/trunk/uimaj-cpe/src/main/java/org/apache/uima/collection/impl/metadata/cpe/CpeComponentDescriptorImpl.java Fri Mar 16 15:17:40 2007
@@ -87,21 +87,25 @@
return mImport.findAbsoluteUrl(aResourceManager);
}
else {
- String relPath = mInclude.get();
+ String path = mInclude.get();
//replace ${CPM_HOME}
- if (relPath.startsWith("${CPM_HOME}")) {
+ if (path.startsWith("${CPM_HOME}")) {
String cpmHome = System.getProperty("CPM_HOME");
- relPath = cpmHome + relPath.substring("${CPM_HOME}".length());
+ path = cpmHome + path.substring("${CPM_HOME}".length());
}
try {
- //TODO: fix this logic
- if (relPath.startsWith("file:")) {
- return new URL(relPath);
- }
- return new File(relPath).getAbsoluteFile().toURI().toURL();
+ //try path as a URL, then if that fails try it as a File
+ //TODO: is there a good way to tell if it's a valid URL without
+ //having to catch MalformedURLException?
+ return new URL(path);
} catch (MalformedURLException e) {
- throw new InvalidXMLException(InvalidXMLException.MALFORMED_IMPORT_URL, new Object[] {
- relPath, getSourceUrlString() }, e);
+ try {
+ return new File(path).getAbsoluteFile().toURI().toURL();
+ }
+ catch(MalformedURLException e2) {
+ throw new InvalidXMLException(InvalidXMLException.MALFORMED_IMPORT_URL, new Object[] {
+ path, getSourceUrlString() }, e);
+ }
}
}
} catch (InvalidXMLException e) {