FELIX-2151: Use Strings instead of URLs in the API

git-svn-id: https://svn.apache.org/repos/asf/felix/trunk@918061 13f79535-47bb-0310-9956-ffa450edef68
diff --git a/bundlerepository/src/main/java/org/apache/felix/bundlerepository/Repository.java b/bundlerepository/src/main/java/org/apache/felix/bundlerepository/Repository.java
index 9ee805b..6794222 100644
--- a/bundlerepository/src/main/java/org/apache/felix/bundlerepository/Repository.java
+++ b/bundlerepository/src/main/java/org/apache/felix/bundlerepository/Repository.java
@@ -39,8 +39,6 @@
 // turn this draft into an official specification.  
 package org.apache.felix.bundlerepository;
 
-import java.net.URL;
-
 /**
  * Represents a repository.
  * 
@@ -48,11 +46,22 @@
  */
 public interface Repository
 {
+
+    /**
+     * URI identifying the system repository
+     */
+    String SYSTEM = "system";
+
+    /**
+     * URI identiying the local repository
+     */
+    String LOCAL = "local";
+
     /**
      * Return the associated URL for the repository.
      * 
      */
-    URL getURL();
+    String getURI();
 
     /**
      * Return the resources for this repository.
diff --git a/bundlerepository/src/main/java/org/apache/felix/bundlerepository/RepositoryAdmin.java b/bundlerepository/src/main/java/org/apache/felix/bundlerepository/RepositoryAdmin.java
index 5b69004..f43ba62 100644
--- a/bundlerepository/src/main/java/org/apache/felix/bundlerepository/RepositoryAdmin.java
+++ b/bundlerepository/src/main/java/org/apache/felix/bundlerepository/RepositoryAdmin.java
@@ -119,9 +119,20 @@
 
     /**
      * Add a new repository to the federation.
-     * 
+     *
      * The url must point to a repository XML file.
-     * 
+     *
+     * @param repository
+     * @return
+     * @throws Exception
+     */
+    Repository addRepository(String repository) throws Exception;
+
+    /**
+     * Add a new repository to the federation.
+     *
+     * The url must point to a repository XML file.
+     *
      * @param repository
      * @return
      * @throws Exception
@@ -136,7 +147,7 @@
      * @param repository
      * @return
      */
-    boolean removeRepository(URL repository);
+    boolean removeRepository(String repository);
 
     /**
      * List all the repositories.
diff --git a/bundlerepository/src/main/java/org/apache/felix/bundlerepository/Resource.java b/bundlerepository/src/main/java/org/apache/felix/bundlerepository/Resource.java
index 9af2de6..1208b31 100644
--- a/bundlerepository/src/main/java/org/apache/felix/bundlerepository/Resource.java
+++ b/bundlerepository/src/main/java/org/apache/felix/bundlerepository/Resource.java
@@ -39,7 +39,6 @@
 // turn this draft into an official specification.  
 package org.apache.felix.bundlerepository;
 
-import java.net.URL;
 import java.util.Map;
 
 import org.osgi.framework.Version;
@@ -54,17 +53,17 @@
  */
 public interface Resource
 {
-    final String LICENSE_URL = "license";
+    final String LICENSE_URI = "license";
 
     final String DESCRIPTION = "description";
 
-    final String DOCUMENTATION_URL = "documentation";
+    final String DOCUMENTATION_URI = "documentation";
 
     final String COPYRIGHT = "copyright";
 
-    final String SOURCE_URL = "source";
+    final String SOURCE_URI = "source";
 
-    final String JAVADOC_URL = "javadoc";
+    final String JAVADOC_URI = "javadoc";
 
     final String SYMBOLIC_NAME = "symbolicname";
 
@@ -92,7 +91,7 @@
 
     String getId();
 
-    URL getURL();
+    String getURI();
 
     Requirement[] getRequirements();
 
diff --git a/bundlerepository/src/main/java/org/apache/felix/bundlerepository/impl/LocalRepositoryImpl.java b/bundlerepository/src/main/java/org/apache/felix/bundlerepository/impl/LocalRepositoryImpl.java
index 038ff10..deb984d 100644
--- a/bundlerepository/src/main/java/org/apache/felix/bundlerepository/impl/LocalRepositoryImpl.java
+++ b/bundlerepository/src/main/java/org/apache/felix/bundlerepository/impl/LocalRepositoryImpl.java
@@ -18,7 +18,6 @@
  */
 package org.apache.felix.bundlerepository.impl;
 
-import java.net.URL;
 import java.util.HashMap;
 import java.util.Map;
 
@@ -123,9 +122,9 @@
         m_context.removeServiceListener(this);
     }
 
-    public URL getURL()
+    public String getURI()
     {
-        return null;
+        return LOCAL;
     }
 
     public String getName()
diff --git a/bundlerepository/src/main/java/org/apache/felix/bundlerepository/impl/LocalResourceImpl.java b/bundlerepository/src/main/java/org/apache/felix/bundlerepository/impl/LocalResourceImpl.java
index 72fd15e..17c3a84 100644
--- a/bundlerepository/src/main/java/org/apache/felix/bundlerepository/impl/LocalResourceImpl.java
+++ b/bundlerepository/src/main/java/org/apache/felix/bundlerepository/impl/LocalResourceImpl.java
@@ -176,7 +176,7 @@
             }
             else if (key.equalsIgnoreCase("Bundle-Source"))
             {
-                put(SOURCE_URL, (String) dict.get(key));
+                put(SOURCE_URI, (String) dict.get(key));
             }
             else if (key.equalsIgnoreCase(Constants.BUNDLE_DESCRIPTION))
             {
@@ -184,7 +184,7 @@
             }
             else if (key.equalsIgnoreCase(Constants.BUNDLE_DOCURL))
             {
-                put(DOCUMENTATION_URL, (String) dict.get(key));
+                put(DOCUMENTATION_URI, (String) dict.get(key));
             }
             else if (key.equalsIgnoreCase(Constants.BUNDLE_COPYRIGHT))
             {
@@ -192,7 +192,7 @@
             }
             else if (key.equalsIgnoreCase("Bundle-License"))
             {
-                put(LICENSE_URL, (String) dict.get(key));
+                put(LICENSE_URI, (String) dict.get(key));
             }
         }
     }
diff --git a/bundlerepository/src/main/java/org/apache/felix/bundlerepository/impl/ObrCommandImpl.java b/bundlerepository/src/main/java/org/apache/felix/bundlerepository/impl/ObrCommandImpl.java
index 6637974..47c2e29 100644
--- a/bundlerepository/src/main/java/org/apache/felix/bundlerepository/impl/ObrCommandImpl.java
+++ b/bundlerepository/src/main/java/org/apache/felix/bundlerepository/impl/ObrCommandImpl.java
@@ -157,33 +157,26 @@
         {
             while (st.hasMoreTokens())
             {
-                if (command.equals(ADDURL_CMD))
+                try
                 {
-                    try
+                    String uri = st.nextToken();
+                    if (command.equals(ADDURL_CMD))
                     {
-                        m_repoAdmin.addRepository(new URL(st.nextToken()));
+                        m_repoAdmin.addRepository(uri);
                     }
-                    catch (Exception ex)
+                    else if (command.equals(REFRESHURL_CMD))
                     {
-                        ex.printStackTrace(err);
+                        m_repoAdmin.removeRepository(uri);
+                        m_repoAdmin.addRepository(uri);
                     }
-                } 
-                else if (command.equals(REFRESHURL_CMD))
-                {
-                    try
+                    else
                     {
-                        URL url = new URL(st.nextToken());
-                        m_repoAdmin.removeRepository(url);
-                        m_repoAdmin.addRepository(url);
-                    }
-                    catch (Exception ex)
-                    {
-                        ex.printStackTrace(err);
+                        m_repoAdmin.removeRepository(uri);
                     }
                 }
-                else
+                catch (Exception ex)
                 {
-                    m_repoAdmin.removeRepository(new URL(st.nextToken()));
+                    ex.printStackTrace(err);
                 }
             }
         }
@@ -194,7 +187,7 @@
             {
                 for (int i = 0; i < repos.length; i++)
                 {
-                    out.println(repos[i].getURL());
+                    out.println(repos[i].getURI());
                 }
             }
             else
@@ -444,11 +437,11 @@
             }
             else
             {
-                URL srcURL = (URL) resource.getProperties().get(Resource.SOURCE_URL);
-                if (srcURL != null)
+                String srcURI = (String) resource.getProperties().get(Resource.SOURCE_URI);
+                if (srcURI != null)
                 {
                     FileUtil.downloadSource(
-                        out, err, srcURL, pc.getDirectory(), pc.isExtract());
+                        out, err, new URL(srcURI), pc.getDirectory(), pc.isExtract());
                 }
                 else
                 {
diff --git a/bundlerepository/src/main/java/org/apache/felix/bundlerepository/impl/ObrURLStreamHandlerService.java b/bundlerepository/src/main/java/org/apache/felix/bundlerepository/impl/ObrURLStreamHandlerService.java
index 35a26ca..a99d4eb 100644
--- a/bundlerepository/src/main/java/org/apache/felix/bundlerepository/impl/ObrURLStreamHandlerService.java
+++ b/bundlerepository/src/main/java/org/apache/felix/bundlerepository/impl/ObrURLStreamHandlerService.java
@@ -183,7 +183,7 @@
         ResourceSelectionStrategy strategy = new NewestSelectionStrategy(m_logger);
         Resource selected = strategy.selectOne(Version.emptyVersion, discoverResources);
 
-        return selected.getURL();
+        return new URL(selected.getURI());
     }
 
     private boolean validateFilter(String filter) {
@@ -227,7 +227,7 @@
         Resource selected = strategy.selectOne(
             Version.parseVersion(version), discoverResources);
 
-        return selected.getURL();
+        return new URL(selected.getURI());
     }
 
     private ResourceSelectionStrategy getStrategy(String strategy)
diff --git a/bundlerepository/src/main/java/org/apache/felix/bundlerepository/impl/RepositoryAdminImpl.java b/bundlerepository/src/main/java/org/apache/felix/bundlerepository/impl/RepositoryAdminImpl.java
index f169eed..09eb837 100644
--- a/bundlerepository/src/main/java/org/apache/felix/bundlerepository/impl/RepositoryAdminImpl.java
+++ b/bundlerepository/src/main/java/org/apache/felix/bundlerepository/impl/RepositoryAdminImpl.java
@@ -18,7 +18,6 @@
  */
 package org.apache.felix.bundlerepository.impl;
 
-import java.net.MalformedURLException;
 import java.net.URL;
 import java.util.ArrayList;
 import java.util.Arrays;
@@ -45,7 +44,6 @@
     private final Logger m_logger;
     private final SystemRepositoryImpl m_system;
     private final LocalRepositoryImpl m_local;
-    private List m_urlList = new ArrayList();
     private Map m_repoMap = new HashMap();
     private boolean m_initialized = false;
 
@@ -78,6 +76,11 @@
         m_local.dispose();
     }
 
+    public Repository addRepository(String uri) throws Exception
+    {
+        return addRepository(new URL(uri));
+    }
+
     public Repository addRepository(URL url) throws Exception
     {
         return addRepository(url, Integer.MAX_VALUE);
@@ -85,40 +88,34 @@
 
     public synchronized RepositoryImpl addRepository(URL url, int hopCount) throws Exception
     {
-        if (!m_urlList.contains(url))
-        {
-            m_urlList.add(url);
-        }
+        initialize();
 
         // If the repository URL is a duplicate, then we will just
         // replace the existing repository object with a new one,
         // which is effectively the same as refreshing the repository.
         RepositoryImpl repo = new RepositoryImpl(this, url, hopCount, m_logger);
-        m_repoMap.put(url, repo);
+        m_repoMap.put(url.toExternalForm(), repo);
         return repo;
     }
 
-    public synchronized boolean removeRepository(URL url)
+    public synchronized boolean removeRepository(String uri)
     {
-        m_repoMap.remove(url);
-        return (m_urlList.remove(url)) ? true : false;
+        initialize();
+
+        return m_repoMap.remove(uri) != null;
     }
 
     public synchronized Repository[] listRepositories()
     {
-        if (!m_initialized)
-        {
-            initialize();
-        }
+        initialize();
+
         return (Repository[]) m_repoMap.values().toArray(new Repository[m_repoMap.size()]);
     }
 
     public synchronized Resolver resolver()
     {
-        if (!m_initialized)
-        {
-            initialize();
-        }
+        initialize();
+
         List repositories = new ArrayList();
         repositories.add(m_system);
         repositories.add(m_local);
@@ -128,10 +125,8 @@
 
     public synchronized Resolver resolver(Repository[] repositories)
     {
-        if (!m_initialized)
-        {
-            initialize();
-        }
+        initialize();
+
         if (repositories == null)
         {
             return resolver();
@@ -141,10 +136,7 @@
 
     public synchronized Resource[] discoverResources(String filterExpr) throws InvalidSyntaxException
     {
-        if (!m_initialized)
-        {
-            initialize();
-        }
+        initialize();
 
         Filter filter = filterExpr != null ? filter(filterExpr) : null;
         Resource[] resources;
@@ -172,10 +164,7 @@
 
     public synchronized Resource[] discoverResources(Requirement[] requirements)
     {
-        if (!m_initialized)
-        {
-            initialize();
-        }
+        initialize();
 
         Resource[] resources = null;
         MapToDictionary dict = new MapToDictionary(null);
@@ -259,58 +248,36 @@
 
     private void initialize()
     {
+        if (m_initialized)
+        {
+            return;
+        }
         m_initialized = true;
 
-        // Initialize the repository URL list if it is currently empty.
-        if (m_urlList.size() == 0)
+        // First check the repository URL config property.
+        String urlStr = m_context.getProperty(REPOSITORY_URL_PROP);
+        if (urlStr != null)
         {
-            // First check the repository URL config property.
-            String urlStr = m_context.getProperty(REPOSITORY_URL_PROP);
-            if (urlStr != null)
+            StringTokenizer st = new StringTokenizer(urlStr);
+            if (st.countTokens() > 0)
             {
-                StringTokenizer st = new StringTokenizer(urlStr);
-                if (st.countTokens() > 0)
+                while (st.hasMoreTokens())
                 {
-                    while (st.hasMoreTokens())
+                    final String token = st.nextToken();
+                    try
                     {
-                        final String token = st.nextToken();
-                        try
-                        {
-                            m_urlList.add(new URL(token));
-                        }
-                        catch (MalformedURLException ex)
-                        {
-                            m_logger.log(
-                                Logger.LOG_WARNING,
-                                "Repository url " + token + " cannot be used. Skipped.",
-                                ex);
-                        }
+                        addRepository(token);
+                    }
+                    catch (Exception ex)
+                    {
+                        m_logger.log(
+                            Logger.LOG_WARNING,
+                            "Repository url " + token + " cannot be used. Skipped.",
+                            ex);
                     }
                 }
             }
         }
 
-        m_repoMap.clear();
-
-        for (int i = 0; i < m_urlList.size(); i++)
-        {
-            URL url = (URL) m_urlList.get(i);
-            try
-            {
-                Repository repo = new RepositoryImpl(this, url, m_logger);
-                if (repo != null)
-                {
-                    m_repoMap.put(url, repo);
-                }
-            }
-            catch (Exception ex)
-            {
-                m_logger.log(
-                    Logger.LOG_WARNING,
-                    "RepositoryAdminImpl: Exception creating repository " + url.toExternalForm()
-                        + ". Repository is skipped.",
-                    ex);
-            }
-        }
     }
 }
\ No newline at end of file
diff --git a/bundlerepository/src/main/java/org/apache/felix/bundlerepository/impl/RepositoryImpl.java b/bundlerepository/src/main/java/org/apache/felix/bundlerepository/impl/RepositoryImpl.java
index 53d414a..db8af53 100644
--- a/bundlerepository/src/main/java/org/apache/felix/bundlerepository/impl/RepositoryImpl.java
+++ b/bundlerepository/src/main/java/org/apache/felix/bundlerepository/impl/RepositoryImpl.java
@@ -50,7 +50,7 @@
 
     private String m_name = null;
     private long m_lastmodified = 0;
-    private URL m_url = null;
+    private String m_uri = null;
     private final Logger m_logger;
     private Resource[] m_resources = null;
     private Referral[] m_referrals = null;
@@ -63,7 +63,7 @@
     public RepositoryImpl(Resource[] resources)
     {
         m_repoAdmin = null;
-        m_url = null;
+        m_uri = null;
         m_logger = null;
         m_resources = resources;
         m_lastmodified = System.currentTimeMillis();
@@ -79,7 +79,7 @@
         throws Exception
     {
         m_repoAdmin = repoAdmin;
-        m_url = url;
+        m_uri = url.toExternalForm();
         m_logger = logger;
         m_resourceList = new ArrayList();
         try
@@ -99,14 +99,14 @@
         }
     }
 
-    public URL getURL()
+    public String getURI()
     {
-        return m_url;
+        return m_uri;
     }
 
-    protected void setURL(URL url)
+    protected void setURI(String uri)
     {
-        m_url = url;
+        m_uri = uri;
     }
 
     public Resource[] getResources()
@@ -193,22 +193,23 @@
 
         try
         {
+            URL url = new URL(m_uri);
             // Do it the manual way to have a chance to
             // set request properties as proxy auth (EW).
-            URLConnection conn = m_url.openConnection();
+            URLConnection conn = url.openConnection();
 
             // Support for http proxy authentication
             String auth = System.getProperty("http.proxyAuth");
             if ((auth != null) && (auth.length() > 0))
             {
-                if ("http".equals(m_url.getProtocol()) || "https".equals(m_url.getProtocol()))
+                if ("http".equals(url.getProtocol()) || "https".equals(url.getProtocol()))
                 {
                     String base64 = Util.base64Encode(auth);
                     conn.setRequestProperty("Proxy-Authorization", "Basic " + base64);
                 }
             }
 
-            if (m_url.getPath().endsWith(".zip"))
+            if (url.getPath().endsWith(".zip"))
             {
                 ZipInputStream zin = new ZipInputStream(conn.getInputStream());
                 ZipEntry entry = zin.getNextEntry();
@@ -240,10 +241,10 @@
                     {
                         Referral referral = m_referrals[i];
 
-                        URL url = new URL(getURL(), referral.getUrl());
+                        URL referralUrl = new URL(url, referral.getUrl());
                         hopCount = (referral.getDepth() > hopCount) ? hopCount : referral.getDepth();
 
-                        m_repoAdmin.addRepository(url, hopCount);
+                        m_repoAdmin.addRepository(referralUrl, hopCount);
                     }
                 }
             }
diff --git a/bundlerepository/src/main/java/org/apache/felix/bundlerepository/impl/ResolverImpl.java b/bundlerepository/src/main/java/org/apache/felix/bundlerepository/impl/ResolverImpl.java
index 1bdb1da..d4e19e3 100644
--- a/bundlerepository/src/main/java/org/apache/felix/bundlerepository/impl/ResolverImpl.java
+++ b/bundlerepository/src/main/java/org/apache/felix/bundlerepository/impl/ResolverImpl.java
@@ -586,7 +586,7 @@
                             localResource.getBundle().stop();
                         }
                         
-                        localResource.getBundle().update(deployResources[i].getURL().openStream());
+                        localResource.getBundle().update(new URL(deployResources[i].getURI()).openStream());
 
                         // If necessary, save the updated bundle to be
                         // started later.
@@ -618,7 +618,7 @@
                     // bundle JAR URL for the bundle location, since this will
                     // limit OBR's ability to manipulate bundle versions. Instead,
                     // use a unique timestamp as the bundle location.
-                    URL url = deployResources[i].getURL();
+                    URL url = new URL(deployResources[i].getURI());
                     if (url != null)
                     {
                         Bundle bundle = m_context.installBundle(
diff --git a/bundlerepository/src/main/java/org/apache/felix/bundlerepository/impl/ResourceImpl.java b/bundlerepository/src/main/java/org/apache/felix/bundlerepository/impl/ResourceImpl.java
index 75f33d6..fe0d7b0 100644
--- a/bundlerepository/src/main/java/org/apache/felix/bundlerepository/impl/ResourceImpl.java
+++ b/bundlerepository/src/main/java/org/apache/felix/bundlerepository/impl/ResourceImpl.java
@@ -18,8 +18,8 @@
  */
 package org.apache.felix.bundlerepository.impl;
 
-import java.net.MalformedURLException;
-import java.net.URL;
+import java.net.URI;
+import java.net.URISyntaxException;
 import java.util.*;
 
 import org.apache.felix.bundlerepository.Capability;
@@ -102,7 +102,7 @@
     {
         if (!m_converted)
         {
-            convertURItoURL();
+            convertURIs();
         }
         return m_map;
     }
@@ -129,13 +129,13 @@
         return v;
     }
 
-    public URL getURL()
+    public String getURI()
     {
         if (!m_converted)
         {
-            convertURItoURL();
+            convertURIs();
         }
-        return (URL) m_map.get(Resource.URI);
+        return (String) m_map.get(Resource.URI);
     }
 
     public Requirement[] getRequirements()
@@ -196,19 +196,19 @@
         // need to defer setting the actual URL value until they
         // are used so that we will know our repository and its
         // base URL.
-        if (key.equals(LICENSE_URL))
+        if (key.equals(LICENSE_URI))
         {
             m_licenseURI = (String) value;
         }
-        else if (key.equals(DOCUMENTATION_URL))
+        else if (key.equals(DOCUMENTATION_URI))
         {
             m_docURI = (String) value;
         }
-        else if (key.equals(SOURCE_URL))
+        else if (key.equals(SOURCE_URI))
         {
             m_sourceURI = (String) value;
         }
-        else if (key.equals(JAVADOC_URL))
+        else if (key.equals(JAVADOC_URI))
         {
             m_javadocURI = (String) value;
         }
@@ -244,36 +244,36 @@
         return null;
     }
 
-    private void convertURItoURL()
+    private void convertURIs()
     {
         if (m_repo != null)
         {
             try
             {
-                URL base = m_repo.getURL();
+                URI base = m_repo.getURI() != null ? new URI(m_repo.getURI()) : null;
                 if (m_resourceURI != null)
                 {
-                    m_map.put(URI, new URL(base, m_resourceURI));
+                    m_map.put(URI, base != null ? base.resolve(m_resourceURI).toString() : m_resourceURI);
                 }
                 if (m_docURI != null)
                 {
-                    m_map.put(DOCUMENTATION_URL, new URL(base, m_docURI));
+                    m_map.put(DOCUMENTATION_URI, base != null ? base.resolve(m_docURI).toString() : m_docURI);
                 }
                 if (m_licenseURI != null)
                 {
-                    m_map.put(LICENSE_URL, new URL(base, m_licenseURI));
+                    m_map.put(LICENSE_URI, base != null ? base.resolve(m_licenseURI).toString() : m_licenseURI);
                 }
                 if (m_sourceURI != null)
                 {
-                    m_map.put(SOURCE_URL, new URL(base, m_sourceURI));
+                    m_map.put(SOURCE_URI, base != null ? base.resolve(m_sourceURI).toString() : m_sourceURI);
                 }
                 if (m_javadocURI != null)
                 {
-                    m_map.put(JAVADOC_URL, new URL(base, m_javadocURI));
+                    m_map.put(JAVADOC_URI, base != null ? base.resolve(m_javadocURI).toString() : m_javadocURI);
                 }
                 m_converted = true;
             }
-            catch (MalformedURLException ex)
+            catch (URISyntaxException ex)
             {
                 ex.printStackTrace(System.err);
             }
diff --git a/bundlerepository/src/main/java/org/apache/felix/bundlerepository/impl/SystemRepositoryImpl.java b/bundlerepository/src/main/java/org/apache/felix/bundlerepository/impl/SystemRepositoryImpl.java
index 05a9e5a..078bb8e 100644
--- a/bundlerepository/src/main/java/org/apache/felix/bundlerepository/impl/SystemRepositoryImpl.java
+++ b/bundlerepository/src/main/java/org/apache/felix/bundlerepository/impl/SystemRepositoryImpl.java
@@ -18,8 +18,6 @@
  */
 package org.apache.felix.bundlerepository.impl;
 
-import java.net.URL;
-
 import org.apache.felix.bundlerepository.Resource;
 import org.osgi.framework.BundleContext;
 import org.osgi.framework.InvalidSyntaxException;
@@ -49,9 +47,9 @@
         }
     }
 
-    public URL getURL()
+    public String getURI()
     {
-        return null;
+        return SYSTEM;
     }
 
     public Resource[] getResources()
diff --git a/bundlerepository/src/main/java/org/apache/felix/bundlerepository/impl/wrapper/RepositoryAdminWrapper.java b/bundlerepository/src/main/java/org/apache/felix/bundlerepository/impl/wrapper/RepositoryAdminWrapper.java
index 9c6379c..79655bc 100644
--- a/bundlerepository/src/main/java/org/apache/felix/bundlerepository/impl/wrapper/RepositoryAdminWrapper.java
+++ b/bundlerepository/src/main/java/org/apache/felix/bundlerepository/impl/wrapper/RepositoryAdminWrapper.java
@@ -50,7 +50,7 @@
     }
 
     public boolean removeRepository(URL repository) {
-        return admin.removeRepository(repository);
+        return admin.removeRepository(repository.toExternalForm());
     }
 
     public org.osgi.service.obr.Repository[] listRepositories() {
diff --git a/bundlerepository/src/main/java/org/apache/felix/bundlerepository/impl/wrapper/RepositoryWrapper.java b/bundlerepository/src/main/java/org/apache/felix/bundlerepository/impl/wrapper/RepositoryWrapper.java
index cb1dff7..8b1f342 100644
--- a/bundlerepository/src/main/java/org/apache/felix/bundlerepository/impl/wrapper/RepositoryWrapper.java
+++ b/bundlerepository/src/main/java/org/apache/felix/bundlerepository/impl/wrapper/RepositoryWrapper.java
@@ -18,6 +18,7 @@
  */
 package org.apache.felix.bundlerepository.impl.wrapper;
 
+import java.net.MalformedURLException;
 import java.net.URL;
 
 import org.apache.felix.bundlerepository.Repository;
@@ -32,7 +33,11 @@
     }
 
     public URL getURL() {
-        return repository.getURL();
+        try {
+            return new URL(repository.getURI());
+        } catch (MalformedURLException e) {
+            throw new RuntimeException(e);
+        }
     }
 
     public org.osgi.service.obr.Resource[] getResources() {
diff --git a/bundlerepository/src/main/java/org/apache/felix/bundlerepository/impl/wrapper/ResourceWrapper.java b/bundlerepository/src/main/java/org/apache/felix/bundlerepository/impl/wrapper/ResourceWrapper.java
index 0dd0184..6ef61b8 100644
--- a/bundlerepository/src/main/java/org/apache/felix/bundlerepository/impl/wrapper/ResourceWrapper.java
+++ b/bundlerepository/src/main/java/org/apache/felix/bundlerepository/impl/wrapper/ResourceWrapper.java
@@ -18,6 +18,7 @@
  */
 package org.apache.felix.bundlerepository.impl.wrapper;
 
+import java.net.MalformedURLException;
 import java.net.URL;
 import java.util.Map;
 
@@ -56,7 +57,11 @@
     }
 
     public URL getURL() {
-        return resource.getURL();
+        try {
+            return new URL(resource.getURI());
+        } catch (MalformedURLException e) {
+            throw new RuntimeException(e);
+        }
     }
 
     public Requirement[] getRequirements() {
diff --git a/bundlerepository/src/test/java/org/apache/felix/bundlerepository/impl/FilterImplTest.java b/bundlerepository/src/test/java/org/apache/felix/bundlerepository/impl/FilterImplTest.java
index 8fd48d2..e41fe4f 100644
--- a/bundlerepository/src/test/java/org/apache/felix/bundlerepository/impl/FilterImplTest.java
+++ b/bundlerepository/src/test/java/org/apache/felix/bundlerepository/impl/FilterImplTest.java
@@ -22,7 +22,6 @@
 import java.util.Hashtable;
 
 import junit.framework.TestCase;
-import org.apache.felix.bundlerepository.impl.FilterImpl;
 import org.osgi.framework.Version;
 
 public class FilterImplTest extends TestCase
diff --git a/bundlerepository/src/test/java/org/apache/felix/bundlerepository/impl/RepositoryAdminTest.java b/bundlerepository/src/test/java/org/apache/felix/bundlerepository/impl/RepositoryAdminTest.java
index 3ca41e3..2f6e4ae 100644
--- a/bundlerepository/src/test/java/org/apache/felix/bundlerepository/impl/RepositoryAdminTest.java
+++ b/bundlerepository/src/test/java/org/apache/felix/bundlerepository/impl/RepositoryAdminTest.java
@@ -23,10 +23,6 @@
 
 import junit.framework.TestCase;
 import org.apache.felix.bundlerepository.Resource;
-import org.apache.felix.bundlerepository.impl.FilterImpl;
-import org.apache.felix.bundlerepository.impl.Logger;
-import org.apache.felix.bundlerepository.impl.RepositoryAdminImpl;
-import org.apache.felix.bundlerepository.impl.RepositoryImpl;
 import org.easymock.Capture;
 import org.easymock.EasyMock;
 import org.easymock.IAnswer;
@@ -82,7 +78,7 @@
         org.apache.felix.bundlerepository.Repository[] repos = repoAdmin.listRepositories();
         for (int i = 0; repos != null && i < repos.length; i++)
         {
-            repoAdmin.removeRepository(repos[i].getURL());
+            repoAdmin.removeRepository(repos[i].getURI());
         }
 
         return repoAdmin;
diff --git a/bundlerepository/src/test/java/org/apache/felix/bundlerepository/impl/RepositoryImplTest.java b/bundlerepository/src/test/java/org/apache/felix/bundlerepository/impl/RepositoryImplTest.java
index 6facb80..bcf1e76 100644
--- a/bundlerepository/src/test/java/org/apache/felix/bundlerepository/impl/RepositoryImplTest.java
+++ b/bundlerepository/src/test/java/org/apache/felix/bundlerepository/impl/RepositoryImplTest.java
@@ -122,7 +122,7 @@
         Repository[] repos = repoAdmin.listRepositories();
         for (int i = 0; repos != null && i < repos.length; i++)
         {
-            repoAdmin.removeRepository(repos[i].getURL());
+            repoAdmin.removeRepository(repos[i].getURI());
         }
 
         return repoAdmin;
diff --git a/bundlerepository/src/test/java/org/apache/felix/bundlerepository/impl/ResolverImplTest.java b/bundlerepository/src/test/java/org/apache/felix/bundlerepository/impl/ResolverImplTest.java
index 37f4cb4..5bb7381 100644
--- a/bundlerepository/src/test/java/org/apache/felix/bundlerepository/impl/ResolverImplTest.java
+++ b/bundlerepository/src/test/java/org/apache/felix/bundlerepository/impl/ResolverImplTest.java
@@ -25,10 +25,6 @@
 
 import org.apache.felix.bundlerepository.Requirement;
 import org.apache.felix.bundlerepository.Resource;
-import org.apache.felix.bundlerepository.impl.FilterImpl;
-import org.apache.felix.bundlerepository.impl.Logger;
-import org.apache.felix.bundlerepository.impl.RepositoryAdminImpl;
-import org.apache.felix.bundlerepository.impl.RepositoryImpl;
 import org.easymock.Capture;
 import org.easymock.EasyMock;
 import org.easymock.IAnswer;
@@ -149,7 +145,7 @@
         Repository[] repos = repoAdmin.listRepositories();
         for (int i = 0; repos != null && i < repos.length; i++)
         {
-            repoAdmin.removeRepository(repos[i].getURL());
+            repoAdmin.removeRepository(repos[i].getURI());
         }
 
         return repoAdmin;
diff --git a/bundlerepository/src/test/java/org/apache/felix/bundlerepository/impl/StaxParserTest.java b/bundlerepository/src/test/java/org/apache/felix/bundlerepository/impl/StaxParserTest.java
index 1a5139e..9223871 100644
--- a/bundlerepository/src/test/java/org/apache/felix/bundlerepository/impl/StaxParserTest.java
+++ b/bundlerepository/src/test/java/org/apache/felix/bundlerepository/impl/StaxParserTest.java
@@ -24,11 +24,6 @@
 import junit.framework.TestCase;
 import org.apache.felix.bundlerepository.Resolver;
 import org.apache.felix.bundlerepository.Resource;
-import org.apache.felix.bundlerepository.impl.FilterImpl;
-import org.apache.felix.bundlerepository.impl.Logger;
-import org.apache.felix.bundlerepository.impl.RepositoryAdminImpl;
-import org.apache.felix.bundlerepository.impl.RepositoryImpl;
-import org.apache.felix.bundlerepository.impl.StaxParser;
 import org.easymock.Capture;
 import org.easymock.EasyMock;
 import org.easymock.IAnswer;
@@ -153,7 +148,7 @@
         Repository[] repos = repoAdmin.listRepositories();
         for (int i = 0; repos != null && i < repos.length; i++)
         {
-            repoAdmin.removeRepository(repos[i].getURL());
+            repoAdmin.removeRepository(repos[i].getURI());
         }
 
         return repoAdmin;