summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--branches/sca-java-2.0-M3/modules/contribution/src/main/java/org/apache/tuscany/sca/contribution/processor/impl/ContributionContentProcessor.java27
-rw-r--r--branches/sca-java-2.0-M3/modules/contribution/src/main/java/org/apache/tuscany/sca/contribution/scanner/impl/DirectoryContributionScanner.java7
2 files changed, 25 insertions, 9 deletions
diff --git a/branches/sca-java-2.0-M3/modules/contribution/src/main/java/org/apache/tuscany/sca/contribution/processor/impl/ContributionContentProcessor.java b/branches/sca-java-2.0-M3/modules/contribution/src/main/java/org/apache/tuscany/sca/contribution/processor/impl/ContributionContentProcessor.java
index 5d8b950c45..4e075fea24 100644
--- a/branches/sca-java-2.0-M3/modules/contribution/src/main/java/org/apache/tuscany/sca/contribution/processor/impl/ContributionContentProcessor.java
+++ b/branches/sca-java-2.0-M3/modules/contribution/src/main/java/org/apache/tuscany/sca/contribution/processor/impl/ContributionContentProcessor.java
@@ -102,6 +102,20 @@ public class ContributionContentProcessor implements ExtendedURLArtifactProcesso
return Contribution.class;
}
+ private File toFile(URL url) {
+ if("file".equalsIgnoreCase(url.getProtocol())) {
+ try {
+ return new File(url.toURI());
+ } catch(URISyntaxException e) {
+ return new File(url.getPath());
+ } catch(IllegalArgumentException e) {
+ // Hack for file:./a.txt or file:../a/c.wsdl
+ return new File(url.getPath());
+ }
+ }
+ return null;
+ }
+
public Contribution read(URL parentURL, URI contributionURI, URL contributionURL) throws ContributionReadException {
// Create contribution model
@@ -115,14 +129,11 @@ public class ContributionContentProcessor implements ExtendedURLArtifactProcesso
// Create a contribution scanner
ContributionScanner scanner = scanners.getContributionScanner(contributionURL.getProtocol());
if (scanner == null) {
- try {
- if ("file".equals(contributionURL.getProtocol()) && new File(contributionURL.toURI().getPath()).isDirectory()) {
- scanner = new DirectoryContributionScanner();
- } else {
- scanner = new JarContributionScanner();
- }
- } catch (URISyntaxException e) {
- throw new ContributionReadException(e);
+ File file = toFile(contributionURL);
+ if (file != null && file.isDirectory()) {
+ scanner = new DirectoryContributionScanner();
+ } else {
+ scanner = new JarContributionScanner();
}
}
diff --git a/branches/sca-java-2.0-M3/modules/contribution/src/main/java/org/apache/tuscany/sca/contribution/scanner/impl/DirectoryContributionScanner.java b/branches/sca-java-2.0-M3/modules/contribution/src/main/java/org/apache/tuscany/sca/contribution/scanner/impl/DirectoryContributionScanner.java
index 95a4ed69e8..144302c3e4 100644
--- a/branches/sca-java-2.0-M3/modules/contribution/src/main/java/org/apache/tuscany/sca/contribution/scanner/impl/DirectoryContributionScanner.java
+++ b/branches/sca-java-2.0-M3/modules/contribution/src/main/java/org/apache/tuscany/sca/contribution/scanner/impl/DirectoryContributionScanner.java
@@ -98,10 +98,15 @@ public class DirectoryContributionScanner implements ContributionScanner {
private static File directory(Contribution contribution) throws ContributionReadException {
File file;
+ URI uri = null;
try {
- file = new File(new URI(contribution.getLocation()));
+ uri = new URI(contribution.getLocation());
+ file = new File(uri);
} catch (URISyntaxException e) {
throw new ContributionReadException(e);
+ } catch(IllegalArgumentException e) {
+ // Hack for file:./a.txt or file:../a/c.wsdl
+ return new File(uri.getPath());
}
if (!file.exists() || !file.isDirectory()) {
throw new ContributionReadException(contribution.getLocation());