diff options
author | rfeng <rfeng@13f79535-47bb-0310-9956-ffa450edef68> | 2009-02-19 06:34:03 +0000 |
---|---|---|
committer | rfeng <rfeng@13f79535-47bb-0310-9956-ffa450edef68> | 2009-02-19 06:34:03 +0000 |
commit | fa9b36803f44b85576b05d708b68277342d22629 (patch) | |
tree | bb77df1f6a988dc2ac4be4ee3fbacca84897b847 /branches/sca-java-1.x/modules/contribution-impl/src/main | |
parent | ac09f26b6e318b5ad422806bc9e6e2d67fdf1a57 (diff) |
Fix for TUSCANY-2702
git-svn-id: http://svn.us.apache.org/repos/asf/tuscany@745752 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'branches/sca-java-1.x/modules/contribution-impl/src/main')
-rw-r--r-- | branches/sca-java-1.x/modules/contribution-impl/src/main/java/org/apache/tuscany/sca/contribution/service/impl/ContributionServiceImpl.java | 47 |
1 files changed, 35 insertions, 12 deletions
diff --git a/branches/sca-java-1.x/modules/contribution-impl/src/main/java/org/apache/tuscany/sca/contribution/service/impl/ContributionServiceImpl.java b/branches/sca-java-1.x/modules/contribution-impl/src/main/java/org/apache/tuscany/sca/contribution/service/impl/ContributionServiceImpl.java index 6471042fed..1c4d8e8547 100644 --- a/branches/sca-java-1.x/modules/contribution-impl/src/main/java/org/apache/tuscany/sca/contribution/service/impl/ContributionServiceImpl.java +++ b/branches/sca-java-1.x/modules/contribution-impl/src/main/java/org/apache/tuscany/sca/contribution/service/impl/ContributionServiceImpl.java @@ -18,10 +18,12 @@ */ package org.apache.tuscany.sca.contribution.service.impl; +import java.io.File; 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.net.URLConnection; @@ -304,6 +306,22 @@ public class ContributionServiceImpl implements ContributionService { return contributionMetadata; } + + private static boolean isDirectory(URL url) { + if ("file".equals(url.getProtocol())) { + try { + final URI uri = url.toURI(); + return AccessController.doPrivileged(new PrivilegedAction<Boolean>() { + public Boolean run() { + return new File(uri).isDirectory(); + } + }); + } catch (URISyntaxException e) { + // Ignore + } + } + return false; + } /** * Note: @@ -358,18 +376,23 @@ public class ContributionServiceImpl implements ContributionService { //NOTE: if a contribution is stored on the repository //the stream would be consumed at this point if (storeInRepository || contributionStream == null) { - URLConnection connection = sourceURL.openConnection(); - connection.setUseCaches(false); - // Allow access to open URL stream. Add FilePermission to added to security policy file. - final URLConnection finalConnection = connection; - try { - contributionStream = AccessController.doPrivileged(new PrivilegedExceptionAction<InputStream>() { - public InputStream run() throws IOException { - return finalConnection.getInputStream(); - } - }); - } catch (PrivilegedActionException e) { - throw (IOException)e.getException(); + if (isDirectory(sourceURL)) { + // TUSCANY-2702: This is a directory + contributionStream = null; + } else { + URLConnection connection = sourceURL.openConnection(); + connection.setUseCaches(false); + // Allow access to open URL stream. Add FilePermission to added to security policy file. + final URLConnection finalConnection = connection; + try { + contributionStream = AccessController.doPrivileged(new PrivilegedExceptionAction<InputStream>() { + public InputStream run() throws IOException { + return finalConnection.getInputStream(); + } + }); + } catch (PrivilegedActionException e) { + throw (IOException)e.getException(); + } } try { |