felix-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From gno...@apache.org
Subject svn commit: r918061 - in /felix/trunk/bundlerepository/src: main/java/org/apache/felix/bundlerepository/ main/java/org/apache/felix/bundlerepository/impl/ main/java/org/apache/felix/bundlerepository/impl/wrapper/ test/java/org/apache/felix/bundlereposi...
Date Tue, 02 Mar 2010 14:56:22 GMT
Author: gnodet
Date: Tue Mar  2 14:56:21 2010
New Revision: 918061

URL: http://svn.apache.org/viewvc?rev=918061&view=rev
Log:
FELIX-2151: Use Strings instead of URLs in the API

Modified:
    felix/trunk/bundlerepository/src/main/java/org/apache/felix/bundlerepository/Repository.java
    felix/trunk/bundlerepository/src/main/java/org/apache/felix/bundlerepository/RepositoryAdmin.java
    felix/trunk/bundlerepository/src/main/java/org/apache/felix/bundlerepository/Resource.java
    felix/trunk/bundlerepository/src/main/java/org/apache/felix/bundlerepository/impl/LocalRepositoryImpl.java
    felix/trunk/bundlerepository/src/main/java/org/apache/felix/bundlerepository/impl/LocalResourceImpl.java
    felix/trunk/bundlerepository/src/main/java/org/apache/felix/bundlerepository/impl/ObrCommandImpl.java
    felix/trunk/bundlerepository/src/main/java/org/apache/felix/bundlerepository/impl/ObrURLStreamHandlerService.java
    felix/trunk/bundlerepository/src/main/java/org/apache/felix/bundlerepository/impl/RepositoryAdminImpl.java
    felix/trunk/bundlerepository/src/main/java/org/apache/felix/bundlerepository/impl/RepositoryImpl.java
    felix/trunk/bundlerepository/src/main/java/org/apache/felix/bundlerepository/impl/ResolverImpl.java
    felix/trunk/bundlerepository/src/main/java/org/apache/felix/bundlerepository/impl/ResourceImpl.java
    felix/trunk/bundlerepository/src/main/java/org/apache/felix/bundlerepository/impl/SystemRepositoryImpl.java
    felix/trunk/bundlerepository/src/main/java/org/apache/felix/bundlerepository/impl/wrapper/RepositoryAdminWrapper.java
    felix/trunk/bundlerepository/src/main/java/org/apache/felix/bundlerepository/impl/wrapper/RepositoryWrapper.java
    felix/trunk/bundlerepository/src/main/java/org/apache/felix/bundlerepository/impl/wrapper/ResourceWrapper.java
    felix/trunk/bundlerepository/src/test/java/org/apache/felix/bundlerepository/impl/FilterImplTest.java
    felix/trunk/bundlerepository/src/test/java/org/apache/felix/bundlerepository/impl/RepositoryAdminTest.java
    felix/trunk/bundlerepository/src/test/java/org/apache/felix/bundlerepository/impl/RepositoryImplTest.java
    felix/trunk/bundlerepository/src/test/java/org/apache/felix/bundlerepository/impl/ResolverImplTest.java
    felix/trunk/bundlerepository/src/test/java/org/apache/felix/bundlerepository/impl/StaxParserTest.java

Modified: felix/trunk/bundlerepository/src/main/java/org/apache/felix/bundlerepository/Repository.java
URL: http://svn.apache.org/viewvc/felix/trunk/bundlerepository/src/main/java/org/apache/felix/bundlerepository/Repository.java?rev=918061&r1=918060&r2=918061&view=diff
==============================================================================
--- felix/trunk/bundlerepository/src/main/java/org/apache/felix/bundlerepository/Repository.java
(original)
+++ felix/trunk/bundlerepository/src/main/java/org/apache/felix/bundlerepository/Repository.java
Tue Mar  2 14:56:21 2010
@@ -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.

Modified: felix/trunk/bundlerepository/src/main/java/org/apache/felix/bundlerepository/RepositoryAdmin.java
URL: http://svn.apache.org/viewvc/felix/trunk/bundlerepository/src/main/java/org/apache/felix/bundlerepository/RepositoryAdmin.java?rev=918061&r1=918060&r2=918061&view=diff
==============================================================================
--- felix/trunk/bundlerepository/src/main/java/org/apache/felix/bundlerepository/RepositoryAdmin.java
(original)
+++ felix/trunk/bundlerepository/src/main/java/org/apache/felix/bundlerepository/RepositoryAdmin.java
Tue Mar  2 14:56:21 2010
@@ -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.

Modified: felix/trunk/bundlerepository/src/main/java/org/apache/felix/bundlerepository/Resource.java
URL: http://svn.apache.org/viewvc/felix/trunk/bundlerepository/src/main/java/org/apache/felix/bundlerepository/Resource.java?rev=918061&r1=918060&r2=918061&view=diff
==============================================================================
--- felix/trunk/bundlerepository/src/main/java/org/apache/felix/bundlerepository/Resource.java
(original)
+++ felix/trunk/bundlerepository/src/main/java/org/apache/felix/bundlerepository/Resource.java
Tue Mar  2 14:56:21 2010
@@ -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();
 

Modified: felix/trunk/bundlerepository/src/main/java/org/apache/felix/bundlerepository/impl/LocalRepositoryImpl.java
URL: http://svn.apache.org/viewvc/felix/trunk/bundlerepository/src/main/java/org/apache/felix/bundlerepository/impl/LocalRepositoryImpl.java?rev=918061&r1=918060&r2=918061&view=diff
==============================================================================
--- felix/trunk/bundlerepository/src/main/java/org/apache/felix/bundlerepository/impl/LocalRepositoryImpl.java
(original)
+++ felix/trunk/bundlerepository/src/main/java/org/apache/felix/bundlerepository/impl/LocalRepositoryImpl.java
Tue Mar  2 14:56:21 2010
@@ -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()

Modified: felix/trunk/bundlerepository/src/main/java/org/apache/felix/bundlerepository/impl/LocalResourceImpl.java
URL: http://svn.apache.org/viewvc/felix/trunk/bundlerepository/src/main/java/org/apache/felix/bundlerepository/impl/LocalResourceImpl.java?rev=918061&r1=918060&r2=918061&view=diff
==============================================================================
--- felix/trunk/bundlerepository/src/main/java/org/apache/felix/bundlerepository/impl/LocalResourceImpl.java
(original)
+++ felix/trunk/bundlerepository/src/main/java/org/apache/felix/bundlerepository/impl/LocalResourceImpl.java
Tue Mar  2 14:56:21 2010
@@ -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));
             }
         }
     }

Modified: felix/trunk/bundlerepository/src/main/java/org/apache/felix/bundlerepository/impl/ObrCommandImpl.java
URL: http://svn.apache.org/viewvc/felix/trunk/bundlerepository/src/main/java/org/apache/felix/bundlerepository/impl/ObrCommandImpl.java?rev=918061&r1=918060&r2=918061&view=diff
==============================================================================
--- felix/trunk/bundlerepository/src/main/java/org/apache/felix/bundlerepository/impl/ObrCommandImpl.java
(original)
+++ felix/trunk/bundlerepository/src/main/java/org/apache/felix/bundlerepository/impl/ObrCommandImpl.java
Tue Mar  2 14:56:21 2010
@@ -157,33 +157,26 @@
         {
             while (st.hasMoreTokens())
             {
-                if (command.equals(ADDURL_CMD))
+                try
                 {
-                    try
-                    {
-                        m_repoAdmin.addRepository(new URL(st.nextToken()));
-                    }
-                    catch (Exception ex)
+                    String uri = st.nextToken();
+                    if (command.equals(ADDURL_CMD))
                     {
-                        ex.printStackTrace(err);
+                        m_repoAdmin.addRepository(uri);
                     }
-                } 
-                else if (command.equals(REFRESHURL_CMD))
-                {
-                    try
+                    else if (command.equals(REFRESHURL_CMD))
                     {
-                        URL url = new URL(st.nextToken());
-                        m_repoAdmin.removeRepository(url);
-                        m_repoAdmin.addRepository(url);
+                        m_repoAdmin.removeRepository(uri);
+                        m_repoAdmin.addRepository(uri);
                     }
-                    catch (Exception ex)
+                    else
                     {
-                        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
                 {

Modified: felix/trunk/bundlerepository/src/main/java/org/apache/felix/bundlerepository/impl/ObrURLStreamHandlerService.java
URL: http://svn.apache.org/viewvc/felix/trunk/bundlerepository/src/main/java/org/apache/felix/bundlerepository/impl/ObrURLStreamHandlerService.java?rev=918061&r1=918060&r2=918061&view=diff
==============================================================================
--- felix/trunk/bundlerepository/src/main/java/org/apache/felix/bundlerepository/impl/ObrURLStreamHandlerService.java
(original)
+++ felix/trunk/bundlerepository/src/main/java/org/apache/felix/bundlerepository/impl/ObrURLStreamHandlerService.java
Tue Mar  2 14:56:21 2010
@@ -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)

Modified: felix/trunk/bundlerepository/src/main/java/org/apache/felix/bundlerepository/impl/RepositoryAdminImpl.java
URL: http://svn.apache.org/viewvc/felix/trunk/bundlerepository/src/main/java/org/apache/felix/bundlerepository/impl/RepositoryAdminImpl.java?rev=918061&r1=918060&r2=918061&view=diff
==============================================================================
--- felix/trunk/bundlerepository/src/main/java/org/apache/felix/bundlerepository/impl/RepositoryAdminImpl.java
(original)
+++ felix/trunk/bundlerepository/src/main/java/org/apache/felix/bundlerepository/impl/RepositoryAdminImpl.java
Tue Mar  2 14:56:21 2010
@@ -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

Modified: felix/trunk/bundlerepository/src/main/java/org/apache/felix/bundlerepository/impl/RepositoryImpl.java
URL: http://svn.apache.org/viewvc/felix/trunk/bundlerepository/src/main/java/org/apache/felix/bundlerepository/impl/RepositoryImpl.java?rev=918061&r1=918060&r2=918061&view=diff
==============================================================================
--- felix/trunk/bundlerepository/src/main/java/org/apache/felix/bundlerepository/impl/RepositoryImpl.java
(original)
+++ felix/trunk/bundlerepository/src/main/java/org/apache/felix/bundlerepository/impl/RepositoryImpl.java
Tue Mar  2 14:56:21 2010
@@ -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);
                     }
                 }
             }

Modified: felix/trunk/bundlerepository/src/main/java/org/apache/felix/bundlerepository/impl/ResolverImpl.java
URL: http://svn.apache.org/viewvc/felix/trunk/bundlerepository/src/main/java/org/apache/felix/bundlerepository/impl/ResolverImpl.java?rev=918061&r1=918060&r2=918061&view=diff
==============================================================================
--- felix/trunk/bundlerepository/src/main/java/org/apache/felix/bundlerepository/impl/ResolverImpl.java
(original)
+++ felix/trunk/bundlerepository/src/main/java/org/apache/felix/bundlerepository/impl/ResolverImpl.java
Tue Mar  2 14:56:21 2010
@@ -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(

Modified: felix/trunk/bundlerepository/src/main/java/org/apache/felix/bundlerepository/impl/ResourceImpl.java
URL: http://svn.apache.org/viewvc/felix/trunk/bundlerepository/src/main/java/org/apache/felix/bundlerepository/impl/ResourceImpl.java?rev=918061&r1=918060&r2=918061&view=diff
==============================================================================
--- felix/trunk/bundlerepository/src/main/java/org/apache/felix/bundlerepository/impl/ResourceImpl.java
(original)
+++ felix/trunk/bundlerepository/src/main/java/org/apache/felix/bundlerepository/impl/ResourceImpl.java
Tue Mar  2 14:56:21 2010
@@ -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);
             }

Modified: felix/trunk/bundlerepository/src/main/java/org/apache/felix/bundlerepository/impl/SystemRepositoryImpl.java
URL: http://svn.apache.org/viewvc/felix/trunk/bundlerepository/src/main/java/org/apache/felix/bundlerepository/impl/SystemRepositoryImpl.java?rev=918061&r1=918060&r2=918061&view=diff
==============================================================================
--- felix/trunk/bundlerepository/src/main/java/org/apache/felix/bundlerepository/impl/SystemRepositoryImpl.java
(original)
+++ felix/trunk/bundlerepository/src/main/java/org/apache/felix/bundlerepository/impl/SystemRepositoryImpl.java
Tue Mar  2 14:56:21 2010
@@ -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()

Modified: felix/trunk/bundlerepository/src/main/java/org/apache/felix/bundlerepository/impl/wrapper/RepositoryAdminWrapper.java
URL: http://svn.apache.org/viewvc/felix/trunk/bundlerepository/src/main/java/org/apache/felix/bundlerepository/impl/wrapper/RepositoryAdminWrapper.java?rev=918061&r1=918060&r2=918061&view=diff
==============================================================================
--- felix/trunk/bundlerepository/src/main/java/org/apache/felix/bundlerepository/impl/wrapper/RepositoryAdminWrapper.java
(original)
+++ felix/trunk/bundlerepository/src/main/java/org/apache/felix/bundlerepository/impl/wrapper/RepositoryAdminWrapper.java
Tue Mar  2 14:56:21 2010
@@ -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() {

Modified: felix/trunk/bundlerepository/src/main/java/org/apache/felix/bundlerepository/impl/wrapper/RepositoryWrapper.java
URL: http://svn.apache.org/viewvc/felix/trunk/bundlerepository/src/main/java/org/apache/felix/bundlerepository/impl/wrapper/RepositoryWrapper.java?rev=918061&r1=918060&r2=918061&view=diff
==============================================================================
--- felix/trunk/bundlerepository/src/main/java/org/apache/felix/bundlerepository/impl/wrapper/RepositoryWrapper.java
(original)
+++ felix/trunk/bundlerepository/src/main/java/org/apache/felix/bundlerepository/impl/wrapper/RepositoryWrapper.java
Tue Mar  2 14:56:21 2010
@@ -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() {

Modified: felix/trunk/bundlerepository/src/main/java/org/apache/felix/bundlerepository/impl/wrapper/ResourceWrapper.java
URL: http://svn.apache.org/viewvc/felix/trunk/bundlerepository/src/main/java/org/apache/felix/bundlerepository/impl/wrapper/ResourceWrapper.java?rev=918061&r1=918060&r2=918061&view=diff
==============================================================================
--- felix/trunk/bundlerepository/src/main/java/org/apache/felix/bundlerepository/impl/wrapper/ResourceWrapper.java
(original)
+++ felix/trunk/bundlerepository/src/main/java/org/apache/felix/bundlerepository/impl/wrapper/ResourceWrapper.java
Tue Mar  2 14:56:21 2010
@@ -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() {

Modified: felix/trunk/bundlerepository/src/test/java/org/apache/felix/bundlerepository/impl/FilterImplTest.java
URL: http://svn.apache.org/viewvc/felix/trunk/bundlerepository/src/test/java/org/apache/felix/bundlerepository/impl/FilterImplTest.java?rev=918061&r1=918060&r2=918061&view=diff
==============================================================================
--- felix/trunk/bundlerepository/src/test/java/org/apache/felix/bundlerepository/impl/FilterImplTest.java
(original)
+++ felix/trunk/bundlerepository/src/test/java/org/apache/felix/bundlerepository/impl/FilterImplTest.java
Tue Mar  2 14:56:21 2010
@@ -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

Modified: felix/trunk/bundlerepository/src/test/java/org/apache/felix/bundlerepository/impl/RepositoryAdminTest.java
URL: http://svn.apache.org/viewvc/felix/trunk/bundlerepository/src/test/java/org/apache/felix/bundlerepository/impl/RepositoryAdminTest.java?rev=918061&r1=918060&r2=918061&view=diff
==============================================================================
--- felix/trunk/bundlerepository/src/test/java/org/apache/felix/bundlerepository/impl/RepositoryAdminTest.java
(original)
+++ felix/trunk/bundlerepository/src/test/java/org/apache/felix/bundlerepository/impl/RepositoryAdminTest.java
Tue Mar  2 14:56:21 2010
@@ -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;

Modified: felix/trunk/bundlerepository/src/test/java/org/apache/felix/bundlerepository/impl/RepositoryImplTest.java
URL: http://svn.apache.org/viewvc/felix/trunk/bundlerepository/src/test/java/org/apache/felix/bundlerepository/impl/RepositoryImplTest.java?rev=918061&r1=918060&r2=918061&view=diff
==============================================================================
--- felix/trunk/bundlerepository/src/test/java/org/apache/felix/bundlerepository/impl/RepositoryImplTest.java
(original)
+++ felix/trunk/bundlerepository/src/test/java/org/apache/felix/bundlerepository/impl/RepositoryImplTest.java
Tue Mar  2 14:56:21 2010
@@ -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;

Modified: felix/trunk/bundlerepository/src/test/java/org/apache/felix/bundlerepository/impl/ResolverImplTest.java
URL: http://svn.apache.org/viewvc/felix/trunk/bundlerepository/src/test/java/org/apache/felix/bundlerepository/impl/ResolverImplTest.java?rev=918061&r1=918060&r2=918061&view=diff
==============================================================================
--- felix/trunk/bundlerepository/src/test/java/org/apache/felix/bundlerepository/impl/ResolverImplTest.java
(original)
+++ felix/trunk/bundlerepository/src/test/java/org/apache/felix/bundlerepository/impl/ResolverImplTest.java
Tue Mar  2 14:56:21 2010
@@ -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;

Modified: felix/trunk/bundlerepository/src/test/java/org/apache/felix/bundlerepository/impl/StaxParserTest.java
URL: http://svn.apache.org/viewvc/felix/trunk/bundlerepository/src/test/java/org/apache/felix/bundlerepository/impl/StaxParserTest.java?rev=918061&r1=918060&r2=918061&view=diff
==============================================================================
--- felix/trunk/bundlerepository/src/test/java/org/apache/felix/bundlerepository/impl/StaxParserTest.java
(original)
+++ felix/trunk/bundlerepository/src/test/java/org/apache/felix/bundlerepository/impl/StaxParserTest.java
Tue Mar  2 14:56:21 2010
@@ -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;



Mime
View raw message