From 8b8b6376e13e53973b50199b6347bbb30882d20a Mon Sep 17 00:00:00 2001 From: lresende Date: Thu, 9 Apr 2009 06:20:34 +0000 Subject: TUSCANY-2862 - Fixing issues when calculating contribution location and provided composite had spaces git-svn-id: http://svn.us.apache.org/repos/asf/tuscany@763523 13f79535-47bb-0310-9956-ffa450edef68 --- .../java/org/apache/tuscany/sca/node/impl/NodeImpl.java | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) (limited to 'branches/sca-java-1.x/modules/node-impl/src/main/java') diff --git a/branches/sca-java-1.x/modules/node-impl/src/main/java/org/apache/tuscany/sca/node/impl/NodeImpl.java b/branches/sca-java-1.x/modules/node-impl/src/main/java/org/apache/tuscany/sca/node/impl/NodeImpl.java index 4a6ac723c2..b0e5352d51 100644 --- a/branches/sca-java-1.x/modules/node-impl/src/main/java/org/apache/tuscany/sca/node/impl/NodeImpl.java +++ b/branches/sca-java-1.x/modules/node-impl/src/main/java/org/apache/tuscany/sca/node/impl/NodeImpl.java @@ -25,6 +25,7 @@ import java.io.IOException; import java.io.InputStream; import java.net.MalformedURLException; import java.net.URI; +import java.net.URISyntaxException; import java.net.URL; import java.net.URLClassLoader; import java.security.AccessController; @@ -175,7 +176,9 @@ public class NodeImpl implements SCANode, SCAClient { logger.log(Level.INFO, "Creating node: " + configurationName); if (compositeURI != null) { - URI uri = URI.create(compositeURI); + //URI uri = URI.create(compositeURI); + URI uri = createURI(compositeURI); + if (uri.isAbsolute()) { throw new IllegalArgumentException("Composite URI must be a resource name: " + compositeURI); } @@ -264,10 +267,12 @@ public class NodeImpl implements SCANode, SCAClient { try { String url = contributionArtifactURL.toExternalForm(); String protocol = contributionArtifactURL.getProtocol(); + String escapedContributionArtifactPath = new URI(null, contributionArtifactPath, null).toASCIIString(); + if ("file".equals(protocol)) { // directory contribution - if (url.endsWith(contributionArtifactPath)) { - final String location = url.substring(0, url.lastIndexOf(contributionArtifactPath)); + if (url.endsWith(escapedContributionArtifactPath)) { + final String location = url.substring(0, url.lastIndexOf(escapedContributionArtifactPath)); // workaround from evil URL/URI form Maven // contributionURL = FileHelper.toFile(new URL(location)).toURI().toURL(); // Allow privileged access to open URL stream. Add FilePermission to added to @@ -309,6 +314,8 @@ public class NodeImpl implements SCANode, SCAClient { } } catch (MalformedURLException mfe) { throw new IllegalArgumentException(mfe); + } catch (URISyntaxException use) { + throw new IllegalArgumentException(use); } return contributionURL; } -- cgit v1.2.3