[KARAF-2986] Use urls for features repository completion mapping

Project: http://git-wip-us.apache.org/repos/asf/karaf/repo
Commit: http://git-wip-us.apache.org/repos/asf/karaf/commit/f4ad8c4f
Tree: http://git-wip-us.apache.org/repos/asf/karaf/tree/f4ad8c4f
Diff: http://git-wip-us.apache.org/repos/asf/karaf/diff/f4ad8c4f

Branch: refs/heads/master
Commit: f4ad8c4fa0da86e8dc178608dc13ab2711a9e51b
Parents: 005c0a3
Author: Guillaume Nodet <gno...@gmail.com>
Authored: Mon May 19 09:18:46 2014 +0200
Committer: Guillaume Nodet <gno...@gmail.com>
Committed: Mon May 19 09:19:10 2014 +0200

----------------------------------------------------------------------
 .../etc/org.apache.karaf.features.repos.cfg     | 20 +++----
 .../features/internal/service/Artifact.java     | 56 --------------------
 .../internal/service/FeatureFinder.java         | 16 +++---
 3 files changed, 20 insertions(+), 72 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/karaf/blob/f4ad8c4f/assemblies/features/framework/src/main/resources/resources/etc/org.apache.karaf.features.repos.cfg
----------------------------------------------------------------------
diff --git 
a/assemblies/features/framework/src/main/resources/resources/etc/org.apache.karaf.features.repos.cfg
 
b/assemblies/features/framework/src/main/resources/resources/etc/org.apache.karaf.features.repos.cfg
index 00844e9..7574897 100644
--- 
a/assemblies/features/framework/src/main/resources/resources/etc/org.apache.karaf.features.repos.cfg
+++ 
b/assemblies/features/framework/src/main/resources/resources/etc/org.apache.karaf.features.repos.cfg
@@ -22,13 +22,13 @@
 # It could be directly installed using feature:repo-add command
 #
 
-cellar       = org.apache.karaf.cellar:apache-karaf-cellar:xml:features:(0,]
-camel        = org.apache.camel.karaf:apache-camel:xml:features:(0,]
-camel-extras = 
org.apache-extras.camel-extra.karaf:camel-extra:xml:features:(0,]
-cxf          = org.apache.cxf.karaf:apache-cxf:xml:features:(0,]
-cxf-dosgi    = org.apache.cxf.dosgi:cxf-dosgi:xml:features:(0,]
-activemq     = org.apache.activemq:activemq-karaf:xml:features:(0,]
-jclouds      = org.jclouds.karaf:jclouds-karaf:xml:features:(0,]
-openejb      = org.apache.openejb:openejb-feature:xml:features:(0,]
-wicket       = org.ops4j.pax.wicket:features:xml:features:(0,]
-hawtio       = io.hawt:hawtio-karaf:xml:features:(0,]
+cellar       = 
mvn:org.apache.karaf.cellar/apache-karaf-cellar/${version}/xml/features
+camel        = mvn:org.apache.camel.karaf/apache-camel/${version}/xml/features
+camel-extras = 
mvn:org.apache-extras.camel-extra.karaf/camel-extra/${version}/xml/features
+cxf          = mvn:org.apache.cxf.karaf/apache-cxf/${version}/xml/features
+cxf-dosgi    = mvn:org.apache.cxf.dosgi/cxf-dosgi/${version}/xml/features
+activemq     = mvn:org.apache.activemq/activemq-karaf/${version}/xml/features
+jclouds      = mvn:org.jclouds.karaf/jclouds-karaf/${version}/xml/features
+openejb      = mvn:org.apache.openejb/openejb-feature/${version}/xml/features
+wicket       = mvn:org.ops4j.pax.wicket/features/${version}/xml/features
+hawtio       = mvn:io.hawt/hawtio-karaf/${version}/xml/features

http://git-wip-us.apache.org/repos/asf/karaf/blob/f4ad8c4f/features/core/src/main/java/org/apache/karaf/features/internal/service/Artifact.java
----------------------------------------------------------------------
diff --git 
a/features/core/src/main/java/org/apache/karaf/features/internal/service/Artifact.java
 
b/features/core/src/main/java/org/apache/karaf/features/internal/service/Artifact.java
deleted file mode 100644
index d76acd8..0000000
--- 
a/features/core/src/main/java/org/apache/karaf/features/internal/service/Artifact.java
+++ /dev/null
@@ -1,56 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements.  See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License.  You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.karaf.features.internal.service;
-
-import java.net.URI;
-
-/**
- * Simple abstraction of a maven artifact to avoid external deps
- */
-public class Artifact {
-    String groupId;
-    String artifactId;
-    String version;
-    String extension;
-    String classifier;
-
-    public Artifact(String coords) {
-        String[] coordsAr = coords.split(":");
-        if (coordsAr.length != 5) {
-            throw new IllegalArgumentException("Maven URL " + coords + " is 
malformed or not complete");
-        }
-        this.groupId = coordsAr[0];
-        this.artifactId = coordsAr[1];
-        this.version = coordsAr[4];
-        this.extension = coordsAr[2];
-        this.classifier = coordsAr[3];
-    }
-
-    public Artifact(String coords, String version) {
-        this(coords);
-        this.version = version;
-    }
-
-    public URI getMavenUrl(String version) {
-        String uriSt = "mvn:" + this.groupId + "/" + this.artifactId + "/" + 
version + "/" + this.extension + "/" + this.classifier;
-        try {
-            return new URI(uriSt);
-        } catch (Exception e) {
-            return null;
-        }
-    }
-}

http://git-wip-us.apache.org/repos/asf/karaf/blob/f4ad8c4f/features/core/src/main/java/org/apache/karaf/features/internal/service/FeatureFinder.java
----------------------------------------------------------------------
diff --git 
a/features/core/src/main/java/org/apache/karaf/features/internal/service/FeatureFinder.java
 
b/features/core/src/main/java/org/apache/karaf/features/internal/service/FeatureFinder.java
index d6defe0..8348ac0 100644
--- 
a/features/core/src/main/java/org/apache/karaf/features/internal/service/FeatureFinder.java
+++ 
b/features/core/src/main/java/org/apache/karaf/features/internal/service/FeatureFinder.java
@@ -23,12 +23,13 @@ import java.util.HashMap;
 import java.util.Map;
 import java.util.Set;
 
+import org.apache.felix.utils.properties.InterpolationHelper;
 import org.osgi.service.cm.ConfigurationException;
 import org.osgi.service.cm.ManagedService;
 
 public class FeatureFinder implements ManagedService {
 
-    final Map<String, String> nameToArtifactMap = new HashMap<String, 
String>();
+    final Map<String, String> nameToArtifactMap = new HashMap<>();
 
     public String[] getNames() {
         synchronized (nameToArtifactMap) {
@@ -38,15 +39,18 @@ public class FeatureFinder implements ManagedService {
     }
 
     public URI getUriFor(String name, String version) {
-        String coords;
+        String url;
         synchronized (nameToArtifactMap) {
-            coords = nameToArtifactMap.get(name);
+            url = nameToArtifactMap.get(name);
         }
-        if (coords == null) {
+        if (url == null) {
             return null;
         }
-        Artifact artifact = new Artifact(coords);
-        return artifact.getMavenUrl(version);
+        Map<String, String> map = new HashMap<>();
+        map.put("url", url);
+        map.put("version", version);
+        InterpolationHelper.performSubstitution(map);
+        return URI.create(map.get("url"));
     }
 
     @SuppressWarnings("rawtypes")

Reply via email to