karaf-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Andreas Pieber <anpie...@gmail.com>
Subject Re: svn commit: r1436343 - in /karaf/branches/karaf-2.2.x/deployer: blueprint/src/main/java/org/apache/karaf/deployer/blueprint/ features/src/main/java/org/apache/karaf/deployer/features/ spring/src/main/java/org/apache/karaf/deployer/spring/
Date Mon, 21 Jan 2013 16:00:41 GMT
just my 0.02€ but maybe we don't want to duplicate the same code thrice? :-)

Kind regards,
Andreas

On Mon, Jan 21, 2013 at 2:41 PM,  <gnodet@apache.org> wrote:
> Author: gnodet
> Date: Mon Jan 21 13:41:10 2013
> New Revision: 1436343
>
> URL: http://svn.apache.org/viewvc?rev=1436343&view=rev
> Log:
> [KARAF-2134] Deployers do not support mvn urls well
>
> Modified:
>     karaf/branches/karaf-2.2.x/deployer/blueprint/src/main/java/org/apache/karaf/deployer/blueprint/BlueprintTransformer.java
>     karaf/branches/karaf-2.2.x/deployer/features/src/main/java/org/apache/karaf/deployer/features/FeatureTransformer.java
>     karaf/branches/karaf-2.2.x/deployer/spring/src/main/java/org/apache/karaf/deployer/spring/SpringTransformer.java
>
> Modified: karaf/branches/karaf-2.2.x/deployer/blueprint/src/main/java/org/apache/karaf/deployer/blueprint/BlueprintTransformer.java
> URL: http://svn.apache.org/viewvc/karaf/branches/karaf-2.2.x/deployer/blueprint/src/main/java/org/apache/karaf/deployer/blueprint/BlueprintTransformer.java?rev=1436343&r1=1436342&r2=1436343&view=diff
> ==============================================================================
> --- karaf/branches/karaf-2.2.x/deployer/blueprint/src/main/java/org/apache/karaf/deployer/blueprint/BlueprintTransformer.java
(original)
> +++ karaf/branches/karaf-2.2.x/deployer/blueprint/src/main/java/org/apache/karaf/deployer/blueprint/BlueprintTransformer.java
Mon Jan 21 13:41:10 2013
> @@ -64,7 +64,7 @@ public class BlueprintTransformer {
>          // Build dom document
>          Document doc = parse(url);
>          // Heuristicly retrieve name and version
> -        String name = url.getPath();
> +        String name = getPath(url);
>          int idx = name.lastIndexOf('/');
>          if (idx >= 0) {
>              name = name.substring(idx + 1);
> @@ -185,6 +185,28 @@ public class BlueprintTransformer {
>          return db.parse(url.toString());
>      }
>
> +    protected static String getPath(URL url) {
> +        if (url.getProtocol().equals("mvn")) {
> +            String[] parts = url.toExternalForm().substring(4).split("/");
> +            String groupId;
> +            String artifactId;
> +            String version;
> +            String type;
> +            String qualifier;
> +            if (parts.length < 3 || parts.length > 5) {
> +                return url.getPath();
> +            }
> +            groupId = parts[0];
> +            artifactId = parts[1];
> +            version = parts[2];
> +            type = (parts.length >= 4) ?  "." + parts[3] : ".jar";
> +            qualifier = (parts.length >= 5) ? "-" + parts[4] :  "";
> +            return groupId.replace('.', '/') + "/" + artifactId + "/"
> +                    + version + "/" + artifactId + "-" + version + qualifier + type;
> +        }
> +        return url.getPath();
> +    }
> +
>      protected static void copyInputStream(InputStream in, OutputStream out) throws Exception
{
>          byte[] buffer = new byte[4096];
>          int len = in.read(buffer);
>
> Modified: karaf/branches/karaf-2.2.x/deployer/features/src/main/java/org/apache/karaf/deployer/features/FeatureTransformer.java
> URL: http://svn.apache.org/viewvc/karaf/branches/karaf-2.2.x/deployer/features/src/main/java/org/apache/karaf/deployer/features/FeatureTransformer.java?rev=1436343&r1=1436342&r2=1436343&view=diff
> ==============================================================================
> --- karaf/branches/karaf-2.2.x/deployer/features/src/main/java/org/apache/karaf/deployer/features/FeatureTransformer.java
(original)
> +++ karaf/branches/karaf-2.2.x/deployer/features/src/main/java/org/apache/karaf/deployer/features/FeatureTransformer.java
Mon Jan 21 13:41:10 2013
> @@ -36,7 +36,7 @@ public class FeatureTransformer {
>
>      public static void transform(URL url, OutputStream os) throws Exception {
>          // Heuristicly retrieve name and version
> -        String name = url.getPath();
> +        String name = getPath(url);
>          int idx = name.lastIndexOf('/');
>          if (idx >= 0) {
>              name = name.substring(idx + 1);
> @@ -72,6 +72,28 @@ public class FeatureTransformer {
>          os.close();
>      }
>
> +    private static String getPath(URL url) {
> +        if (url.getProtocol().equals("mvn")) {
> +            String[] parts = url.toExternalForm().substring(4).split("/");
> +            String groupId;
> +            String artifactId;
> +            String version;
> +            String type;
> +            String qualifier;
> +            if (parts.length < 3 || parts.length > 5) {
> +                return url.getPath();
> +            }
> +            groupId = parts[0];
> +            artifactId = parts[1];
> +            version = parts[2];
> +            type = (parts.length >= 4) ?  "." + parts[3] : ".jar";
> +            qualifier = (parts.length >= 5) ? "-" + parts[4] :  "";
> +            return groupId.replace('.', '/') + "/" + artifactId + "/"
> +                    + version + "/" + artifactId + "-" + version + qualifier + type;
> +        }
> +        return url.getPath();
> +    }
> +
>      private static void copyInputStream(InputStream in, OutputStream out) throws IOException
{
>          byte[] buffer = new byte[8192];
>          int len = in.read(buffer);
>
> Modified: karaf/branches/karaf-2.2.x/deployer/spring/src/main/java/org/apache/karaf/deployer/spring/SpringTransformer.java
> URL: http://svn.apache.org/viewvc/karaf/branches/karaf-2.2.x/deployer/spring/src/main/java/org/apache/karaf/deployer/spring/SpringTransformer.java?rev=1436343&r1=1436342&r2=1436343&view=diff
> ==============================================================================
> --- karaf/branches/karaf-2.2.x/deployer/spring/src/main/java/org/apache/karaf/deployer/spring/SpringTransformer.java
(original)
> +++ karaf/branches/karaf-2.2.x/deployer/spring/src/main/java/org/apache/karaf/deployer/spring/SpringTransformer.java
Mon Jan 21 13:41:10 2013
> @@ -64,7 +64,7 @@ public class SpringTransformer {
>          // Build dom document
>          Document doc = parse(url);
>          // Heuristicly retrieve name and version
> -        String name = url.getPath();
> +        String name = getPath(url);
>          int idx = name.lastIndexOf('/');
>          if (idx >= 0) {
>              name = name.substring(idx + 1);
> @@ -182,6 +182,28 @@ public class SpringTransformer {
>          return db.parse(url.toString());
>      }
>
> +    protected static String getPath(URL url) {
> +        if (url.getProtocol().equals("mvn")) {
> +            String[] parts = url.toExternalForm().substring(4).split("/");
> +            String groupId;
> +            String artifactId;
> +            String version;
> +            String type;
> +            String qualifier;
> +            if (parts.length < 3 || parts.length > 5) {
> +                return url.getPath();
> +            }
> +            groupId = parts[0];
> +            artifactId = parts[1];
> +            version = parts[2];
> +            type = (parts.length >= 4) ?  "." + parts[3] : ".jar";
> +            qualifier = (parts.length >= 5) ? "-" + parts[4] :  "";
> +            return groupId.replace('.', '/') + "/" + artifactId + "/"
> +                    + version + "/" + artifactId + "-" + version + qualifier + type;
> +        }
> +        return url.getPath();
> +    }
> +
>      protected static void copyInputStream(InputStream in, OutputStream out) throws Exception
{
>          byte[] buffer = new byte[4096];
>          int len = in.read(buffer);
>
>

Mime
View raw message