summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorrfeng <rfeng@13f79535-47bb-0310-9956-ffa450edef68>2009-02-19 06:34:03 +0000
committerrfeng <rfeng@13f79535-47bb-0310-9956-ffa450edef68>2009-02-19 06:34:03 +0000
commitfa9b36803f44b85576b05d708b68277342d22629 (patch)
treebb77df1f6a988dc2ac4be4ee3fbacca84897b847
parentac09f26b6e318b5ad422806bc9e6e2d67fdf1a57 (diff)
Fix for TUSCANY-2702
git-svn-id: http://svn.us.apache.org/repos/asf/tuscany@745752 13f79535-47bb-0310-9956-ffa450edef68
-rw-r--r--branches/sca-java-1.x/modules/contribution-impl/src/main/java/org/apache/tuscany/sca/contribution/service/impl/ContributionServiceImpl.java47
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 {