summaryrefslogtreecommitdiffstats
path: root/java
diff options
context:
space:
mode:
Diffstat (limited to 'java')
-rw-r--r--java/sca/modules/contribution/src/main/java/org/apache/tuscany/sca/contribution/processor/impl/ContributionContentProcessor.java30
-rw-r--r--java/sca/modules/contribution/src/main/java/org/apache/tuscany/sca/contribution/scanner/impl/DirectoryContributionScanner.java7
2 files changed, 26 insertions, 11 deletions
diff --git a/java/sca/modules/contribution/src/main/java/org/apache/tuscany/sca/contribution/processor/impl/ContributionContentProcessor.java b/java/sca/modules/contribution/src/main/java/org/apache/tuscany/sca/contribution/processor/impl/ContributionContentProcessor.java
index 046053af54..4e075fea24 100644
--- a/java/sca/modules/contribution/src/main/java/org/apache/tuscany/sca/contribution/processor/impl/ContributionContentProcessor.java
+++ b/java/sca/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,16 +129,12 @@ 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.getFile()).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();
+ }
}
// Scan the contribution and list the artifacts contained in it
diff --git a/java/sca/modules/contribution/src/main/java/org/apache/tuscany/sca/contribution/scanner/impl/DirectoryContributionScanner.java b/java/sca/modules/contribution/src/main/java/org/apache/tuscany/sca/contribution/scanner/impl/DirectoryContributionScanner.java
index 95a4ed69e8..144302c3e4 100644
--- a/java/sca/modules/contribution/src/main/java/org/apache/tuscany/sca/contribution/scanner/impl/DirectoryContributionScanner.java
+++ b/java/sca/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());