ant-notifications mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From hi...@apache.org
Subject svn commit: r1165100 [1/4] - in /ant/ivy/core/trunk: src/java/org/apache/ivy/ant/ src/java/org/apache/ivy/osgi/core/ src/java/org/apache/ivy/osgi/obr/ src/java/org/apache/ivy/osgi/obr/xml/ src/java/org/apache/ivy/osgi/p2/ src/java/org/apache/ivy/osgi/r...
Date Sun, 04 Sep 2011 19:37:05 GMT
Author: hibou
Date: Sun Sep  4 19:37:03 2011
New Revision: 1165100

URL: http://svn.apache.org/viewvc?rev=1165100&view=rev
Log:
- add some tests on the updatesite resolver
- fix the way artifact location is handled so at the end we have a proper URL

Added:
    ant/ivy/core/trunk/test/java/org/apache/ivy/osgi/updatesite/UpdateSiteResolverTest.java   (with props)
    ant/ivy/core/trunk/test/test-p2/
    ant/ivy/core/trunk/test/test-p2/ivyde-repo/
    ant/ivy/core/trunk/test/test-p2/ivyde-repo/artifacts.xml   (with props)
    ant/ivy/core/trunk/test/test-p2/ivyde-repo/content.xml   (with props)
    ant/ivy/core/trunk/test/test-p2/ivyde-repo/features/
    ant/ivy/core/trunk/test/test-p2/ivyde-repo/features/org.apache.ivy.feature_2.0.0.final_20090108225011.jar
    ant/ivy/core/trunk/test/test-p2/ivyde-repo/features/org.apache.ivy.feature_2.1.0.final_20090925235825.jar
    ant/ivy/core/trunk/test/test-p2/ivyde-repo/features/org.apache.ivy.feature_2.2.0.final_20100923230623.jar
    ant/ivy/core/trunk/test/test-p2/ivyde-repo/features/org.apache.ivyde.feature_2.0.0.final-200907011148-RELEASE.jar
    ant/ivy/core/trunk/test/test-p2/ivyde-repo/features/org.apache.ivyde.feature_2.1.0.201008101807-RELEASE.jar
    ant/ivy/core/trunk/test/test-p2/ivyde-repo/plugins/
    ant/ivy/core/trunk/test/test-p2/ivyde-repo/plugins/org.apache.ivy.eclipse.ant_2.0.0.final_20090108225011.jar
    ant/ivy/core/trunk/test/test-p2/ivyde-repo/plugins/org.apache.ivy.eclipse.ant_2.1.0.final_20090925235825.jar
    ant/ivy/core/trunk/test/test-p2/ivyde-repo/plugins/org.apache.ivy.eclipse.ant_2.2.0.final_20100923230623.jar
    ant/ivy/core/trunk/test/test-p2/ivyde-repo/plugins/org.apache.ivy_2.0.0.final_20090108225011.jar
    ant/ivy/core/trunk/test/test-p2/ivyde-repo/plugins/org.apache.ivy_2.1.0.final_20090925235825.jar
    ant/ivy/core/trunk/test/test-p2/ivyde-repo/plugins/org.apache.ivy_2.2.0.final_20100923230623.jar
    ant/ivy/core/trunk/test/test-p2/ivyde-repo/plugins/org.apache.ivyde.eclipse_2.0.0.final-200907011148-RELEASE.jar
    ant/ivy/core/trunk/test/test-p2/ivyde-repo/plugins/org.apache.ivyde.eclipse_2.1.0.201008101807-RELEASE.jar
Modified:
    ant/ivy/core/trunk/src/java/org/apache/ivy/ant/ConvertManifestTask.java
    ant/ivy/core/trunk/src/java/org/apache/ivy/osgi/core/BundleInfo.java
    ant/ivy/core/trunk/src/java/org/apache/ivy/osgi/core/BundleInfoAdapter.java
    ant/ivy/core/trunk/src/java/org/apache/ivy/osgi/core/OSGiManifestParser.java
    ant/ivy/core/trunk/src/java/org/apache/ivy/osgi/obr/OBRResolver.java
    ant/ivy/core/trunk/src/java/org/apache/ivy/osgi/obr/xml/OBRXMLParser.java
    ant/ivy/core/trunk/src/java/org/apache/ivy/osgi/obr/xml/OBRXMLWriter.java
    ant/ivy/core/trunk/src/java/org/apache/ivy/osgi/p2/P2Descriptor.java
    ant/ivy/core/trunk/src/java/org/apache/ivy/osgi/p2/P2MetadataParser.java
    ant/ivy/core/trunk/src/java/org/apache/ivy/osgi/repo/AbstractFSManifestIterable.java
    ant/ivy/core/trunk/src/java/org/apache/ivy/osgi/repo/BundleRepoDescriptor.java
    ant/ivy/core/trunk/src/java/org/apache/ivy/osgi/repo/FSManifestIterable.java
    ant/ivy/core/trunk/src/java/org/apache/ivy/osgi/repo/ManifestAndLocation.java
    ant/ivy/core/trunk/src/java/org/apache/ivy/osgi/repo/RepoDescriptor.java
    ant/ivy/core/trunk/src/java/org/apache/ivy/osgi/repo/RepoDescriptorBasedResolver.java
    ant/ivy/core/trunk/src/java/org/apache/ivy/osgi/repo/RepositoryManifestIterable.java
    ant/ivy/core/trunk/src/java/org/apache/ivy/osgi/repo/ResolverManifestIterable.java
    ant/ivy/core/trunk/src/java/org/apache/ivy/osgi/updatesite/PluginAdapter.java
    ant/ivy/core/trunk/src/java/org/apache/ivy/osgi/updatesite/UpdateSiteDescriptor.java
    ant/ivy/core/trunk/src/java/org/apache/ivy/osgi/updatesite/UpdateSiteLoader.java
    ant/ivy/core/trunk/src/java/org/apache/ivy/osgi/updatesite/UpdateSiteResolver.java
    ant/ivy/core/trunk/src/java/org/apache/ivy/osgi/updatesite/xml/EclipseUpdateSiteParser.java
    ant/ivy/core/trunk/src/java/org/apache/ivy/osgi/updatesite/xml/UpdateSite.java
    ant/ivy/core/trunk/src/java/org/apache/ivy/osgi/updatesite/xml/UpdateSiteDigestParser.java
    ant/ivy/core/trunk/src/java/org/apache/ivy/osgi/util/DelegetingHandler.java
    ant/ivy/core/trunk/test/java/org/apache/ivy/osgi/obr/OBRParserTest.java
    ant/ivy/core/trunk/test/java/org/apache/ivy/osgi/obr/OBRResolverTest.java
    ant/ivy/core/trunk/test/java/org/apache/ivy/osgi/repo/BundleRepoTest.java
    ant/ivy/core/trunk/test/java/org/apache/ivy/osgi/updatesite/UpdateSiteLoaderTest.java
    ant/ivy/core/trunk/test/test-repo/ivyrepo/repo.xml

Modified: ant/ivy/core/trunk/src/java/org/apache/ivy/ant/ConvertManifestTask.java
URL: http://svn.apache.org/viewvc/ant/ivy/core/trunk/src/java/org/apache/ivy/ant/ConvertManifestTask.java?rev=1165100&r1=1165099&r2=1165100&view=diff
==============================================================================
--- ant/ivy/core/trunk/src/java/org/apache/ivy/ant/ConvertManifestTask.java (original)
+++ ant/ivy/core/trunk/src/java/org/apache/ivy/ant/ConvertManifestTask.java Sun Sep  4 19:37:03 2011
@@ -83,7 +83,7 @@ public class ConvertManifestTask extends
         } catch (ParseException e) {
             throw new BuildException("Incorrect manifest file '" + manifest + "'", e);
         }
-        ModuleDescriptor md = BundleInfoAdapter.toModuleDescriptor(bundleInfo, profileProvider);
+        ModuleDescriptor md = BundleInfoAdapter.toModuleDescriptor(null, bundleInfo, profileProvider);
 
         try {
             XmlModuleDescriptorWriter.write(md, ivyFile);

Modified: ant/ivy/core/trunk/src/java/org/apache/ivy/osgi/core/BundleInfo.java
URL: http://svn.apache.org/viewvc/ant/ivy/core/trunk/src/java/org/apache/ivy/osgi/core/BundleInfo.java?rev=1165100&r1=1165099&r2=1165100&view=diff
==============================================================================
--- ant/ivy/core/trunk/src/java/org/apache/ivy/osgi/core/BundleInfo.java (original)
+++ ant/ivy/core/trunk/src/java/org/apache/ivy/osgi/core/BundleInfo.java Sun Sep  4 19:37:03 2011
@@ -17,6 +17,7 @@
  */
 package org.apache.ivy.osgi.core;
 
+import java.net.URI;
 import java.util.Collections;
 import java.util.Iterator;
 import java.util.LinkedHashSet;
@@ -61,7 +62,7 @@ public class BundleInfo {
 
     private Integer size;
 
-    private String uri;
+    private URI uri;
 
     public BundleInfo(String name, Version version) {
         this.symbolicName = name;
@@ -96,11 +97,11 @@ public class BundleInfo {
         return version;
     }
 
-    public void setUri(String uri) {
+    public void setUri(URI uri) {
         this.uri = uri;
     }
 
-    public String getUri() {
+    public URI getUri() {
         return uri;
     }
 

Modified: ant/ivy/core/trunk/src/java/org/apache/ivy/osgi/core/BundleInfoAdapter.java
URL: http://svn.apache.org/viewvc/ant/ivy/core/trunk/src/java/org/apache/ivy/osgi/core/BundleInfoAdapter.java?rev=1165100&r1=1165099&r2=1165100&view=diff
==============================================================================
--- ant/ivy/core/trunk/src/java/org/apache/ivy/osgi/core/BundleInfoAdapter.java (original)
+++ ant/ivy/core/trunk/src/java/org/apache/ivy/osgi/core/BundleInfoAdapter.java Sun Sep  4 19:37:03 2011
@@ -18,11 +18,15 @@
 package org.apache.ivy.osgi.core;
 
 import java.net.MalformedURLException;
+import java.net.URI;
+import java.net.URISyntaxException;
 import java.net.URL;
+import java.util.ArrayList;
 import java.util.Collections;
 import java.util.Date;
 import java.util.HashSet;
 import java.util.Iterator;
+import java.util.List;
 import java.util.Map;
 import java.util.Set;
 
@@ -41,8 +45,6 @@ import org.apache.ivy.osgi.util.Version;
 import org.apache.ivy.osgi.util.VersionRange;
 import org.apache.ivy.plugins.matcher.ExactOrRegexpPatternMatcher;
 import org.apache.ivy.plugins.matcher.PatternMatcher;
-import org.apache.ivy.util.Message;
-import org.apache.ivy.util.StringUtils;
 
 public class BundleInfoAdapter {
 
@@ -75,7 +77,16 @@ public class BundleInfoAdapter {
     public static final Map/* <String, String> */OSGI_SERVICE = Collections.singletonMap(
         EXTRA_ATTRIBUTE_NAME, BundleInfo.SERVICE_TYPE);
 
-    public static DefaultModuleDescriptor toModuleDescriptor(BundleInfo bundle,
+    /**
+     * 
+     * @param baseUri
+     *            uri to help build the absolute url if the bundle info has a relative uri.
+     * @param bundle
+     * @param profileProvider
+     * @return
+     * @throws ProfileNotFoundException
+     */
+    public static DefaultModuleDescriptor toModuleDescriptor(URI baseUri, BundleInfo bundle,
             ExecutionEnvironmentProfileProvider profileProvider) throws ProfileNotFoundException {
         DefaultModuleDescriptor md = new DefaultModuleDescriptor(null, null);
         md.addExtraAttributeNamespace("o", Ivy.getIvyHomeURL() + "osgi");
@@ -107,22 +118,20 @@ public class BundleInfoAdapter {
 
         requirementAsDependency(md, bundle, exportedPkgNames);
 
-        if (bundle.getUri() != null) {
+        URI uri = bundle.getUri();
+        if (uri != null) {
             DefaultArtifact artifact = null;
-            String uri = bundle.getUri();
-            if (uri.startsWith("ivy://")) {
-                artifact = decodeIvyLocation(uri);
+            if ("ivy".equals(uri.getScheme())) {
+                artifact = decodeIvyURI(uri);
             } else {
-                URL url = null;
-                try {
-                    url = new URL("file:" + uri);
-                } catch (MalformedURLException e) {
-                    Message.error("BUG IN BUSHEL, please report: " + e.getMessage() + "\n"
-                            + StringUtils.getStackTrace(e));
+                if (!uri.isAbsolute()) {
+                    uri = baseUri.resolve(uri);
                 }
-                if (url != null) {
+                try {
                     artifact = new DefaultArtifact(mrid, null, bundle.getSymbolicName(), "jar",
-                            "jar", url, null);
+                            "jar", new URL(uri.toString()), null);
+                } catch (MalformedURLException e) {
+                    throw new RuntimeException("Unable to make the uri into the url", e);
                 }
             }
             if (artifact != null) {
@@ -159,16 +168,31 @@ public class BundleInfoAdapter {
         return md;
     }
 
-    public static String encodeIvyLocation(Artifact artifact) {
+    public static List/*<String>*/ getConfigurations(BundleInfo bundle) {
+        List/*<String>*/ confs = new ArrayList();
+        confs.add(CONF_DEFAULT);
+        confs.add(CONF_OPTIONAL);
+        confs.add(CONF_TRANSITIVE_OPTIONAL);
+
+        Iterator itExport = bundle.getExports().iterator();
+        while (itExport.hasNext()) {
+            ExportPackage exportPackage = (ExportPackage) itExport.next();
+            confs.add(CONF_USE_PREFIX + exportPackage.getName());
+        }
+
+        return confs;
+    }
+
+    public static URI buildIvyURI(Artifact artifact) {
         ModuleRevisionId mrid = artifact.getModuleRevisionId();
-        return encodeIvyLocation(mrid.getOrganisation(), mrid.getName(), mrid.getBranch(),
+        return asIvyURI(mrid.getOrganisation(), mrid.getName(), mrid.getBranch(),
             mrid.getRevision(), artifact.getType(), artifact.getName(), artifact.getExt());
     }
 
-    private static String encodeIvyLocation(String org, String name, String branch, String rev,
-            String type, String art, String ext) {
+    private static URI asIvyURI(String org, String name, String branch, String rev, String type,
+            String art, String ext) {
         StringBuffer builder = new StringBuffer();
-        builder.append("ivy://");
+        builder.append("ivy:///");
         builder.append(org);
         builder.append('/');
         builder.append(name);
@@ -193,10 +217,14 @@ public class BundleInfoAdapter {
             builder.append("&ext=");
             builder.append(ext);
         }
-        return builder.toString();
+        try {
+            return new URI(builder.toString());
+        } catch (URISyntaxException e) {
+            throw new RuntimeException("illformed ivy url", e);
+        }
     }
 
-    private static DefaultArtifact decodeIvyLocation(final String uri) {
+    private static DefaultArtifact decodeIvyURI(final URI uri) {
         String org = null;
         String name = null;
         String branch = null;
@@ -205,22 +233,19 @@ public class BundleInfoAdapter {
         String type = null;
         String ext = null;
 
-        String u = uri.substring(6);
-        int i = u.indexOf('/');
-        if (i < 0) {
-            throw new IllegalArgumentException("Expecting an organisation in the ivy uri: " + uri);
+        String path = uri.getPath();
+        if (!path.startsWith("/")) {
+            throw new IllegalArgumentException("An ivy url should be of the form ivy:///org/module but was : " + uri);
         }
-        org = u.substring(0, i);
-        u = u.substring(i + 1);
-
-        i = u.indexOf('?');
+        int i = path.indexOf('/', 1);
         if (i < 0) {
-            throw new IllegalArgumentException("Expecting an module name in the ivy uri: " + uri);
+            throw new IllegalArgumentException("Expecting an organisation in the ivy url: " + uri);
         }
-        name = u.substring(0, i);
-        u = u.substring(i + 1);
+        org = path.substring(1, i);
+        name = path.substring(i + 1);
 
-        String[] parameters = u.split("&");
+        String query = uri.getQuery();
+        String[] parameters = query.split("&");
         for (int j = 0; j < parameters.length; j++) {
             String parameter = parameters[j];
             if (parameter.length() == 0) {
@@ -228,7 +253,7 @@ public class BundleInfoAdapter {
             }
             String[] nameAndValue = parameter.split("=");
             if (nameAndValue.length != 2) {
-                throw new IllegalArgumentException("Malformed query string in the ivy uri: " + uri);
+                throw new IllegalArgumentException("Malformed query string in the ivy url: " + uri);
             } else if (nameAndValue[0].equals("branch")) {
                 branch = nameAndValue[1];
             } else if (nameAndValue[0].equals("rev")) {
@@ -241,7 +266,7 @@ public class BundleInfoAdapter {
                 ext = nameAndValue[1];
             } else {
                 throw new IllegalArgumentException("Unrecognized parameter '" + nameAndValue[0]
-                        + " in the query string of the ivy uri: " + uri);
+                        + " in the query string of the ivy url: " + uri);
             }
         }
 

Modified: ant/ivy/core/trunk/src/java/org/apache/ivy/osgi/core/OSGiManifestParser.java
URL: http://svn.apache.org/viewvc/ant/ivy/core/trunk/src/java/org/apache/ivy/osgi/core/OSGiManifestParser.java?rev=1165100&r1=1165099&r2=1165100&view=diff
==============================================================================
--- ant/ivy/core/trunk/src/java/org/apache/ivy/osgi/core/OSGiManifestParser.java (original)
+++ ant/ivy/core/trunk/src/java/org/apache/ivy/osgi/core/OSGiManifestParser.java Sun Sep  4 19:37:03 2011
@@ -20,6 +20,8 @@ package org.apache.ivy.osgi.core;
 import java.io.File;
 import java.io.IOException;
 import java.io.InputStream;
+import java.net.URI;
+import java.net.URISyntaxException;
 import java.net.URL;
 import java.text.ParseException;
 import java.util.Date;
@@ -61,7 +63,12 @@ public class OSGiManifestParser implemen
             Resource res, boolean validate) throws ParseException, IOException {
         Manifest m = new Manifest(res.openStream());
         BundleInfo bundleInfo = ManifestParser.parseManifest(m);
-        return BundleInfoAdapter.toModuleDescriptor(bundleInfo, profileProvider);
+        try {
+            bundleInfo.setUri(new URI(res.getName()));
+        } catch (URISyntaxException e) {
+            throw new RuntimeException("Unsupported repository, resources names are not uris", e);
+        }
+        return BundleInfoAdapter.toModuleDescriptor(null, bundleInfo, profileProvider);
     }
 
     public void toIvyFile(InputStream is, Resource res, File destFile, ModuleDescriptor md)

Modified: ant/ivy/core/trunk/src/java/org/apache/ivy/osgi/obr/OBRResolver.java
URL: http://svn.apache.org/viewvc/ant/ivy/core/trunk/src/java/org/apache/ivy/osgi/obr/OBRResolver.java?rev=1165100&r1=1165099&r2=1165100&view=diff
==============================================================================
--- ant/ivy/core/trunk/src/java/org/apache/ivy/osgi/obr/OBRResolver.java (original)
+++ ant/ivy/core/trunk/src/java/org/apache/ivy/osgi/obr/OBRResolver.java Sun Sep  4 19:37:03 2011
@@ -22,6 +22,8 @@ import java.io.FileInputStream;
 import java.io.FileNotFoundException;
 import java.io.IOException;
 import java.net.MalformedURLException;
+import java.net.URI;
+import java.net.URISyntaxException;
 import java.net.URL;
 import java.text.ParseException;
 
@@ -29,10 +31,8 @@ import org.apache.ivy.core.cache.CacheRe
 import org.apache.ivy.core.event.EventManager;
 import org.apache.ivy.core.report.ArtifactDownloadReport;
 import org.apache.ivy.osgi.obr.xml.OBRXMLParser;
-import org.apache.ivy.osgi.repo.RelativeURLRepository;
 import org.apache.ivy.osgi.repo.RepoDescriptorBasedResolver;
 import org.apache.ivy.plugins.repository.Resource;
-import org.apache.ivy.plugins.repository.file.FileRepository;
 import org.apache.ivy.plugins.repository.url.URLResource;
 import org.xml.sax.SAXException;
 
@@ -69,8 +69,7 @@ public class OBRResolver extends RepoDes
         }
         if (repoXmlFile != null) {
             File f = new File(repoXmlFile);
-            setRepository(new FileRepository(f.getParentFile()));
-            loadRepoFromFile(f, repoXmlFile);
+            loadRepoFromFile(f.getParentFile().toURI(), f, repoXmlFile);
         } else if (repoXmlURL != null) {
             final URL url;
             try {
@@ -80,25 +79,6 @@ public class OBRResolver extends RepoDes
                         + " couldn't be configured: repoXmlURL '" + repoXmlURL + "' is not an URL");
             }
 
-            // compute the base URL
-            URL baseUrl;
-            String basePath = "/";
-            int i = url.getPath().lastIndexOf("/");
-            if (i > 0) {
-                basePath = url.getPath().substring(0, i + 1);
-            }
-            try {
-                baseUrl = new URL(url.getProtocol(), url.getHost(), url.getPort(), basePath);
-            } catch (MalformedURLException e) {
-                throw new RuntimeException(
-                        "The OBR repository resolver "
-                                + getName()
-                                + " couldn't be configured: the base url couldn'd be extracted from the url "
-                                + url + " (" + e.getMessage() + ")");
-            }
-            RelativeURLRepository repo = new RelativeURLRepository(baseUrl);
-            setRepository(repo);
-
             ArtifactDownloadReport report;
             EventManager eventManager = getEventManager();
             try {
@@ -114,14 +94,20 @@ public class OBRResolver extends RepoDes
                     options.setForce(forceMetadataUpdate.booleanValue());
                 }
                 report = getRepositoryCacheManager().downloadRepositoryResource(obrResource, "obr",
-                    "obr", "xml", options, repo);
+                    "obr", "xml", options, getRepository());
             } finally {
                 if (eventManager != null) {
                     getRepository().removeTransferListener(eventManager);
                 }
             }
 
-            loadRepoFromFile(report.getLocalFile(), repoXmlURL);
+            URI baseURI;
+            try {
+                baseURI = new URI(repoXmlURL);
+            } catch (URISyntaxException e) {
+                throw new RuntimeException("illegal uri");
+            }
+            loadRepoFromFile(baseURI, report.getLocalFile(), repoXmlURL);
 
         } else {
             throw new RuntimeException("The OBR repository resolver " + getName()
@@ -129,7 +115,7 @@ public class OBRResolver extends RepoDes
         }
     }
 
-    private void loadRepoFromFile(File repoFile, String sourceLocation) {
+    private void loadRepoFromFile(URI baseUri, File repoFile, String sourceLocation) {
         FileInputStream in;
         try {
             in = new FileInputStream(repoFile);
@@ -138,7 +124,7 @@ public class OBRResolver extends RepoDes
                     + " couldn't be configured: the file " + sourceLocation + " was not found");
         }
         try {
-            setRepoDescriptor(OBRXMLParser.parse(in));
+            setRepoDescriptor(OBRXMLParser.parse(baseUri, in));
         } catch (ParseException e) {
             throw new RuntimeException("The OBR repository resolver " + getName()
                     + " couldn't be configured: the file " + sourceLocation

Modified: ant/ivy/core/trunk/src/java/org/apache/ivy/osgi/obr/xml/OBRXMLParser.java
URL: http://svn.apache.org/viewvc/ant/ivy/core/trunk/src/java/org/apache/ivy/osgi/obr/xml/OBRXMLParser.java?rev=1165100&r1=1165099&r2=1165100&view=diff
==============================================================================
--- ant/ivy/core/trunk/src/java/org/apache/ivy/osgi/obr/xml/OBRXMLParser.java (original)
+++ ant/ivy/core/trunk/src/java/org/apache/ivy/osgi/obr/xml/OBRXMLParser.java Sun Sep  4 19:37:03 2011
@@ -19,6 +19,8 @@ package org.apache.ivy.osgi.obr.xml;
 
 import java.io.IOException;
 import java.io.InputStream;
+import java.net.URI;
+import java.net.URISyntaxException;
 import java.text.ParseException;
 
 import javax.xml.parsers.ParserConfigurationException;
@@ -37,9 +39,9 @@ import org.xml.sax.SAXParseException;
 
 public class OBRXMLParser {
 
-    public static BundleRepoDescriptor parse(InputStream in) throws ParseException, IOException,
-            SAXException {
-        RepositoryHandler handler = new RepositoryHandler();
+    public static BundleRepoDescriptor parse(URI baseUri, InputStream in) throws ParseException,
+            IOException, SAXException {
+        RepositoryHandler handler = new RepositoryHandler(baseUri);
         try {
             XMLHelper.parse(in, null, handler, null);
         } catch (ParserConfigurationException e) {
@@ -58,8 +60,11 @@ public class OBRXMLParser {
 
         BundleRepoDescriptor repo;
 
-        public RepositoryHandler() {
+        private final URI baseUri;
+
+        public RepositoryHandler(URI baseUri) {
             super(REPOSITORY);
+            this.baseUri = baseUri;
             addChild(new ResourceHandler(), new ChildElementHandler() {
                 public void childHanlded(DelegetingHandler child) {
                     repo.addBundle(((ResourceHandler) child).bundleInfo);
@@ -68,7 +73,8 @@ public class OBRXMLParser {
         }
 
         protected void handleAttributes(Attributes atts) {
-            repo = new BundleRepoDescriptor(ExecutionEnvironmentProfileProvider.getInstance());
+            repo = new BundleRepoDescriptor(baseUri,
+                    ExecutionEnvironmentProfileProvider.getInstance());
 
             repo.setName(atts.getValue(NAME));
 
@@ -128,7 +134,7 @@ public class OBRXMLParser {
                         bundleInfo.setSize(Integer.valueOf(size));
                     } catch (NumberFormatException e) {
                         log(Message.MSG_WARN,
-                            "Invalid size for the bundle" + bundleInfo.getSymbolicName() + ": "
+                            "Invalid size for the bundle " + bundleInfo.getSymbolicName() + ": "
                                     + size + ". This size is then ignored.");
                     }
                 }
@@ -182,7 +188,17 @@ public class OBRXMLParser {
 
             bundleInfo = new BundleInfo(symbolicname, version);
             bundleInfo.setPresentationName(atts.getValue(PRESENTATION_NAME));
-            bundleInfo.setUri(atts.getValue(URI));
+            String uri = atts.getValue(URI);
+            if (uri != null) {
+                try {
+                    bundleInfo.setUri(new URI(uri));
+                } catch (URISyntaxException e) {
+                    log(Message.MSG_ERR, "Incorrect uri " + uri + ". The resource " + symbolicname
+                            + " is then ignored.");
+                    skip();
+                    return;
+                }
+            }
             bundleInfo.setId(atts.getValue(ID));
         }
 

Modified: ant/ivy/core/trunk/src/java/org/apache/ivy/osgi/obr/xml/OBRXMLWriter.java
URL: http://svn.apache.org/viewvc/ant/ivy/core/trunk/src/java/org/apache/ivy/osgi/obr/xml/OBRXMLWriter.java?rev=1165100&r1=1165099&r2=1165100&view=diff
==============================================================================
--- ant/ivy/core/trunk/src/java/org/apache/ivy/osgi/obr/xml/OBRXMLWriter.java (original)
+++ ant/ivy/core/trunk/src/java/org/apache/ivy/osgi/obr/xml/OBRXMLWriter.java Sun Sep  4 19:37:03 2011
@@ -75,15 +75,14 @@ public class OBRXMLWriter {
             BundleInfo bundleInfo;
             try {
                 bundleInfo = ManifestParser.parseManifest(manifestAndLocation.getManifest());
-                bundleInfo.setUri(manifestAndLocation.getLocation());
+                bundleInfo.setUri(manifestAndLocation.getUri());
                 nbOk++;
             } catch (ParseException e) {
                 nbRejected++;
                 IvyContext
                         .getContext()
                         .getMessageLogger()
-                        .log(
-                            "Rejected " + manifestAndLocation.getLocation() + ": " + e.getMessage(),
+                        .log("Rejected " + manifestAndLocation.getUri() + ": " + e.getMessage(),
                             level);
                 continue;
             }
@@ -114,7 +113,7 @@ public class OBRXMLWriter {
         addAttr(atts, ResourceHandler.SYMBOLIC_NAME, bundleInfo.getSymbolicName());
         addAttr(atts, ResourceHandler.VERSION, bundleInfo.getRawVersion());
         if (bundleInfo.getUri() != null) {
-            addAttr(atts, ResourceHandler.URI, bundleInfo.getUri());
+            addAttr(atts, ResourceHandler.URI, bundleInfo.getUri().toString());
         }
         handler.startElement("", ResourceHandler.RESOURCE, ResourceHandler.RESOURCE, atts);
         Iterator itCapabilities = bundleInfo.getCapabilities().iterator();

Modified: ant/ivy/core/trunk/src/java/org/apache/ivy/osgi/p2/P2Descriptor.java
URL: http://svn.apache.org/viewvc/ant/ivy/core/trunk/src/java/org/apache/ivy/osgi/p2/P2Descriptor.java?rev=1165100&r1=1165099&r2=1165100&view=diff
==============================================================================
--- ant/ivy/core/trunk/src/java/org/apache/ivy/osgi/p2/P2Descriptor.java (original)
+++ ant/ivy/core/trunk/src/java/org/apache/ivy/osgi/p2/P2Descriptor.java Sun Sep  4 19:37:03 2011
@@ -17,6 +17,9 @@
  */
 package org.apache.ivy.osgi.p2;
 
+import java.net.MalformedURLException;
+import java.net.URI;
+import java.net.URISyntaxException;
 import java.util.HashMap;
 import java.util.Map;
 
@@ -29,10 +32,17 @@ public class P2Descriptor extends RepoDe
 
     private long timestamp;
 
-    private Map/* <String, Map<Version, String>> */artifactUrls = new HashMap();
+    private Map/* <String, Map<Version, String>> */artifactUrlPatterns = new HashMap();
 
-    public P2Descriptor(ExecutionEnvironmentProfileProvider profileProvider) {
-        super(profileProvider);
+    private String repoUrl;
+
+    public P2Descriptor(URI repoUri, ExecutionEnvironmentProfileProvider profileProvider) {
+        super(repoUri, profileProvider);
+        try {
+            repoUrl = repoUri.toURL().toExternalForm();
+        } catch (MalformedURLException e) {
+            throw new RuntimeException("Illegal repo uri", e);
+        }
     }
 
     public void setTimestamp(long timestamp) {
@@ -42,12 +52,20 @@ public class P2Descriptor extends RepoDe
     public void addBundle(BundleInfo bundleInfo) {
         // before transforming it and adding it into the repo, let's add the artifacts
 
-        Map/* <Version, String> */urlsByVersion = (Map) artifactUrls.get(bundleInfo
+        Map/* <Version, String> */urlPatternsByVersion = (Map) artifactUrlPatterns.get(bundleInfo
                 .getSymbolicName());
-        if (urlsByVersion != null) {
-            String url = (String) urlsByVersion.get(bundleInfo.getVersion());
-            if (url != null) {
-                bundleInfo.setUri(url);
+        if (urlPatternsByVersion != null) {
+            String urlPattern = (String) urlPatternsByVersion.get(bundleInfo.getVersion());
+            if (urlPattern != null) {
+                String url = urlPattern.replaceAll("\\$\\{repoUrl\\}", repoUrl);
+                url = url.replaceAll("\\$\\{id\\}", bundleInfo.getSymbolicName());
+                url = url.replaceAll("\\$\\{version\\}", bundleInfo.getVersion().toString());
+                try {
+                    bundleInfo.setUri(new URI(url));
+                } catch (URISyntaxException e) {
+                    throw new RuntimeException("Unable to build the artifact uri of " + bundleInfo,
+                            e);
+                }
             }
         }
 
@@ -55,10 +73,10 @@ public class P2Descriptor extends RepoDe
     }
 
     public void addArtifactUrl(String id, Version version, String url) {
-        Map/* <Version, String> */byVersion = (Map) artifactUrls.get(id);
+        Map/* <Version, String> */byVersion = (Map) artifactUrlPatterns.get(id);
         if (byVersion == null) {
             byVersion = new HashMap();
-            artifactUrls.put(id, byVersion);
+            artifactUrlPatterns.put(id, byVersion);
         }
         byVersion.put(version, url);
     }

Modified: ant/ivy/core/trunk/src/java/org/apache/ivy/osgi/p2/P2MetadataParser.java
URL: http://svn.apache.org/viewvc/ant/ivy/core/trunk/src/java/org/apache/ivy/osgi/p2/P2MetadataParser.java?rev=1165100&r1=1165099&r2=1165100&view=diff
==============================================================================
--- ant/ivy/core/trunk/src/java/org/apache/ivy/osgi/p2/P2MetadataParser.java (original)
+++ ant/ivy/core/trunk/src/java/org/apache/ivy/osgi/p2/P2MetadataParser.java Sun Sep  4 19:37:03 2011
@@ -286,7 +286,7 @@ public class P2MetadataParser implements
         protected void handleAttributes(Attributes atts) {
             String id = atts.getValue(ID);
             Version version = new Version(atts.getValue(VERSION));
-            boolean singleton = Boolean.getBoolean(atts.getValue(SINGLETON));
+            // Boolean singleton = Boolean.valueOf(atts.getValue(SINGLETON));
             bundleInfo = new BundleInfo(id, version);
         }
 

Modified: ant/ivy/core/trunk/src/java/org/apache/ivy/osgi/repo/AbstractFSManifestIterable.java
URL: http://svn.apache.org/viewvc/ant/ivy/core/trunk/src/java/org/apache/ivy/osgi/repo/AbstractFSManifestIterable.java?rev=1165100&r1=1165099&r2=1165100&view=diff
==============================================================================
--- ant/ivy/core/trunk/src/java/org/apache/ivy/osgi/repo/AbstractFSManifestIterable.java (original)
+++ ant/ivy/core/trunk/src/java/org/apache/ivy/osgi/repo/AbstractFSManifestIterable.java Sun Sep  4 19:37:03 2011
@@ -20,6 +20,7 @@ package org.apache.ivy.osgi.repo;
 import java.io.FileNotFoundException;
 import java.io.IOException;
 import java.io.InputStream;
+import java.net.URI;
 import java.util.Collections;
 import java.util.Iterator;
 import java.util.List;
@@ -30,7 +31,8 @@ import java.util.jar.Manifest;
 
 import org.apache.ivy.util.Message;
 
-public abstract class AbstractFSManifestIterable { //implements Iterable/* <ManifestAndLocation> */{
+public abstract class AbstractFSManifestIterable { // implements Iterable/* <ManifestAndLocation>
+                                                   // */{
 
     public Iterator/* <ManifestAndLocation> */iterator() {
         return new FSManifestIterator();
@@ -42,9 +44,7 @@ public abstract class AbstractFSManifest
 
     abstract protected InputStream getInputStream(String f) throws IOException;
 
-    protected String createBundleLocation(String location) {
-        return location;
-    }
+    abstract protected URI buildBundleURI(String location) throws IOException;
 
     class FSManifestIterator implements Iterator/* <ManifestAndLocation> */{
 
@@ -101,7 +101,7 @@ public abstract class AbstractFSManifest
                         Manifest manifest = in.getManifest();
                         if (manifest != null) {
                             next = new ManifestAndLocation(manifest,
-                                    createBundleLocation(bundleCandidate));
+                                    buildBundleURI(bundleCandidate));
                         } else {
                             Message.debug("No manifest in jar: " + bundleCandidate);
                         }

Modified: ant/ivy/core/trunk/src/java/org/apache/ivy/osgi/repo/BundleRepoDescriptor.java
URL: http://svn.apache.org/viewvc/ant/ivy/core/trunk/src/java/org/apache/ivy/osgi/repo/BundleRepoDescriptor.java?rev=1165100&r1=1165099&r2=1165100&view=diff
==============================================================================
--- ant/ivy/core/trunk/src/java/org/apache/ivy/osgi/repo/BundleRepoDescriptor.java (original)
+++ ant/ivy/core/trunk/src/java/org/apache/ivy/osgi/repo/BundleRepoDescriptor.java Sun Sep  4 19:37:03 2011
@@ -17,6 +17,7 @@
  */
 package org.apache.ivy.osgi.repo;
 
+import java.net.URI;
 import java.text.ParseException;
 import java.util.Iterator;
 
@@ -31,8 +32,8 @@ public class BundleRepoDescriptor extend
 
     private Long lastModified;
 
-    public BundleRepoDescriptor(ExecutionEnvironmentProfileProvider profileProvider) {
-        super(profileProvider);
+    public BundleRepoDescriptor(URI baseUri, ExecutionEnvironmentProfileProvider profileProvider) {
+        super(baseUri, profileProvider);
     }
 
     public void setName(String name) {
@@ -57,11 +58,10 @@ public class BundleRepoDescriptor extend
             try {
                 BundleInfo bundleInfo = ManifestParser.parseManifest(manifestAndLocation
                         .getManifest());
-                bundleInfo.setUri(manifestAndLocation.getLocation());
+                bundleInfo.setUri(manifestAndLocation.getUri());
                 addBundle(bundleInfo);
             } catch (ParseException e) {
-                Message.error("Rejected " + manifestAndLocation.getLocation() + ": "
-                        + e.getMessage());
+                Message.error("Rejected " + manifestAndLocation.getUri() + ": " + e.getMessage());
             }
         }
     }

Modified: ant/ivy/core/trunk/src/java/org/apache/ivy/osgi/repo/FSManifestIterable.java
URL: http://svn.apache.org/viewvc/ant/ivy/core/trunk/src/java/org/apache/ivy/osgi/repo/FSManifestIterable.java?rev=1165100&r1=1165099&r2=1165100&view=diff
==============================================================================
--- ant/ivy/core/trunk/src/java/org/apache/ivy/osgi/repo/FSManifestIterable.java (original)
+++ ant/ivy/core/trunk/src/java/org/apache/ivy/osgi/repo/FSManifestIterable.java Sun Sep  4 19:37:03 2011
@@ -23,6 +23,9 @@ import java.io.FileInputStream;
 import java.io.FileNotFoundException;
 import java.io.FilenameFilter;
 import java.io.InputStream;
+import java.net.MalformedURLException;
+import java.net.URI;
+import java.net.URISyntaxException;
 import java.util.ArrayList;
 import java.util.Arrays;
 import java.util.HashSet;
@@ -93,8 +96,14 @@ public class FSManifestIterable extends 
         this.bundleFilter = bundleFilter;
     }
 
-    protected String createBundleLocation(String location) {
-        return basePath + location;
+    protected URI buildBundleURI(String location) {
+        try {
+            return new URI(new File(basePath + location).toURL().toExternalForm());
+        } catch (MalformedURLException e) {
+            throw new RuntimeException("Unexpected file to url conversion error", e);
+        } catch (URISyntaxException e) {
+            throw new RuntimeException("Unexpected url to uri conversion error", e);
+        }
     }
 
     protected InputStream getInputStream(String f) throws FileNotFoundException {

Modified: ant/ivy/core/trunk/src/java/org/apache/ivy/osgi/repo/ManifestAndLocation.java
URL: http://svn.apache.org/viewvc/ant/ivy/core/trunk/src/java/org/apache/ivy/osgi/repo/ManifestAndLocation.java?rev=1165100&r1=1165099&r2=1165100&view=diff
==============================================================================
--- ant/ivy/core/trunk/src/java/org/apache/ivy/osgi/repo/ManifestAndLocation.java (original)
+++ ant/ivy/core/trunk/src/java/org/apache/ivy/osgi/repo/ManifestAndLocation.java Sun Sep  4 19:37:03 2011
@@ -17,6 +17,7 @@
  */
 package org.apache.ivy.osgi.repo;
 
+import java.net.URI;
 import java.util.jar.Manifest;
 
 public class ManifestAndLocation {
@@ -24,17 +25,17 @@ public class ManifestAndLocation {
     private final Manifest manifest;
 
     /**
-     * location of the jar relative to the repository URL
+     * location of the jar
      */
-    private final String location;
+    private final URI uri;
 
-    public ManifestAndLocation(Manifest manifest, String location) {
+    public ManifestAndLocation(Manifest manifest, URI uri) {
         this.manifest = manifest;
-        this.location = location;
+        this.uri = uri;
     }
 
-    public String getLocation() {
-        return location;
+    public URI getUri() {
+        return uri;
     }
 
     public Manifest getManifest() {

Modified: ant/ivy/core/trunk/src/java/org/apache/ivy/osgi/repo/RepoDescriptor.java
URL: http://svn.apache.org/viewvc/ant/ivy/core/trunk/src/java/org/apache/ivy/osgi/repo/RepoDescriptor.java?rev=1165100&r1=1165099&r2=1165100&view=diff
==============================================================================
--- ant/ivy/core/trunk/src/java/org/apache/ivy/osgi/repo/RepoDescriptor.java (original)
+++ ant/ivy/core/trunk/src/java/org/apache/ivy/osgi/repo/RepoDescriptor.java Sun Sep  4 19:37:03 2011
@@ -17,6 +17,7 @@
  */
 package org.apache.ivy.osgi.repo;
 
+import java.net.URI;
 import java.util.HashMap;
 import java.util.HashSet;
 import java.util.Iterator;
@@ -39,14 +40,25 @@ public class RepoDescriptor {
 
     private final ExecutionEnvironmentProfileProvider profileProvider;
 
-    public RepoDescriptor(ExecutionEnvironmentProfileProvider profileProvider) {
+    private final URI baseUri;
+
+    public RepoDescriptor(URI baseUri, ExecutionEnvironmentProfileProvider profileProvider) {
+        this.baseUri = baseUri;
         this.profileProvider = profileProvider;
     }
 
-    public Set/* <ModuleDescriptor> */ getModules() {
+    public URI getBaseUri() {
+        return baseUri;
+    }
+
+    public Set/* <ModuleDescriptor> */getModules() {
         return modules;
     }
 
+    public Map/* <String, Map<String, Set<ModuleDescriptor>>> */getModuleByCapbilities() {
+        return moduleByCapbilities;
+    }
+
     public Set/* <ModuleDescriptor> */findModule(String requirement, String value) {
         Map/* <String, Set<ModuleDescriptor>> */modules = (Map) moduleByCapbilities
                 .get(requirement);
@@ -83,7 +95,7 @@ public class RepoDescriptor {
     }
 
     public void addBundle(BundleInfo bundleInfo) {
-        DefaultModuleDescriptor md = BundleInfoAdapter.toModuleDescriptor(bundleInfo,
+        DefaultModuleDescriptor md = BundleInfoAdapter.toModuleDescriptor(baseUri, bundleInfo,
             profileProvider);
         add(BundleInfo.BUNDLE_TYPE, bundleInfo.getSymbolicName(), md);
         Iterator itCapability = bundleInfo.getCapabilities().iterator();

Modified: ant/ivy/core/trunk/src/java/org/apache/ivy/osgi/repo/RepoDescriptorBasedResolver.java
URL: http://svn.apache.org/viewvc/ant/ivy/core/trunk/src/java/org/apache/ivy/osgi/repo/RepoDescriptorBasedResolver.java?rev=1165100&r1=1165099&r2=1165100&view=diff
==============================================================================
--- ant/ivy/core/trunk/src/java/org/apache/ivy/osgi/repo/RepoDescriptorBasedResolver.java (original)
+++ ant/ivy/core/trunk/src/java/org/apache/ivy/osgi/repo/RepoDescriptorBasedResolver.java Sun Sep  4 19:37:03 2011
@@ -19,6 +19,7 @@ package org.apache.ivy.osgi.repo;
 
 import java.io.File;
 import java.io.IOException;
+import java.net.URL;
 import java.util.ArrayList;
 import java.util.Arrays;
 import java.util.Collection;
@@ -34,8 +35,6 @@ import java.util.Set;
 
 import org.apache.ivy.core.IvyPatternHelper;
 import org.apache.ivy.core.module.descriptor.Artifact;
-import org.apache.ivy.core.module.descriptor.Configuration;
-import org.apache.ivy.core.module.descriptor.DefaultModuleDescriptor;
 import org.apache.ivy.core.module.descriptor.DependencyDescriptor;
 import org.apache.ivy.core.module.descriptor.ModuleDescriptor;
 import org.apache.ivy.core.module.id.ModuleRevisionId;
@@ -45,10 +44,10 @@ import org.apache.ivy.core.resolve.Resol
 import org.apache.ivy.core.resolve.ResolvedModuleRevision;
 import org.apache.ivy.osgi.core.BundleInfo;
 import org.apache.ivy.osgi.core.BundleInfoAdapter;
-import org.apache.ivy.osgi.core.ExecutionEnvironmentProfileProvider;
 import org.apache.ivy.osgi.util.Version;
-import org.apache.ivy.plugins.repository.Repository;
 import org.apache.ivy.plugins.repository.Resource;
+import org.apache.ivy.plugins.repository.url.URLRepository;
+import org.apache.ivy.plugins.repository.url.URLResource;
 import org.apache.ivy.plugins.resolver.BasicResolver;
 import org.apache.ivy.plugins.resolver.util.MDResolvedResource;
 import org.apache.ivy.plugins.resolver.util.ResolvedResource;
@@ -57,11 +56,9 @@ import org.apache.ivy.util.Message;
 
 public abstract class RepoDescriptorBasedResolver extends BasicResolver {
 
-    private Repository repository = null;
-
     private RepoDescriptor repoDescriptor = null;
 
-    private ExecutionEnvironmentProfileProvider profileProvider;
+    private URLRepository repository = new URLRepository();
 
     public static class RequirementStrategy {
         // take the first matching
@@ -91,31 +88,22 @@ public abstract class RepoDescriptorBase
         setImportPackageStrategy(RequirementStrategy.valueOf(strategy));
     }
 
-    public void add(ExecutionEnvironmentProfileProvider pp) {
-        this.profileProvider = pp;
-    }
-
-    protected void setRepository(Repository repository) {
-        this.repository = repository;
-    }
-
     protected void setRepoDescriptor(RepoDescriptor repoDescriptor) {
         this.repoDescriptor = repoDescriptor;
     }
 
+    public URLRepository getRepository() {
+        return repository;
+    }
+
     protected void ensureInit() {
-        if (repoDescriptor == null || repository == null) {
+        if (repoDescriptor == null) {
             init();
         }
     }
 
     abstract protected void init();
 
-    public Repository getRepository() {
-        ensureInit();
-        return repository;
-    }
-
     private RepoDescriptor getRepoDescriptor() {
         ensureInit();
         return repoDescriptor;
@@ -230,14 +218,11 @@ public abstract class RepoDescriptorBase
     }
 
     public ResolvedResource findArtifactRef(Artifact artifact, Date date) {
-        ModuleRevisionId mrid = artifact.getModuleRevisionId();
-        try {
-            return new ResolvedResource(getRepository().getResource(artifact.getUrl().getFile()),
-                    artifact.getModuleRevisionId().getRevision());
-        } catch (IOException e) {
-            throw new RuntimeException(getName() + ": unable to get resource for " + mrid
-                    + ": res=" + artifact.getName() + ": " + e.getMessage(), e);
-        }
+        URL url = artifact.getUrl();
+        Message.verbose("\tusing url for " + artifact + ": " + url);
+        logArtifactAttempt(artifact, url.toExternalForm());
+        Resource resource = new URLResource(url);
+        return new ResolvedResource(resource, artifact.getModuleRevisionId().getRevision());
     }
 
     protected Collection/* <String> */filterNames(Collection/* <String> */names) {
@@ -251,19 +236,42 @@ public abstract class RepoDescriptorBase
                     BundleInfo.SERVICE_TYPE});
         }
 
-        String osgiAtt = (String) tokenValues.get(BundleInfoAdapter.EXTRA_ATTRIBUTE_NAME);
+        if (IvyPatternHelper.ORGANISATION_KEY.equals(token)) {
+            return Collections.singletonList("");
+        }
 
-        Set/* <String> */capabilityValues = getRepoDescriptor().getCapabilityValues(osgiAtt);
-        if (capabilityValues == null || capabilityValues.isEmpty()) {
+        String org = (String) tokenValues.get(IvyPatternHelper.ORGANISATION_KEY);
+        if (org != null && org.length() != 0) {
             return Collections.EMPTY_LIST;
         }
 
-        if (IvyPatternHelper.ORGANISATION_KEY.equals(token)) {
-            return Collections.singletonList("");
-        }
+        String osgiAtt = (String) tokenValues.get(BundleInfoAdapter.EXTRA_ATTRIBUTE_NAME);
+        String rev = (String) tokenValues.get(IvyPatternHelper.REVISION_KEY);
 
         if (IvyPatternHelper.MODULE_KEY.equals(token)) {
-            return capabilityValues;
+            Map/* <String, Map<String, Set<ModuleDescriptor>>> */moduleByCapbilities = getRepoDescriptor()
+                    .getModuleByCapbilities();
+            if (osgiAtt != null) {
+                Map/* <String, Set<ModuleDescriptor>> */moduleByCapabilityValue = (Map) moduleByCapbilities
+                        .get(osgiAtt);
+                if (moduleByCapabilityValue == null) {
+                    return Collections.EMPTY_LIST;
+                }
+                Set/* <String> */capabilityValues = new HashSet();
+                filterCapabilityValues(capabilityValues, moduleByCapbilities, tokenValues, rev);
+                return capabilityValues;
+            } else {
+                Set/* <String> */capabilityValues = new HashSet();
+                Iterator/* <Map<String, Set<ModuleDescriptor>>> */it = ((Collection) moduleByCapbilities
+                        .values()).iterator();
+                while (it.hasNext()) {
+                    Map/* <String, Set<ModuleDescriptor>> */moduleByCapbilityValue = (Map) it
+                            .next();
+                    filterCapabilityValues(capabilityValues, moduleByCapbilityValue, tokenValues,
+                        rev);
+                }
+                return capabilityValues;
+            }
         }
 
         if (IvyPatternHelper.REVISION_KEY.equals(token)) {
@@ -315,19 +323,41 @@ public abstract class RepoDescriptorBase
             if (found == null) {
                 return Collections.EMPTY_LIST;
             }
-            DefaultModuleDescriptor md = BundleInfoAdapter.toModuleDescriptor(
-                found.getBundleInfo(), profileProvider);
-            List/* <String> */confs = new ArrayList/* <String> */();
-            Configuration[] configurations = md.getConfigurations();
-            for (int i = 0; i < configurations.length; i++) {
-                Configuration conf = configurations[i];
-                confs.add(conf.getName());
-            }
+            List/* <String> */confs = BundleInfoAdapter.getConfigurations(found.getBundleInfo());
             return confs;
         }
         return Collections.EMPTY_LIST;
     }
 
+    /**
+     * Populate capabilityValues with capability values for which at least one module match the
+     * expected revision
+     */
+    private void filterCapabilityValues(Set/* <String> */capabilityValues,
+            Map/* <String, Set<ModuleDescriptor>> */moduleByCapbilityValue,
+            Map/* <String, String */tokenValues, String rev) {
+        if (rev == null) {
+            // no revision, all match then
+            capabilityValues.addAll(moduleByCapbilityValue.keySet());
+        } else {
+            Iterator/* <Entry<String, Set<ModuleDescriptor>>> */it = moduleByCapbilityValue
+                    .entrySet().iterator();
+            while (it.hasNext()) {
+                Entry/* <String, Set<ModuleDescriptor>> */entry = (Entry) it.next();
+                Iterator/* <ModuleDescriptor> */itModules = ((Set) entry.getValue()).iterator();
+                boolean moduleMatchRev = false;
+                while (!moduleMatchRev && itModules.hasNext()) {
+                    ModuleDescriptor md = (ModuleDescriptor) itModules.next();
+                    moduleMatchRev = rev.equals(md.getRevision());
+                }
+                if (moduleMatchRev) {
+                    // at least one module matched, the capability value is ok to add
+                    capabilityValues.add(entry.getKey());
+                }
+            }
+        }
+    }
+
     public Map[] listTokenValues(String[] tokens, Map criteria) {
         Set/* <String> */tokenSet = new HashSet/* <String> */(Arrays.asList(tokens));
         Set/* <Map<String, String>> */listTokenValues = listTokenValues(tokenSet, criteria);
@@ -442,13 +472,11 @@ public abstract class RepoDescriptorBase
                 return Collections.EMPTY_SET;
             }
             Set/* <Map<String, String>> */tokenValues = new HashSet/* <Map<String, String>> */();
-            DefaultModuleDescriptor md = BundleInfoAdapter.toModuleDescriptor(
-                found.getBundleInfo(), profileProvider);
-            Configuration[] configurations = md.getConfigurations();
-            for (int i = 0; i < configurations.length; i++) {
-                Configuration c = configurations[i];
+            List/* <String> */configurations = BundleInfoAdapter.getConfigurations(found
+                    .getBundleInfo());
+            for (int i = 0; i < configurations.size(); i++) {
                 Map/* <String, String> */newCriteria = new HashMap/* <String, String> */(criteria);
-                newCriteria.put(IvyPatternHelper.CONF_KEY, c.getName());
+                newCriteria.put(IvyPatternHelper.CONF_KEY, configurations.get(i));
                 tokenValues.add(newCriteria);
             }
             return tokenValues;

Modified: ant/ivy/core/trunk/src/java/org/apache/ivy/osgi/repo/RepositoryManifestIterable.java
URL: http://svn.apache.org/viewvc/ant/ivy/core/trunk/src/java/org/apache/ivy/osgi/repo/RepositoryManifestIterable.java?rev=1165100&r1=1165099&r2=1165100&view=diff
==============================================================================
--- ant/ivy/core/trunk/src/java/org/apache/ivy/osgi/repo/RepositoryManifestIterable.java (original)
+++ ant/ivy/core/trunk/src/java/org/apache/ivy/osgi/repo/RepositoryManifestIterable.java Sun Sep  4 19:37:03 2011
@@ -19,6 +19,8 @@ package org.apache.ivy.osgi.repo;
 
 import java.io.IOException;
 import java.io.InputStream;
+import java.net.URI;
+import java.net.URISyntaxException;
 import java.util.Arrays;
 import java.util.Collections;
 import java.util.List;
@@ -40,6 +42,16 @@ public class RepositoryManifestIterable 
         this.repo = repo;
     }
 
+    protected URI buildBundleURI(String location) throws IOException {
+        try {
+            return new URI(repo.getResource(location).getName());
+        } catch (URISyntaxException e) {
+            throw new RuntimeException(
+                    "Unsupported repository type, resources names cannot be transformed into uri",
+                    e);
+        }
+    }
+
     protected InputStream getInputStream(String f) throws IOException {
         return repo.getResource(f).openStream();
     }
@@ -53,7 +65,6 @@ public class RepositoryManifestIterable 
     }
 
     private List/* <String> */asList(String[] array) {
-        return array == null ? Collections.EMPTY_LIST : Arrays
-                ./* <String> */asList(array);
+        return array == null ? Collections.EMPTY_LIST : Arrays./* <String> */asList(array);
     }
 }

Modified: ant/ivy/core/trunk/src/java/org/apache/ivy/osgi/repo/ResolverManifestIterable.java
URL: http://svn.apache.org/viewvc/ant/ivy/core/trunk/src/java/org/apache/ivy/osgi/repo/ResolverManifestIterable.java?rev=1165100&r1=1165099&r2=1165100&view=diff
==============================================================================
--- ant/ivy/core/trunk/src/java/org/apache/ivy/osgi/repo/ResolverManifestIterable.java (original)
+++ ant/ivy/core/trunk/src/java/org/apache/ivy/osgi/repo/ResolverManifestIterable.java Sun Sep  4 19:37:03 2011
@@ -18,6 +18,7 @@
 package org.apache.ivy.osgi.repo;
 
 import java.io.IOException;
+import java.net.URI;
 import java.text.ParseException;
 import java.util.Iterator;
 import java.util.NoSuchElementException;
@@ -179,8 +180,8 @@ public class ResolverManifestIterable { 
                 if (manifest == null) {
                     Message.debug("No manifest on " + artifact);
                 } else {
-                    String location = BundleInfoAdapter.encodeIvyLocation(artifact);
-                    next = new ManifestAndLocation(manifest, location);
+                    URI uri = BundleInfoAdapter.buildIvyURI(artifact);
+                    next = new ManifestAndLocation(manifest, uri);
                 }
                 artifact = null;
             }

Modified: ant/ivy/core/trunk/src/java/org/apache/ivy/osgi/updatesite/PluginAdapter.java
URL: http://svn.apache.org/viewvc/ant/ivy/core/trunk/src/java/org/apache/ivy/osgi/updatesite/PluginAdapter.java?rev=1165100&r1=1165099&r2=1165100&view=diff
==============================================================================
--- ant/ivy/core/trunk/src/java/org/apache/ivy/osgi/updatesite/PluginAdapter.java (original)
+++ ant/ivy/core/trunk/src/java/org/apache/ivy/osgi/updatesite/PluginAdapter.java Sun Sep  4 19:37:03 2011
@@ -17,6 +17,7 @@
  */
 package org.apache.ivy.osgi.updatesite;
 
+import java.net.URI;
 import java.util.Iterator;
 
 import org.apache.ivy.osgi.core.BundleInfo;
@@ -28,13 +29,14 @@ import org.apache.ivy.osgi.util.VersionR
 
 public class PluginAdapter {
 
-    public static BundleInfo featureAsBundle(String baseUrl, EclipseFeature feature) {
+    public static BundleInfo featureAsBundle(URI baseUri, EclipseFeature feature) {
         BundleInfo b = new BundleInfo(feature.getId(), feature.getVersion());
 
         if (feature.getUrl() == null) {
-            b.setUri(baseUrl + "features/" + feature.getId() + '_' + feature.getVersion() + ".jar");
+            b.setUri(baseUri.resolve("features/" + feature.getId() + '_' + feature.getVersion()
+                    + ".jar"));
         } else {
-            b.setUri(baseUrl + feature.getUrl());
+            b.setUri(baseUri.resolve(feature.getUrl()));
         }
 
         b.setDescription(feature.getDescription());
@@ -70,10 +72,10 @@ public class PluginAdapter {
         return b;
     }
 
-    public static BundleInfo pluginAsBundle(String baseUrl, EclipsePlugin plugin) {
+    public static BundleInfo pluginAsBundle(URI baseUri, EclipsePlugin plugin) {
         BundleInfo b = new BundleInfo(plugin.getId(), plugin.getVersion());
 
-        b.setUri(baseUrl + "plugins/" + plugin.getId() + '_' + plugin.getVersion() + ".jar");
+        b.setUri(baseUri.resolve("plugins/" + plugin.getId() + '_' + plugin.getVersion() + ".jar"));
 
         return b;
     }

Modified: ant/ivy/core/trunk/src/java/org/apache/ivy/osgi/updatesite/UpdateSiteDescriptor.java
URL: http://svn.apache.org/viewvc/ant/ivy/core/trunk/src/java/org/apache/ivy/osgi/updatesite/UpdateSiteDescriptor.java?rev=1165100&r1=1165099&r2=1165100&view=diff
==============================================================================
--- ant/ivy/core/trunk/src/java/org/apache/ivy/osgi/updatesite/UpdateSiteDescriptor.java (original)
+++ ant/ivy/core/trunk/src/java/org/apache/ivy/osgi/updatesite/UpdateSiteDescriptor.java Sun Sep  4 19:37:03 2011
@@ -17,6 +17,7 @@
  */
 package org.apache.ivy.osgi.updatesite;
 
+import java.net.URI;
 import java.util.Iterator;
 
 import org.apache.ivy.osgi.core.ExecutionEnvironmentProfileProvider;
@@ -26,16 +27,16 @@ import org.apache.ivy.osgi.updatesite.xm
 
 public class UpdateSiteDescriptor extends RepoDescriptor {
 
-    public UpdateSiteDescriptor(ExecutionEnvironmentProfileProvider profileProvider) {
-        super(profileProvider);
+    public UpdateSiteDescriptor(URI baseUri, ExecutionEnvironmentProfileProvider profileProvider) {
+        super(baseUri, profileProvider);
     }
 
-    public void addFeature(String baseUrl, EclipseFeature feature) {
-        addBundle(PluginAdapter.featureAsBundle(baseUrl, feature));
+    public void addFeature(EclipseFeature feature) {
+        addBundle(PluginAdapter.featureAsBundle(getBaseUri(), feature));
 
         Iterator itPlugins = feature.getPlugins().iterator();
         while (itPlugins.hasNext()) {
-            addBundle(PluginAdapter.pluginAsBundle(baseUrl, (EclipsePlugin) itPlugins.next()));
+            addBundle(PluginAdapter.pluginAsBundle(getBaseUri(), (EclipsePlugin) itPlugins.next()));
         }
     }
 

Modified: ant/ivy/core/trunk/src/java/org/apache/ivy/osgi/updatesite/UpdateSiteLoader.java
URL: http://svn.apache.org/viewvc/ant/ivy/core/trunk/src/java/org/apache/ivy/osgi/updatesite/UpdateSiteLoader.java?rev=1165100&r1=1165099&r2=1165100&view=diff
==============================================================================
--- ant/ivy/core/trunk/src/java/org/apache/ivy/osgi/updatesite/UpdateSiteLoader.java (original)
+++ ant/ivy/core/trunk/src/java/org/apache/ivy/osgi/updatesite/UpdateSiteLoader.java Sun Sep  4 19:37:03 2011
@@ -20,7 +20,8 @@ package org.apache.ivy.osgi.updatesite;
 import java.io.FileInputStream;
 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.text.ParseException;
 import java.util.Iterator;
@@ -66,16 +67,23 @@ public class UpdateSiteLoader {
         }
     }
 
-    public RepoDescriptor load(String url) throws IOException, ParseException, SAXException {
-        Message.verbose("Loading the update site " + url);
+    public RepoDescriptor load(URI repoUri) throws IOException, ParseException, SAXException {
+        if (!repoUri.toString().endsWith("/")) {
+            try {
+                repoUri = new URI(repoUri.toString() + "/");
+            } catch (URISyntaxException e) {
+                throw new RuntimeException("Cannot make an uri for the repo");
+            }
+        }
+        Message.verbose("Loading the update site " + repoUri);
         // first look for a p2 repository
-        RepoDescriptor repo = loadP2(url);
+        RepoDescriptor repo = loadP2(repoUri);
         if (repo != null) {
             return repo;
         }
         Message.verbose("\tNo P2 artifacts, falling back on the old fashioned updatesite");
         // then try the old update site
-        UpdateSite site = loadSite(url);
+        UpdateSite site = loadSite(repoUri);
         if (site == null) {
             return null;
         }
@@ -86,56 +94,53 @@ public class UpdateSiteLoader {
         return loadFromSite(site);
     }
 
-    private P2Descriptor loadP2(String url) throws IOException, ParseException, SAXException {
-        P2Descriptor p2Descriptor = new P2Descriptor(
+    private P2Descriptor loadP2(URI repoUri) throws IOException, ParseException, SAXException {
+        P2Descriptor p2Descriptor = new P2Descriptor(repoUri,
                 ExecutionEnvironmentProfileProvider.getInstance());
-        if (!populateP2Descriptor(url, p2Descriptor)) {
+        if (!populateP2Descriptor(repoUri, p2Descriptor)) {
             return null;
         }
         return p2Descriptor;
     }
 
-    private boolean populateP2Descriptor(String url, P2Descriptor p2Descriptor) throws IOException,
-            ParseException, SAXException {
+    private boolean populateP2Descriptor(URI repoUri, P2Descriptor p2Descriptor)
+            throws IOException, ParseException, SAXException {
         boolean exist = false;
 
-        exist |= readComposite(url, "compositeContent", p2Descriptor);
+        exist |= readComposite(repoUri, "compositeContent", p2Descriptor);
 
-        exist |= readComposite(url, "compositeArtifacts", p2Descriptor);
+        exist |= readComposite(repoUri, "compositeArtifacts", p2Descriptor);
 
-        exist |= readJarOrXml(url, "artifacts", new P2ArtifactParser(p2Descriptor));
+        exist |= readJarOrXml(repoUri, "artifacts", new P2ArtifactParser(p2Descriptor));
 
-        exist |= readJarOrXml(url, "content", new P2MetadataParser(p2Descriptor));
+        exist |= readJarOrXml(repoUri, "content", new P2MetadataParser(p2Descriptor));
 
         return exist;
     }
 
-    private boolean readComposite(String url, String name, P2Descriptor p2Descriptor)
+    private boolean readComposite(URI repoUri, String name, P2Descriptor p2Descriptor)
             throws IOException, ParseException, SAXException {
         P2CompositeParser p2CompositeParser = new P2CompositeParser();
-        boolean exist = readJarOrXml(url, name, p2CompositeParser);
+        boolean exist = readJarOrXml(repoUri, name, p2CompositeParser);
         if (exist) {
             Iterator itChildLocation = p2CompositeParser.getChildLocations().iterator();
             while (itChildLocation.hasNext()) {
                 String childLocation = (String) itChildLocation.next();
-                String childUrl = url + childLocation + "/";
-                try {
-                    URL u = new URL(childLocation);
-                    childUrl = u.toExternalForm();
-                } catch (MalformedURLException e) {
-                    // not an url, keep the relative location one
+                if (!childLocation.endsWith("/")) {
+                    childLocation += "/";
                 }
-                populateP2Descriptor(childUrl, p2Descriptor);
+                URI childUri = repoUri.resolve(childLocation);
+                populateP2Descriptor(childUri, p2Descriptor);
             }
         }
         return exist;
     }
 
-    private boolean readJarOrXml(String url, String baseName, XMLInputParser reader)
+    private boolean readJarOrXml(URI repoUri, String baseName, XMLInputParser reader)
             throws IOException, ParseException, SAXException {
         InputStream readIn = null; // the input stream from which the xml should be read
 
-        URL contentUrl = new URL(url + baseName + ".jar");
+        URL contentUrl = repoUri.resolve(baseName + ".jar").toURL();
         URLResource res = new URLResource(contentUrl);
 
         ArtifactDownloadReport report = repositoryCacheManager.downloadRepositoryResource(res,
@@ -143,11 +148,11 @@ public class UpdateSiteLoader {
 
         if (report.getDownloadStatus() == DownloadStatus.FAILED) {
             // no jar file, try the xml one
-            contentUrl = new URL(url + baseName + ".xml");
+            contentUrl = repoUri.resolve(baseName + ".xml").toURL();
             res = new URLResource(contentUrl);
 
-            report = repositoryCacheManager.downloadRepositoryResource(res,
-                baseName, baseName, "xml", options, urlRepository);
+            report = repositoryCacheManager.downloadRepositoryResource(res, baseName, baseName,
+                "xml", options, urlRepository);
 
             if (report.getDownloadStatus() == DownloadStatus.FAILED) {
                 // no xml either
@@ -181,9 +186,9 @@ public class UpdateSiteLoader {
         return true;
     }
 
-    private UpdateSite loadSite(String url) throws IOException, ParseException, SAXException {
-        String siteUrl = normalizeSiteUrl(url, null);
-        URL u = new URL(siteUrl + "site.xml");
+    private UpdateSite loadSite(URI repoUri) throws IOException, ParseException, SAXException {
+        URI siteUri = normalizeSiteUri(repoUri, null);
+        URL u = siteUri.resolve("site.xml").toURL();
 
         URLResource res = new URLResource(u);
         ArtifactDownloadReport report = repositoryCacheManager.downloadRepositoryResource(res,
@@ -194,46 +199,44 @@ public class UpdateSiteLoader {
         InputStream in = new FileInputStream(report.getLocalFile());
         try {
             UpdateSite site = EclipseUpdateSiteParser.parse(in);
-            site.setUrl(normalizeSiteUrl(site.getUrl(), siteUrl));
+            site.setUri(normalizeSiteUri(site.getUri(), siteUri));
             return site;
         } finally {
             in.close();
         }
     }
 
-    private String normalizeSiteUrl(String url, String defaultValue) {
-        if (url == null) {
+    private URI normalizeSiteUri(URI uri, URI defaultValue) {
+        if (uri == null) {
             return defaultValue;
         }
-        if (url.endsWith("site.xml")) {
-            return url.substring(0, url.length() - 8);
+        String uriString = uri.toString();
+        if (uriString.endsWith("site.xml")) {
+            try {
+                return new URI(uriString.substring(0, uriString.length() - 8));
+            } catch (URISyntaxException e) {
+                throw new RuntimeException("Illegal uri", e);
+            }
         }
-        if (!url.endsWith("/")) {
-            return url + "/";
+        if (!uriString.endsWith("/")) {
+            try {
+                return new URI(uriString + "/");
+            } catch (URISyntaxException e) {
+                throw new RuntimeException("Illegal uri", e);
+            }
         }
-        return url;
+        return uri;
     }
 
     private UpdateSiteDescriptor loadFromDigest(UpdateSite site) throws IOException,
             ParseException, SAXException {
-        String baseUrl = site.getDigestURL();
-        String siteUrl = site.getUrl();
-        if (baseUrl == null) {
-            baseUrl = siteUrl;
-        } else if (baseUrl.startsWith(".")) {
-            if (baseUrl.length() > 1 && baseUrl.charAt(1) == '/') {
-                baseUrl = siteUrl + baseUrl.substring(2);
-            } else {
-                baseUrl = siteUrl + baseUrl.substring(1);
-            }
-        }
-        String digestUrl;
-        if (baseUrl.endsWith("/")) {
-            digestUrl = baseUrl + "digest.zip";
-        } else {
-            digestUrl = baseUrl + "/digest.zip";
+        URI digestBaseUri = site.getDigestUri();
+        if (digestBaseUri == null) {
+            digestBaseUri = site.getUri();
+        } else if (!digestBaseUri.isAbsolute()) {
+            digestBaseUri = site.getUri().resolve(digestBaseUri);
         }
-        URL digest = new URL(digestUrl);
+        URL digest = digestBaseUri.resolve("digest.zip").toURL();
         Message.verbose("\tReading " + digest);
 
         URLResource res = new URLResource(digest);
@@ -256,13 +259,13 @@ public class UpdateSiteLoader {
 
     private UpdateSiteDescriptor loadFromSite(UpdateSite site) throws IOException, ParseException,
             SAXException {
-        UpdateSiteDescriptor repoDescriptor = new UpdateSiteDescriptor(
+        UpdateSiteDescriptor repoDescriptor = new UpdateSiteDescriptor(site.getUri(),
                 ExecutionEnvironmentProfileProvider.getInstance());
 
         Iterator itFeatures = site.getFeatures().iterator();
         while (itFeatures.hasNext()) {
             EclipseFeature feature = (EclipseFeature) itFeatures.next();
-            URL url = new URL(site.getUrl() + feature.getUrl());
+            URL url = site.getUri().resolve(feature.getUrl()).toURL();
 
             URLResource res = new URLResource(url);
             ArtifactDownloadReport report = repositoryCacheManager.downloadRepositoryResource(res,
@@ -278,7 +281,7 @@ public class UpdateSiteLoader {
                 }
                 EclipseFeature f = FeatureParser.parse(zipped);
                 f.setURL(feature.getUrl());
-                repoDescriptor.addFeature(site.getUrl(), f);
+                repoDescriptor.addFeature(f);
             } finally {
                 in.close();
             }

Modified: ant/ivy/core/trunk/src/java/org/apache/ivy/osgi/updatesite/UpdateSiteResolver.java
URL: http://svn.apache.org/viewvc/ant/ivy/core/trunk/src/java/org/apache/ivy/osgi/updatesite/UpdateSiteResolver.java?rev=1165100&r1=1165099&r2=1165100&view=diff
==============================================================================
--- ant/ivy/core/trunk/src/java/org/apache/ivy/osgi/updatesite/UpdateSiteResolver.java (original)
+++ ant/ivy/core/trunk/src/java/org/apache/ivy/osgi/updatesite/UpdateSiteResolver.java Sun Sep  4 19:37:03 2011
@@ -18,6 +18,8 @@
 package org.apache.ivy.osgi.updatesite;
 
 import java.io.IOException;
+import java.net.URI;
+import java.net.URISyntaxException;
 import java.text.ParseException;
 
 import org.apache.ivy.core.cache.CacheResourceOptions;
@@ -57,9 +59,8 @@ public class UpdateSiteResolver extends 
         }
         UpdateSiteLoader loader = new UpdateSiteLoader(getRepositoryCacheManager(),
                 getEventManager(), options);
-        String u = url.endsWith("/") ? url : (url + "/");
         try {
-            loader.load(u);
+            setRepoDescriptor(loader.load(new URI(url)));
         } catch (IOException e) {
             throw new RuntimeException("IO issue while trying to read the update site ("
                     + e.getMessage() + ")");
@@ -67,6 +68,8 @@ public class UpdateSiteResolver extends 
             throw new RuntimeException("Failed to parse the updatesite (" + e.getMessage() + ")");
         } catch (SAXException e) {
             throw new RuntimeException("Illformed updatesite (" + e.getMessage() + ")");
+        } catch (URISyntaxException e) {
+            throw new RuntimeException("Illformed url (" + e.getMessage() + ")");
         }
     }
 }

Modified: ant/ivy/core/trunk/src/java/org/apache/ivy/osgi/updatesite/xml/EclipseUpdateSiteParser.java
URL: http://svn.apache.org/viewvc/ant/ivy/core/trunk/src/java/org/apache/ivy/osgi/updatesite/xml/EclipseUpdateSiteParser.java?rev=1165100&r1=1165099&r2=1165100&view=diff
==============================================================================
--- ant/ivy/core/trunk/src/java/org/apache/ivy/osgi/updatesite/xml/EclipseUpdateSiteParser.java (original)
+++ ant/ivy/core/trunk/src/java/org/apache/ivy/osgi/updatesite/xml/EclipseUpdateSiteParser.java Sun Sep  4 19:37:03 2011
@@ -20,6 +20,8 @@ package org.apache.ivy.osgi.updatesite.x
 import java.io.File;
 import java.io.IOException;
 import java.io.InputStream;
+import java.net.URI;
+import java.net.URISyntaxException;
 import java.text.ParseException;
 
 import javax.xml.parsers.ParserConfigurationException;
@@ -90,7 +92,11 @@ public class EclipseUpdateSiteParser {
                 if (!url.endsWith("/") && !url.endsWith(File.separator)) {
                     url += "/";
                 }
-                updatesite.setUrl(url);
+                try {
+                    updatesite.setUri(new URI(url));
+                } catch (URISyntaxException e) {
+                    throw new RuntimeException("illegal url", e);
+                }
             }
 
             String mirrorsURL = atts.getValue(MIRRORS_URL);
@@ -105,7 +111,11 @@ public class EclipseUpdateSiteParser {
 
             String digestURL = atts.getValue(DIGEST_URL);
             if (digestURL != null) {
-                updatesite.setDigestURL(digestURL);
+                try {
+                    updatesite.setDigestUri(new URI(digestURL));
+                } catch (URISyntaxException e) {
+                    throw new RuntimeException("illegal url", e);
+                }
             }
 
             String associateSitesURL = atts.getValue(ASSOCIATE_SITES_URL);

Modified: ant/ivy/core/trunk/src/java/org/apache/ivy/osgi/updatesite/xml/UpdateSite.java
URL: http://svn.apache.org/viewvc/ant/ivy/core/trunk/src/java/org/apache/ivy/osgi/updatesite/xml/UpdateSite.java?rev=1165100&r1=1165099&r2=1165100&view=diff
==============================================================================
--- ant/ivy/core/trunk/src/java/org/apache/ivy/osgi/updatesite/xml/UpdateSite.java (original)
+++ ant/ivy/core/trunk/src/java/org/apache/ivy/osgi/updatesite/xml/UpdateSite.java Sun Sep  4 19:37:03 2011
@@ -17,27 +17,28 @@
  */
 package org.apache.ivy.osgi.updatesite.xml;
 
+import java.net.URI;
 import java.util.ArrayList;
 import java.util.List;
 
 public class UpdateSite {
 
-    private String url;
+    private URI uri;
 
     private String mirrorsURL;
 
     private boolean pack200;
 
-    private String digestUrl;
+    private URI digestUri;
 
     private List/* <EclipseFeature> */features = new ArrayList();
 
-    public void setUrl(String url) {
-        this.url = url;
+    public void setUri(URI uri) {
+        this.uri = uri;
     }
 
-    public String getUrl() {
-        return url;
+    public URI getUri() {
+        return uri;
     }
 
     public void setMirrorsURL(String mirrorsURL) {
@@ -48,12 +49,12 @@ public class UpdateSite {
         this.pack200 = pack200;
     }
 
-    public void setDigestURL(String digestURL) {
-        this.digestUrl = digestURL;
+    public void setDigestUri(URI digestUri) {
+        this.digestUri = digestUri;
     }
 
-    public String getDigestURL() {
-        return digestUrl;
+    public URI getDigestUri() {
+        return digestUri;
     }
 
     public void addFeature(EclipseFeature feature) {

Modified: ant/ivy/core/trunk/src/java/org/apache/ivy/osgi/updatesite/xml/UpdateSiteDigestParser.java
URL: http://svn.apache.org/viewvc/ant/ivy/core/trunk/src/java/org/apache/ivy/osgi/updatesite/xml/UpdateSiteDigestParser.java?rev=1165100&r1=1165099&r2=1165100&view=diff
==============================================================================
--- ant/ivy/core/trunk/src/java/org/apache/ivy/osgi/updatesite/xml/UpdateSiteDigestParser.java (original)
+++ ant/ivy/core/trunk/src/java/org/apache/ivy/osgi/updatesite/xml/UpdateSiteDigestParser.java Sun Sep  4 19:37:03 2011
@@ -47,14 +47,15 @@ public class UpdateSiteDigestParser {
 
         private static final String DIGEST = "digest";
 
-        UpdateSiteDescriptor repoDescriptor = new UpdateSiteDescriptor(
-                ExecutionEnvironmentProfileProvider.getInstance());
+        UpdateSiteDescriptor repoDescriptor;
 
         public DigestHandler(final UpdateSite site) {
             super(DIGEST);
+            repoDescriptor = new UpdateSiteDescriptor(site.getUri(),
+                    ExecutionEnvironmentProfileProvider.getInstance());
             addChild(new FeatureHandler(), new ChildElementHandler() {
                 public void childHanlded(DelegetingHandler child) {
-                    repoDescriptor.addFeature(site.getUrl(), ((FeatureHandler) child).feature);
+                    repoDescriptor.addFeature(((FeatureHandler) child).feature);
                 }
             });
         }

Modified: ant/ivy/core/trunk/src/java/org/apache/ivy/osgi/util/DelegetingHandler.java
URL: http://svn.apache.org/viewvc/ant/ivy/core/trunk/src/java/org/apache/ivy/osgi/util/DelegetingHandler.java?rev=1165100&r1=1165099&r2=1165100&view=diff
==============================================================================
--- ant/ivy/core/trunk/src/java/org/apache/ivy/osgi/util/DelegetingHandler.java (original)
+++ ant/ivy/core/trunk/src/java/org/apache/ivy/osgi/util/DelegetingHandler.java Sun Sep  4 19:37:03 2011
@@ -128,7 +128,6 @@ public class DelegetingHandler extends D
         parent.delegate = null;
         skip = false;
         started = false;
-        charBuffer.setLength(0);
         Iterator itHandler = saxHandlerMapping.values().iterator();
         while (itHandler.hasNext()) {
             DelegetingHandler/* <?> */subHandler = (DelegetingHandler) itHandler.next();
@@ -191,6 +190,8 @@ public class DelegetingHandler extends D
 
     public final void startElement(final String uri, final String localName, final String n,
             final Attributes atts) throws SAXException {
+        // reset the char buffer
+        charBuffer.setLength(0);
         if (delegate != null) {
             // we are already delegating, let's continue
             skipOnError(new SkipOnErrorCallback() {

Modified: ant/ivy/core/trunk/test/java/org/apache/ivy/osgi/obr/OBRParserTest.java
URL: http://svn.apache.org/viewvc/ant/ivy/core/trunk/test/java/org/apache/ivy/osgi/obr/OBRParserTest.java?rev=1165100&r1=1165099&r2=1165100&view=diff
==============================================================================
--- ant/ivy/core/trunk/test/java/org/apache/ivy/osgi/obr/OBRParserTest.java (original)
+++ ant/ivy/core/trunk/test/java/org/apache/ivy/osgi/obr/OBRParserTest.java Sun Sep  4 19:37:03 2011
@@ -29,9 +29,11 @@ import org.apache.ivy.util.Message;
 
 public class OBRParserTest extends TestCase {
 
+    private File testObr = new File("test/test-obr");
+
     public void testParse() throws Exception {
-        BundleRepoDescriptor repo = OBRXMLParser
-                .parse(new FileInputStream(new File("test/test-obr/obr.xml")));
+        BundleRepoDescriptor repo = OBRXMLParser.parse(testObr.toURI(), new FileInputStream(
+                new File(testObr, "obr.xml")));
         assertNotNull(repo);
         System.out.println(repo.getModules().size() + " bundles successfully parsed, "
                 + Message.getProblems().size() + " errors");

Modified: ant/ivy/core/trunk/test/java/org/apache/ivy/osgi/obr/OBRResolverTest.java
URL: http://svn.apache.org/viewvc/ant/ivy/core/trunk/test/java/org/apache/ivy/osgi/obr/OBRResolverTest.java?rev=1165100&r1=1165099&r2=1165100&view=diff
==============================================================================
--- ant/ivy/core/trunk/test/java/org/apache/ivy/osgi/obr/OBRResolverTest.java (original)
+++ ant/ivy/core/trunk/test/java/org/apache/ivy/osgi/obr/OBRResolverTest.java Sun Sep  4 19:37:03 2011
@@ -48,7 +48,6 @@ import org.apache.ivy.core.settings.IvyS
 import org.apache.ivy.osgi.core.BundleInfo;
 import org.apache.ivy.osgi.core.BundleInfoAdapter;
 import org.apache.ivy.osgi.core.ManifestParser;
-import org.apache.ivy.osgi.obr.OBRResolver;
 import org.apache.ivy.osgi.repo.RepoDescriptorBasedResolver.RequirementStrategy;
 import org.apache.ivy.plugins.resolver.DependencyResolver;
 import org.apache.ivy.plugins.resolver.DualResolver;
@@ -282,7 +281,8 @@ public class OBRResolverTest extends Tes
         JarInputStream in = new JarInputStream(new FileInputStream("test/test-repo/bundlerepo/"
                 + jarName));
         BundleInfo bundleInfo = ManifestParser.parseManifest(in.getManifest());
-        DefaultModuleDescriptor md = BundleInfoAdapter.toModuleDescriptor(bundleInfo, null);
+        bundleInfo.setUri(new File("test/test-repo/bundlerepo/" + jarName).toURI());
+        DefaultModuleDescriptor md = BundleInfoAdapter.toModuleDescriptor(null, bundleInfo, null);
         ResolveReport resolveReport = ivy.resolve(md,
             new ResolveOptions().setConfs(new String[] {conf}).setOutputReport(false));
         assertFalse("resolve failed " + resolveReport.getAllProblemMessages(),
@@ -312,7 +312,8 @@ public class OBRResolverTest extends Tes
         JarInputStream in = new JarInputStream(new FileInputStream("test/test-repo/bundlerepo/"
                 + jarName));
         BundleInfo bundleInfo = ManifestParser.parseManifest(in.getManifest());
-        DefaultModuleDescriptor md = BundleInfoAdapter.toModuleDescriptor(bundleInfo, null);
+        bundleInfo.setUri(new File("test/test-repo/bundlerepo/" + jarName).toURI());
+        DefaultModuleDescriptor md = BundleInfoAdapter.toModuleDescriptor(null, bundleInfo, null);
         ResolveReport resolveReport = ivy.resolve(md,
             new ResolveOptions().setConfs(new String[] {conf}).setOutputReport(false));
         assertTrue(resolveReport.hasError());

Modified: ant/ivy/core/trunk/test/java/org/apache/ivy/osgi/repo/BundleRepoTest.java
URL: http://svn.apache.org/viewvc/ant/ivy/core/trunk/test/java/org/apache/ivy/osgi/repo/BundleRepoTest.java?rev=1165100&r1=1165099&r2=1165100&view=diff
==============================================================================
--- ant/ivy/core/trunk/test/java/org/apache/ivy/osgi/repo/BundleRepoTest.java (original)
+++ ant/ivy/core/trunk/test/java/org/apache/ivy/osgi/repo/BundleRepoTest.java Sun Sep  4 19:37:03 2011
@@ -42,27 +42,31 @@ import org.xml.sax.SAXException;
 
 public class BundleRepoTest extends TestCase {
 
+    private File bundlerepo = new File("test/test-repo/bundlerepo");
+
+    private File ivyrepo = new File("test/test-repo/ivyrepo");
+
     public void testFS() throws Exception {
-        FSManifestIterable it = new FSManifestIterable(new File("test/test-repo/bundlerepo"), "");
-        BundleRepoDescriptor repo = new BundleRepoDescriptor(
+        FSManifestIterable it = new FSManifestIterable(bundlerepo, "");
+        BundleRepoDescriptor repo = new BundleRepoDescriptor(bundlerepo.toURI(),
                 ExecutionEnvironmentProfileProvider.getInstance());
         repo.populate(it.iterator());
 
-        BundleRepoDescriptor repo2 = OBRXMLParser.parse(new FileInputStream(
-                "test/test-repo/bundlerepo/repo.xml"));
+        BundleRepoDescriptor repo2 = OBRXMLParser.parse(bundlerepo.toURI(), new FileInputStream(
+                new File(bundlerepo, "repo.xml")));
 
         assertEquals(repo, repo2);
     }
 
     public void testFileRepo() throws Exception {
-        RepositoryManifestIterable it = new RepositoryManifestIterable(new FileRepository(new File(
-                "test/test-repo/bundlerepo").getAbsoluteFile()));
-        BundleRepoDescriptor repo = new BundleRepoDescriptor(
+        RepositoryManifestIterable it = new RepositoryManifestIterable(new FileRepository(
+                bundlerepo.getAbsoluteFile()));
+        BundleRepoDescriptor repo = new BundleRepoDescriptor(bundlerepo.toURI(),
                 ExecutionEnvironmentProfileProvider.getInstance());
         repo.populate(it.iterator());
 
-        BundleRepoDescriptor repo2 = OBRXMLParser.parse(new FileInputStream(
-                "test/test-repo/bundlerepo/repo.xml"));
+        BundleRepoDescriptor repo2 = OBRXMLParser.parse(bundlerepo.toURI(), new FileInputStream(
+                new File(bundlerepo, "repo.xml")));
 
         assertEquals(repo, repo2);
     }
@@ -70,26 +74,25 @@ public class BundleRepoTest extends Test
     public void testResolver() throws Exception {
         FileSystemResolver fileSystemResolver = new FileSystemResolver();
         fileSystemResolver.setName("test");
-        File ivyrepo = new File("test/test-repo/ivyrepo");
         fileSystemResolver.addIvyPattern(ivyrepo.getAbsolutePath()
                 + "/[organisation]/[module]/[revision]/ivy.xml");
         fileSystemResolver.addArtifactPattern(ivyrepo.getAbsolutePath()
                 + "/[organisation]/[module]/[revision]/[type]s/[artifact]-[revision].[ext]");
         fileSystemResolver.setSettings(new IvySettings());
         ResolverManifestIterable it = new ResolverManifestIterable(fileSystemResolver);
-        BundleRepoDescriptor repo = new BundleRepoDescriptor(
+        BundleRepoDescriptor repo = new BundleRepoDescriptor(ivyrepo.toURI(),
                 ExecutionEnvironmentProfileProvider.getInstance());
         repo.populate(it.iterator());
 
-        BundleRepoDescriptor repo2 = OBRXMLParser.parse(new FileInputStream(
-                "test/test-repo/ivyrepo/repo.xml"));
+        BundleRepoDescriptor repo2 = OBRXMLParser.parse(ivyrepo.toURI(), new FileInputStream(
+                new File(ivyrepo, "repo.xml")));
 
         assertEquals(repo, repo2);
     }
 
     public void testXMLSerialisation() throws SAXException, ParseException, IOException {
-        FSManifestIterable it = new FSManifestIterable(new File("test/test-repo/bundlerepo"), "");
-        BundleRepoDescriptor repo = new BundleRepoDescriptor(
+        FSManifestIterable it = new FSManifestIterable(bundlerepo, "");
+        BundleRepoDescriptor repo = new BundleRepoDescriptor(bundlerepo.toURI(),
                 ExecutionEnvironmentProfileProvider.getInstance());
         repo.populate(it.iterator());
 
@@ -108,7 +111,7 @@ public class BundleRepoTest extends Test
         OBRXMLWriter.writeManifests(it.iterator(), hd, false);
 
         ByteArrayInputStream in = new ByteArrayInputStream(out.toByteArray());
-        BundleRepoDescriptor repo2 = OBRXMLParser.parse(in);
+        BundleRepoDescriptor repo2 = OBRXMLParser.parse(bundlerepo.toURI(), in);
 
         assertEquals(repo, repo2);
     }

Modified: ant/ivy/core/trunk/test/java/org/apache/ivy/osgi/updatesite/UpdateSiteLoaderTest.java
URL: http://svn.apache.org/viewvc/ant/ivy/core/trunk/test/java/org/apache/ivy/osgi/updatesite/UpdateSiteLoaderTest.java?rev=1165100&r1=1165099&r2=1165100&view=diff
==============================================================================
--- ant/ivy/core/trunk/test/java/org/apache/ivy/osgi/updatesite/UpdateSiteLoaderTest.java (original)
+++ ant/ivy/core/trunk/test/java/org/apache/ivy/osgi/updatesite/UpdateSiteLoaderTest.java Sun Sep  4 19:37:03 2011
@@ -19,6 +19,8 @@ package org.apache.ivy.osgi.updatesite;
 
 import java.io.File;
 import java.io.IOException;
+import java.net.URI;
+import java.net.URISyntaxException;
 import java.text.ParseException;
 import java.util.Iterator;
 
@@ -50,13 +52,15 @@ public class UpdateSiteLoaderTest extend
         CacheCleaner.deleteDir(cache);
     }
 
-    public void testIvyDE() throws IOException, ParseException, SAXException {
-        RepoDescriptor site = loader.load("http://www.apache.org/dist/ant/ivyde/updatesite/");
+    public void testIvyDE() throws IOException, ParseException, SAXException, URISyntaxException {
+        RepoDescriptor site = loader.load(new URI(
+                "http://www.apache.org/dist/ant/ivyde/updatesite/"));
         assertEquals(13, site.getModules().size());
     }
 
-    public void testM2Eclipse() throws IOException, ParseException, SAXException {
-        RepoDescriptor site = loader.load("http://m2eclipse.sonatype.org/sites/m2e/");
+    public void testM2Eclipse() throws IOException, ParseException, SAXException,
+            URISyntaxException {
+        RepoDescriptor site = loader.load(new URI("http://m2eclipse.sonatype.org/sites/m2e/"));
         assertTrue(site.getModules().size() > 70);
         Iterator itModules = site.getModules().iterator();
         while (itModules.hasNext()) {
@@ -65,12 +69,13 @@ public class UpdateSiteLoaderTest extend
             assertTrue(name, name.indexOf("org.maven") != -1);
         }
 
-        site = loader.load("http://m2eclipse.sonatype.org/sites/m2e/");
+        site = loader.load(new URI("http://m2eclipse.sonatype.org/sites/m2e/"));
         assertTrue(site.getModules().size() > 70);
     }
 
-    public void _disabled_testHeliosEclipse() throws IOException, ParseException, SAXException {
-        RepoDescriptor site = loader.load("http://download.eclipse.org/releases/helios/");
+    public void _disabled_testHeliosEclipse() throws IOException, ParseException, SAXException,
+            URISyntaxException {
+        RepoDescriptor site = loader.load(new URI("http://download.eclipse.org/releases/helios/"));
         assertTrue(site.getModules().size() > 900);
     }
 



Mime
View raw message