You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@felix.apache.org by mc...@apache.org on 2008/01/27 08:36:51 UTC

svn commit: r615560 - /felix/trunk/maven-obr-plugin/src/main/java/org/apache/felix/obr/plugin/ObrUtils.java

Author: mcculls
Date: Sat Jan 26 23:36:49 2008
New Revision: 615560

URL: http://svn.apache.org/viewvc?rev=615560&view=rev
Log:
Add helper method to relativize repository URIs

Modified:
    felix/trunk/maven-obr-plugin/src/main/java/org/apache/felix/obr/plugin/ObrUtils.java

Modified: felix/trunk/maven-obr-plugin/src/main/java/org/apache/felix/obr/plugin/ObrUtils.java
URL: http://svn.apache.org/viewvc/felix/trunk/maven-obr-plugin/src/main/java/org/apache/felix/obr/plugin/ObrUtils.java?rev=615560&r1=615559&r2=615560&view=diff
==============================================================================
--- felix/trunk/maven-obr-plugin/src/main/java/org/apache/felix/obr/plugin/ObrUtils.java (original)
+++ felix/trunk/maven-obr-plugin/src/main/java/org/apache/felix/obr/plugin/ObrUtils.java Sat Jan 26 23:36:49 2008
@@ -100,4 +100,27 @@
         }
         return null;
     }
+
+
+    /**
+     * @param repositoryXml URI pointing to repository.xml
+     * @param bundlePath local path to bundle jarfile
+     * @return relative path to bundle jarfile
+     */
+    public static String relativize( URI repositoryXml, String bundlePath )
+    {
+        try
+        {
+            String repositoryPath = repositoryXml.getPath();
+            int index = repositoryPath.lastIndexOf( '/' );
+
+            URI rootURI = new URI( null, repositoryPath.substring( 0, index ), null );
+
+            return rootURI.relativize( new URI( null, bundlePath, null ) ).toASCIIString();
+        }
+        catch ( Exception e )
+        {
+            return bundlePath;
+        }
+    }
 }